### Get Installations Service Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.installations.api.md Retrieves the Installations service instance. An optional Firebase App instance can be provided. ```typescript // Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts // // @public export function getInstallations(app?: App): Installations; ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Steps to clone the repository and install local npm build and test dependencies. ```bash git clone https://github.com/firebase/firebase-admin-node.git cd firebase-admin-node # go to the firebase-admin-node directory npm install # install local npm build / test dependencies ``` -------------------------------- ### Install Firebase Admin Node.js SDK Source: https://github.com/firebase/firebase-admin-node/blob/main/README.md Install the SDK using npm. This command adds the firebase-admin package to your project's dependencies. ```bash npm install --save firebase-admin ``` -------------------------------- ### Installations Service Class Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.installations.api.md Provides methods for interacting with Firebase Installations. It includes a getter for the associated Firebase App and a method to delete a specific installation. ```typescript export class Installations { get app(): App; deleteInstallation(fid: string): Promise; } ``` -------------------------------- ### getInstallations Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.installations.api.md Retrieves the Firebase Installations instance for the current app. If no app is provided, the default app is used. ```APIDOC ## getInstallations ### Description Retrieves the Firebase Installations instance for the current app. If no app is provided, the default app is used. ### Method `getInstallations(app?: App)` ### Parameters * **app** (App) - Optional - The Firebase app to use. Defaults to the default app. ### Returns * **Installations** - The Installations instance. ``` -------------------------------- ### InstallationsErrorCode Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.installations.api.md Defines the possible error codes that can be returned by the Installations API. ```APIDOC ## InstallationsErrorCode ### Description Defines the possible error codes that can be returned by the Installations API. ### Enum Values * **INVALID_ARGUMENT**: Indicates an invalid argument was provided to an API method. * **INVALID_PROJECT_ID**: Indicates an invalid project ID was provided. * **INVALID_INSTALLATION_ID**: Indicates an invalid installation ID was provided. * **API_ERROR**: Indicates a general error occurred on the Firebase backend. ``` -------------------------------- ### Installations Error Codes Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.installations.api.md Defines a set of constants for common error codes encountered in the Installations service, such as invalid arguments or API errors. ```typescript export const InstallationsErrorCode: { readonly INVALID_ARGUMENT: "invalid-argument"; readonly INVALID_PROJECT_ID: "invalid-project-id"; readonly INVALID_INSTALLATION_ID: "invalid-installation-id"; readonly API_ERROR: "api-error"; }; export type InstallationsErrorCode = typeof InstallationsErrorCode[keyof typeof InstallationsErrorCode]; ``` -------------------------------- ### MachineLearning Client Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.machine-learning.api.md Provides access to the Machine Learning service. Use getMachineLearning() to get an instance of this class. ```APIDOC ## MachineLearning Provides access to the Machine Learning service. Use `getMachineLearning()` to get an instance of this class. ### Methods - **createModel(model: ModelOptions): Promise** Creates a new model. - **deleteModel(modelId: string): Promise** Deletes a model by its ID. - **getModel(modelId: string): Promise** Retrieves a model by its ID. - **listModels(options?: ListModelsOptions): Promise** Lists all available models, with optional filtering and pagination. - **publishModel(modelId: string): Promise** Publishes a model, making it available for use. - **unpublishModel(modelId: string): Promise** Unpublishes a model. - **updateModel(modelId: string, model: ModelOptions): Promise** Updates an existing model. ### Properties - **app**: App - The Firebase app associated with this Machine Learning instance. ``` -------------------------------- ### Run Integration Tests with Emulator Suite Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Execute integration tests against the Firebase Emulator Suite. Ensure Firebase CLI is installed and configured. ```bash firebase emulators:exec --project fake-project-id --only auth,database,firestore \ 'npx mocha "test/integration/{auth,database,firestore}.spec.ts" --slow 5000 --timeout 20000 --require ts-node/register' ``` -------------------------------- ### initializeApp Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.app.api.md Initializes a new Firebase app instance. This is the primary method for starting to use the Firebase Admin SDK. You can provide custom options and an app name. ```APIDOC ## initializeApp ### Description Initializes a new Firebase app instance. This is the primary method for starting to use the Firebase Admin SDK. You can provide custom options and an app name. ### Signature ```typescript initializeApp(options?: AppOptions, appName?: string): App ``` ### Parameters * **options** (AppOptions) - Optional. Configuration options for the Firebase app, such as credential, database URL, etc. * **appName** (string) - Optional. A unique name for the Firebase app. If not provided, the default app will be named `[DEFAULT]`. ### Returns * **App** - An `App` object representing the initialized Firebase application. ``` -------------------------------- ### Get All Initialized Apps Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.api.md Returns an array of all Firebase apps that have been initialized. ```typescript getApps(): App[]; ``` -------------------------------- ### getFirestore() Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.firestore.api.md Retrieves a Firestore instance. This can be called without arguments to get the default app's Firestore instance, or with an app or database ID to get a specific instance. ```APIDOC ## getFirestore() ### Description Retrieves a Firestore instance. This can be called without arguments to get the default app's Firestore instance, or with an app or database ID to get a specific instance. ### Method `getFirestore()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Get default Firestore instance const db = getFirestore(); // Get Firestore instance for a specific app const app = initializeApp(...); const dbForApp = getFirestore(app); // Get Firestore instance for a specific database ID const dbForId = getFirestore('my-database-id'); // Get Firestore instance for a specific app and database ID const dbForAppAndId = getFirestore(app, 'my-database-id'); ``` ### Response #### Success Response (200) - **Firestore** - An instance of the Firestore database. #### Response Example ```json { "//": "This is a representation of a Firestore instance, not a JSON response." } ``` ``` -------------------------------- ### Get Machine Learning Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.machine-learning.api.md Retrieves the MachineLearning service for the default app or a specified app. Ensure the Firebase Admin SDK is initialized before use. ```typescript import { getMachineLearning } from "firebase-admin/machine-learning"; // Get the MachineLearning service for the default app const ml = getMachineLearning(); // Or for a specific app // const ml = getMachineLearning(app); ``` -------------------------------- ### Get Storage Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.storage.api.md Initializes and returns a Storage service instance for Firebase. Can be used with a specific app instance or the default app. ```typescript import { App } from 'firebase-admin'; // To get the default Storage service for the default Firebase app: getStorage(); // To get the Storage service for a specific Firebase app: // Assuming 'app' is an instance of App getStorage(app: App); ``` -------------------------------- ### Functions.taskQueue Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.functions.api.md Gets a reference to a specific task queue for a given function. This allows for enqueuing tasks and managing them. ```APIDOC ## Functions.taskQueue ### Description Gets a reference to a specific task queue for a given function. This allows for enqueuing tasks and managing them. ### Method `taskQueue>(functionName: string, extensionId?: string): TaskQueue` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **functionName** (string) - Required - The name of the function associated with the task queue. - **extensionId** (string) - Optional - The ID of the extension if the function is part of an extension. ### Response #### Success Response (TaskQueue) - **TaskQueue** - An object representing the task queue with methods to enqueue and delete tasks. ``` -------------------------------- ### Get Extensions Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.extensions.api.md Retrieves an instance of the Extensions client. An optional Firebase App instance can be provided. ```typescript import * as admin from "firebase-admin"; // Initialize Firebase Admin SDK (if not already initialized) // admin.initializeApp(); // Get the Extensions client const extensions = admin.extensions(); ``` -------------------------------- ### Get Functions Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.functions.api.md Retrieves the Functions service for the default app or a specified app. Ensure Firebase Admin SDK is initialized before use. ```typescript import { getFunctions } from "firebase-admin/functions"; // For the default app const functions = getFunctions(); // For a specific app // const functions = getFunctions(app); ``` -------------------------------- ### Get Storage Ruleset Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Retrieves the currently active Storage ruleset for a given bucket. If no bucket is specified, it defaults to the project's default storage bucket. ```typescript const storageRuleset = await rules.getStorageRuleset("my-storage-bucket"); ``` -------------------------------- ### FirebaseInstallationsError Class Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.installations.api.md Represents an error specific to the Firebase Installations service. It extends the base FirebaseError and requires an ErrorInfo object for initialization. ```typescript export class FirebaseInstallationsError extends FirebaseError { // Warning: (ae-forgotten-export) The symbol "ErrorInfo" needs to be exported by the entry point index.d.ts constructor(info: ErrorInfo, message?: string); } ``` -------------------------------- ### Get Specific Ruleset Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Retrieves a specific ruleset by its resource name. Use this to inspect previously created or released rulesets. ```typescript const ruleset = await rules.getRuleset("projects/my-project/rulesets/my-ruleset-id"); ``` -------------------------------- ### Get DataConnect Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.data-connect.api.md Instantiates a DataConnect client with the provided connector configuration and an optional Firebase app instance. Use this to interact with Firebase Data Connect services. ```typescript import { FirebaseApp } from "firebase/app"; import { ConnectorConfig, DataConnect } from "firebase-admin/data-connect"; function getDataConnect(connectorConfig: ConnectorConfig, app?: FirebaseApp): DataConnect; ``` -------------------------------- ### Run Integration Test Suite Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Execute the full integration test suite. This command builds and runs all tests. ```bash npm run integration ``` -------------------------------- ### Run Unit Tests Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Command to run the unit test suite, which also includes linting. ```bash npm test # Lint and run unit test suite ``` -------------------------------- ### Initialize Firebase Admin SDK (ES2015) Source: https://github.com/firebase/firebase-admin-node/blob/main/README.md Initialize the Firebase Admin SDK using ES2015 import syntax. Ensure your environment supports ES modules. ```javascript import { initializeApp } from "firebase-admin/app"; initializeApp(); ``` -------------------------------- ### Installations.deleteInstallation Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.installations.api.md Deletes a specific Firebase Installation ID. This is a destructive operation. ```APIDOC ## Installations.deleteInstallation ### Description Deletes a specific Firebase Installation ID. This is a destructive operation. ### Method `deleteInstallation(fid: string): Promise` ### Parameters #### Path Parameters * **fid** (string) - Required - The Firebase Installation ID (FID) to delete. ### Returns * **Promise** - A promise that resolves when the installation has been deleted. ``` -------------------------------- ### Run Integration Tests with Multi-tenancy Auth Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Execute the integration tests, including multi-tenancy Auth tests. This requires an Identity Platform project with multi-tenancy enabled. ```bash npm run test:integration -- --testMultiTenancy ``` -------------------------------- ### Get Firestore Ruleset Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Retrieves the currently active Firestore ruleset. This is the set of rules that is currently enforced. ```typescript const firestoreRuleset = await rules.getFirestoreRuleset(); ``` -------------------------------- ### Run Unit Tests (Skip Linter) Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Command to run only the unit tests, skipping the linter. ```bash npm run test:unit ``` -------------------------------- ### listProviderConfigs Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md Lists all authentication provider configurations, with options for filtering and pagination. ```APIDOC ## listProviderConfigs ### Description Lists all authentication provider configurations, with options for filtering and pagination. ### Method listProviderConfigs ### Parameters #### Request Body - **options** (AuthProviderConfigFilter) - Required - Filter and pagination options. - **maxResults** (number) - Optional - The maximum number of results to return. - **pageToken** (string) - Optional - A page token for retrieving the next set of results. - **type** ('saml' | 'oidc') - Required - The type of provider configurations to list. ### Response #### Success Response (ListProviderConfigResults) - Returns a ListProviderConfigResults object containing a list of provider configurations and a page token if more results are available. ### Request Example ```javascript const filter = { type: "saml", maxResults: 10 }; const results = await auth.listProviderConfigs(filter); ``` ### Response Example ```json { "providerConfigs": [ { "providerId": "saml.example.com", "enabled": true, "displayName": "Example SAML Provider", "type": "saml" } ], "pageToken": "next-page-token" } ``` ``` -------------------------------- ### Deploy Data Connector Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Use this command to deploy a Data Connector to your Firebase project. Ensure you replace `` with your actual project ID. ```bash firebase deploy --only dataconnect:my-service:my-connector --config ./test/integration/dataconnect/firebase.json --project ``` -------------------------------- ### Get Default Application Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.api.md Retrieves the default Firebase app instance. If no app has been initialized, this will throw an error. ```typescript getApp(appName?: string): App; ``` -------------------------------- ### applicationDefault Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.app.api.md Creates a `Credential` object using the application default credentials. This is typically used in environments where credentials can be automatically discovered, like Google Cloud. ```APIDOC ## applicationDefault ### Description Creates a `Credential` object using the application default credentials. This is typically used in environments where credentials can be automatically discovered, like Google Cloud. ### Signature ```typescript applicationDefault(httpAgent?: Agent): Credential ``` ### Parameters * **httpAgent** (Agent) - Optional. An `http.Agent` instance to use for network requests. ### Returns * **Credential** - A `Credential` object that can be used for authentication. ``` -------------------------------- ### Get Security Rules Service Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Retrieves the Security Rules service for the default Firebase app or a specified app. ```typescript import { getSecurityRules } from "firebase-admin/security-rules"; // Get the Security Rules service for the default app const rules = getSecurityRules(); // Get the Security Rules service for a specific app // const customApp = admin.app("my-app"); // const rules = getSecurityRules(customApp); ``` -------------------------------- ### Get Eventarc Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.eventarc.api.md Retrieves the Eventarc service for the current app. If no app is provided, it uses the default app. ```typescript import * as admin from 'firebase-admin'; // Get an instance of the Eventarc service const eventarc = admin.getEventarc(); ``` -------------------------------- ### initializeApp Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.api.md Initializes a Firebase app. This function can be called with or without options. If no options are provided, it attempts to initialize the app using application default credentials. ```APIDOC ## initializeApp ### Description Initializes a Firebase app. This function can be called with or without options. If no options are provided, it attempts to initialize the app using application default credentials. ### Signature `initializeApp(options?: AppOptions, appName?: string): App` ### Parameters #### Parameters - **options** (AppOptions) - Optional. Configuration options for the Firebase app. - **appName** (string) - Optional. The name of the Firebase app to initialize. If not provided, the default app name is used. ``` -------------------------------- ### Run Integration Tests with Rule Updates Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Run the integration tests and force an update of the Realtime Database security rules. This is necessary for certain Database integration tests to pass. ```bash npm run test:integration -- --updateRules ``` -------------------------------- ### Get Eventarc Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.eventarc.api.md Retrieves the Eventarc service instance. If no Firebase App instance is provided, the default app is used. ```APIDOC ## getEventarc(app?: App): Eventarc ### Description Retrieves the Eventarc service instance. If no Firebase App instance is provided, the default app is used. ### Parameters #### Path Parameters - **app** (App) - Optional - The Firebase App instance to use. ``` -------------------------------- ### getDatabase() Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.database.api.md Retrieves the Database service for the default app or a specified app. ```APIDOC ## getDatabase(app?: App) ### Description Retrieves the Database service for the default app or a specified app. ### Method `getDatabase` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript const database = getDatabase(); ``` ### Response #### Success Response - **Database** (Database) - The Database service instance. ``` -------------------------------- ### List Models Options Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.machine-learning.api.md Options for listing machine learning models. ```APIDOC ## ListModelsOptions Options for listing machine learning models. ### Properties - **filter** (string) - Optional - A filter string to apply to the list operation. - **pageSize** (number) - Optional - The maximum number of models to return in a single page. - **pageToken** (string) - Optional - A page token for retrieving the next page of results. ``` -------------------------------- ### Initialize Firebase App Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.api.md Initializes a Firebase app with the provided options and an optional app name. If no options are provided, it attempts to use default credentials. ```typescript initializeApp(options?: AppOptions, appName?: string): App; ``` -------------------------------- ### Get Download URL for a File Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.storage.api.md Retrieves the download URL for a given Firebase Storage file. Requires the file object from @google-cloud/storage. ```typescript import { File as File_2 } from '@google-cloud/storage'; // Assuming 'file' is an instance of File_2 from @google-cloud/storage getDownloadURL(file: File_2): Promise; ``` -------------------------------- ### Release Storage Ruleset from Source Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Creates a new ruleset from source code and immediately releases it as the active Storage ruleset for a given bucket. This is a convenient way to deploy new Storage rules. ```typescript const releasedRuleset = await rules.releaseStorageRulesetFromSource("rules_version = '2';\n// Storage rules example\nservice firebase.storage {\n match /b/{bucket}/o {\n match /{allPaths=**} {\n allow read, write: if request.auth != null;\n }\n }\n}", "my-storage-bucket"); ``` -------------------------------- ### Get Remote Config Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.remote-config.api.md Retrieves the Remote Config service instance for the Firebase app. If no app is provided, it uses the default app. ```typescript import { getRemoteConfig } from 'firebase-admin/remote-config'; // Get a Remote Config instance for the default app const remoteConfig = getRemoteConfig(); // Get a Remote Config instance for a specific app // const remoteConfig = getRemoteConfig(app); ``` -------------------------------- ### initializeFirestore Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.firestore.api.md Initializes the Firestore client. This function can be called with or without specific database settings and a database ID. ```APIDOC ## initializeFirestore ### Description Initializes the Firestore client for the given Firebase App. ### Signature ```typescript initializeFirestore(app: App, settings?: FirestoreSettings): Firestore; initializeFirestore(app: App, settings: FirestoreSettings, databaseId: string): Firestore; ``` ### Parameters * `app` (App) - The Firebase App instance. * `settings` (FirestoreSettings, optional) - Configuration options for Firestore. * `databaseId` (string, optional) - The ID of the Firestore database to use. ``` -------------------------------- ### Authorize Google Cloud SDK Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Authorize the gcloud utility with Google application default credentials to run tests. ```bash gcloud beta auth application-default login ``` -------------------------------- ### Runtime Class Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.extensions.api.md The `Runtime` class allows you to manage the processing state and report errors for an extension. ```APIDOC ## Class: Runtime ### Description Manages the processing state and error reporting for an extension. ### Methods - `setFatalError(errorMessage: string): Promise`: Reports a fatal error that will stop the extension's execution. - `setProcessingState(state: SettableProcessingState, detailMessage: string): Promise`: Updates the processing state of the extension. ``` -------------------------------- ### getDatabaseWithUrl(url, app?) Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.database.api.md Retrieves the Database service for the default app or a specified app, using a custom database URL. ```APIDOC ## getDatabaseWithUrl(url: string, app?: App) ### Description Retrieves the Database service for the default app or a specified app, using a custom database URL. ### Method `getDatabaseWithUrl` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript const database = getDatabaseWithUrl('https://.firebaseio.com'); ``` ### Response #### Success Response - **Database** (Database) - The Database service instance. ``` -------------------------------- ### getExtensions Function Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.extensions.api.md A factory function to retrieve an `Extensions` instance. It can optionally take an `App` instance. ```APIDOC ## Function: getExtensions ### Description Retrieves an instance of the `Extensions` client. ### Parameters - `app` (App, optional): The Firebase App instance to use. If not provided, the default app will be used. ### Returns - `Extensions`: An instance of the `Extensions` client. ``` -------------------------------- ### Get Phone Number Verification Instance Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.phone-number-verification.api.md Retrieves the PhoneNumberVerification service for the default Firebase app or a specified app instance. Ensure the Firebase Admin SDK is initialized before use. ```typescript import { getPhoneNumberVerification } from "firebase-admin/phone-number-verification"; // Get the service for the default app const verification = getPhoneNumberVerification(); // Or, get the service for a specific app // import * as admin from "firebase-admin"; // const app = admin.app(); // const verification = getPhoneNumberVerification(app); ``` -------------------------------- ### ProjectManagement.shaCertificate Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.project-management.api.md Creates a ShaCertificate object from a SHA hash. ```APIDOC ## Utility Function ### Description Creates a ShaCertificate object from a SHA hash. This is a utility function and does not represent an API endpoint. ### Function Signature `shaCertificate(shaHash: string): ShaCertificate` ### Parameters - **shaHash** (string) - Required - The SHA hash string. ``` -------------------------------- ### getApps Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.app.api.md Retrieves all Firebase app instances that have been initialized. This returns an array of all `App` objects. ```APIDOC ## getApps ### Description Retrieves all Firebase app instances that have been initialized. This returns an array of all `App` objects. ### Signature ```typescript getApps(): App[] ``` ### Returns * **App[]** - An array containing all initialized `App` objects. ``` -------------------------------- ### getDataConnect Function Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.data-connect.api.md Initializes and returns a DataConnect instance. ```APIDOC ## getDataConnect Function Initializes and returns a DataConnect instance. ### Signature ```typescript function getDataConnect(connectorConfig: ConnectorConfig, app?: App): DataConnect; ``` ### Parameters - **connectorConfig** (ConnectorConfig) - Required - Configuration for the connector. - **app** (App) - Optional - The Firebase App instance. ``` -------------------------------- ### Create a Rules File from Source Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Creates a RulesFile object from a given name and source content. This is a helper function to prepare rules for other operations. ```typescript const rulesFile = rules.createRulesFileFromSource("my-rules-file.txt", "rules_version = '2';\nservice cloud.firestore {\n match /databases/{database}/documents {\n match /{document=**} {\n allow read, write: if true;\n }\n }\n}"); ``` -------------------------------- ### MachineLearning Class Methods Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.machine-learning.api.md Provides methods for interacting with the Machine Learning service, including creating, deleting, retrieving, listing, publishing, unpublishing, and updating models. These operations are asynchronous and return Promises. ```typescript declare const ml: MachineLearning; // Create a model const model = await ml.createModel({ displayName: "My Model", tags: ["image-classification", "v1"], tfliteModel: { gcsTfliteUri: "gs://bucket/model.tflite" } }); // Get a model const fetchedModel = await ml.getModel(model.modelId); // List models const modelsPage = await ml.listModels({ pageSize: 10, pageToken: "nextPageToken" }); // Update a model const updatedModel = await ml.updateModel(model.modelId, { displayName: "My Updated Model" }); // Publish a model const publishedModel = await ml.publishModel(model.modelId); // Unpublish a model const unpublishedModel = await ml.unpublishModel(model.modelId); // Delete a model await ml.deleteModel(model.modelId); ``` -------------------------------- ### ConnectorConfig Interface Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.data-connect.api.md Configuration options for a Data Connect connector. ```APIDOC ## ConnectorConfig Interface Configuration options for a Data Connect connector. ### Properties - **connector** (string) - Optional - The name of the connector. - **location** (string) - Required - The location of the connector. - **serviceId** (string) - Required - The ID of the service. ``` -------------------------------- ### GraphqlOptions Interface Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.data-connect.api.md Options for executing GraphQL operations. ```APIDOC ## GraphqlOptions Interface Options for executing GraphQL operations. ### Properties - **impersonate** (ImpersonateAuthenticated | ImpersonateUnauthenticated) - Optional - Impersonation settings. - **operationName** (string) - Optional - The name of the GraphQL operation. - **variables** (Variables) - Optional - Variables for the GraphQL query. ``` -------------------------------- ### getMessaging Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.messaging.api.md Retrieves a Messaging service instance. If no `App` instance is provided, the default app will be used. ```APIDOC ## getMessaging ### Description Retrieves a Messaging service instance. If no `App` instance is provided, the default app will be used. ### Method `getMessaging(app?: App): Messaging` ### Parameters #### Path Parameters - **app** (App) - Optional - The Firebase App instance to use. ``` -------------------------------- ### Database.getRules() Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.database.api.md Retrieves the current security rules for the database. ```APIDOC ## Database.getRules() ### Description Retrieves the current security rules for the database. ### Method `getRules` ### Endpoint N/A (SDK method) ### Parameters None ### Request Example ```typescript database.getRules().then(rules => console.log(rules)); ``` ### Response #### Success Response - **rules** (string) - The security rules as a string. ``` -------------------------------- ### createCustomToken Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md Creates a custom authentication token for a given user ID. This token can be used to sign in users with custom authentication systems. ```APIDOC ## createCustomToken ### Description Creates a custom authentication token for a given user ID. This token can be used to sign in users with custom authentication systems. ### Method createCustomToken ### Parameters #### Path Parameters - **uid** (string) - Required - The user ID for which to create the custom token. - **developerClaims** (object) - Optional - Custom claims to include in the token. ### Response #### Success Response (string) - Returns the generated custom token as a string. ### Request Example ```javascript const uid = "some-uid"; const token = await auth.createCustomToken(uid, { role: "admin" }); ``` ### Response Example ```javascript "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." ``` ``` -------------------------------- ### cert Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.api.md Returns a `Credential` instance that can be used to authenticate your application using a service account key. The key can be provided as a file path or a JSON object. ```APIDOC ## cert ### Description Returns a `Credential` instance that can be used to authenticate your application using a service account key. The key can be provided as a file path or a JSON object. ### Signature `cert(serviceAccountPathOrObject: string | ServiceAccount, httpAgent?: Agent): Credential` ### Parameters #### Parameters - **serviceAccountPathOrObject** (string | ServiceAccount) - Required. The path to the service account key file or a JSON object containing the service account credentials. - **httpAgent** (Agent) - Optional. An HTTP agent to use for network requests. ``` -------------------------------- ### IosApp.getConfig Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.project-management.api.md Retrieves the configuration object for an iOS app. ```APIDOC ## GET /projects/{projectId}/iosApps/{appId}/config ### Description Retrieves the configuration object for an iOS app. ### Method GET ### Endpoint `/projects/{projectId}/iosApps/{appId}/config` ### Parameters #### Path Parameters - **appId** (string) - Required - The unique identifier of the iOS app. ### Response #### Success Response (200) - **string** - The configuration object for the iOS app. ``` -------------------------------- ### cert Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.app.api.md Creates a `Credential` object from a service account file or object. This is commonly used for server-side authentication. ```APIDOC ## cert ### Description Creates a `Credential` object from a service account file or object. This is commonly used for server-side authentication. ### Signature ```typescript cert(serviceAccountPathOrObject: string | ServiceAccount, httpAgent?: Agent): Credential ``` ### Parameters * **serviceAccountPathOrObject** (string | ServiceAccount) - Either the file path to the service account JSON file, or a `ServiceAccount` object containing the credentials. * **httpAgent** (Agent) - Optional. An `http.Agent` instance to use for network requests. ### Returns * **Credential** - A `Credential` object that can be used for authentication. ``` -------------------------------- ### OperationOptions Interface Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.data-connect.api.md Options for executing operations. ```APIDOC ## OperationOptions Interface Options for executing operations. ### Properties - **impersonate** (ImpersonateAuthenticated | ImpersonateUnauthenticated) - Optional - Impersonation settings. ``` -------------------------------- ### RemoteConfig Class Methods Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.remote-config.api.md This section details the methods available on the RemoteConfig class for managing configuration templates and versions. ```APIDOC ## Class: RemoteConfig ### Description Provides methods to manage Firebase Remote Config templates and versions. ### Methods #### `createTemplateFromJSON(json: string): RemoteConfigTemplate` Creates a Remote Config template object from a JSON string. #### `getServerTemplate(options?: GetServerTemplateOptions): Promise` Fetches the server-side Remote Config template. #### `getTemplate(): Promise` Fetches the latest version of the Remote Config template. #### `getTemplateAtVersion(versionNumber: number | string): Promise` Fetches a specific version of the Remote Config template. #### `initServerTemplate(options?: InitServerTemplateOptions): ServerTemplate` Initializes a server-side Remote Config template. #### `listVersions(options?: ListVersionsOptions): Promise` Lists all versions of the Remote Config template. #### `publishTemplate(template: RemoteConfigTemplate, options?: { force: boolean }): Promise` Publishes a Remote Config template. The `force` option allows overwriting the current template. #### `rollback(versionNumber: number | string): Promise` Rolls back the Remote Config template to a specified version. #### `validateTemplate(template: RemoteConfigTemplate): Promise` Validates a Remote Config template before publishing. ``` -------------------------------- ### Extensions Class Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.extensions.api.md The `Extensions` class provides access to the extension's runtime. It holds a reference to the `App` instance. ```APIDOC ## Class: Extensions ### Description Provides access to the extension's runtime. ### Properties - `app` (App): The Firebase App instance associated with this Extensions client. ### Methods - `runtime(): Runtime`: Returns the `Runtime` object for managing the extension's execution state. ``` -------------------------------- ### SecurityRules.releaseStorageRulesetFromSource Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Creates a new ruleset from the provided source content and immediately releases it as the active Storage security ruleset for a given bucket. If no bucket is specified, the default bucket is used. This operation is asynchronous and returns a Promise that resolves with the newly created and released `Ruleset` object. ```APIDOC ## SecurityRules.releaseStorageRulesetFromSource ### Description Creates a new ruleset from the provided source content and immediately releases it as the active Storage security ruleset for a given bucket. If no bucket is specified, the default bucket is used. This operation is asynchronous and returns a Promise that resolves with the newly created and released `Ruleset` object. ### Method `releaseStorageRulesetFromSource(source: string | Buffer, bucket?: string): Promise` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **source** (string | Buffer) - Required - The source content of the ruleset. - **bucket** (string) - Optional - The name of the storage bucket for which to release the ruleset. ### Request Example ```typescript const storageRulesSource = '{\n "rules": {\n "objects": {\n "*.jpg": {\n "allow read": "request.auth != null",\n "allow write": "request.auth != null && resource.size < 1024*1024"\n }\n }\n }\n}'; // Release for default bucket securityRules.releaseStorageRulesetFromSource(storageRulesSource) .then((ruleset: Ruleset) => { console.log('Storage ruleset released from source (default bucket):', ruleset.name); }) .catch((error) => { console.error('Error releasing Storage ruleset from source (default bucket):', error); }); // Release for a specific bucket securityRules.releaseStorageRulesetFromSource(storageRulesSource, 'my-specific-bucket') .then((ruleset: Ruleset) => { console.log('Storage ruleset released from source (specific bucket):', ruleset.name); }) .catch((error) => { console.error('Error releasing Storage ruleset from source (specific bucket):', error); }); ``` ### Response #### Success Response (200) - **Ruleset** - An object containing metadata about the newly released Storage ruleset, including its `name` and `createTime`. ``` -------------------------------- ### SecurityRules.createRulesFileFromSource Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Creates a `RulesFile` object from a given name and source content. This is a utility function and does not create a ruleset on the server. ```APIDOC ## SecurityRules.createRulesFileFromSource ### Description Creates a `RulesFile` object from a given name and source content. This is a utility function and does not create a ruleset on the server. ### Method `createRulesFileFromSource(name: string, source: string | Buffer): RulesFile` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (string) - Required - The name of the rules file. - **source** (string | Buffer) - Required - The content of the rules file, which can be a string or a Buffer. ### Request Example ```typescript const rulesFile = securityRules.createRulesFileFromSource('my-rules.json', '{\n "rules": {\n "data": {\n ".read": "true"\n }\n }\n}'); console.log(rulesFile); ``` ### Response #### Success Response - **RulesFile** - An object representing the rules file with `name` and `content` properties. ``` -------------------------------- ### Auth Class Methods Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md Provides access to the Firebase app instance, project configuration manager, and tenant manager. ```typescript export class Auth extends BaseAuth { // Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts get app(): App; projectConfigManager(): ProjectConfigManager; tenantManager(): TenantManager; } ``` -------------------------------- ### Certificate Credential Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.api.md Creates a credential from a service account file path or object. Requires a service account key. ```typescript cert(serviceAccountPathOrObject: string | ServiceAccount, httpAgent?: Agent): Credential; ``` -------------------------------- ### AllowByDefaultWrap Interface Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md A wrapper interface for security settings that allow by default, with an option to specify disallowed regions. ```typescript export interface AllowByDefaultWrap { allowByDefault: AllowByDefault; // @alpha (undocumented) allowlistOnly?: never; } ``` -------------------------------- ### Create a Ruleset Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Creates a new ruleset from a RulesFile object. This is useful when you have a pre-defined RulesFile structure. ```typescript const ruleset = await rules.createRuleset({ name: "my-ruleset-name", content: "rules_version = '2';\nservice cloud.firestore {\n match /databases/{database}/documents {\n match /{document=**} {\n allow read, write: if true;\n }\n }\n}", }); ``` -------------------------------- ### getApp Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.app.api.md Retrieves an existing Firebase app instance by its name. If no name is provided, it returns the default app. ```APIDOC ## getApp ### Description Retrieves an existing Firebase app instance by its name. If no name is provided, it returns the default app. ### Signature ```typescript getApp(appName?: string): App ``` ### Parameters * **appName** (string) - Optional. The name of the Firebase app to retrieve. If omitted, the default app is returned. ### Returns * **App** - The `App` object for the specified app name, or the default app if no name is provided. ``` -------------------------------- ### List Ruleset Metadata Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Lists metadata for all rulesets in the project. Supports pagination to handle large numbers of rulesets. ```typescript const rulesetList = await rules.listRulesetMetadata(10, "nextPageToken"); ``` -------------------------------- ### AndroidApp.getConfig Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.project-management.api.md Retrieves the configuration object for an Android app. ```APIDOC ## GET /projects/{projectId}/androidApps/{appId}/config ### Description Retrieves the configuration object for an Android app. ### Method GET ### Endpoint `/projects/{projectId}/androidApps/{appId}/config` ### Parameters #### Path Parameters - **appId** (string) - Required - The unique identifier of the Android app. ### Response #### Success Response (200) - **string** - The configuration object for the Android app. ``` -------------------------------- ### ProjectManagement.listAppMetadata Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.project-management.api.md Lists metadata for all apps (Android and iOS) in the Firebase project. ```APIDOC ## GET /projects/{projectId}/apps ### Description Lists metadata for all apps (Android and iOS) in the Firebase project. ### Method GET ### Endpoint `/projects/{projectId}/apps` ### Response #### Success Response (200) - **AppMetadata[]** - An array of AppMetadata objects. ``` -------------------------------- ### createProviderConfig Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md Creates a new authentication provider configuration. This allows you to configure SAML or OIDC providers for your Firebase project. ```APIDOC ## createProviderConfig ### Description Creates a new authentication provider configuration. This allows you to configure SAML or OIDC providers for your Firebase project. ### Method createProviderConfig ### Parameters #### Request Body - **config** (AuthProviderConfig) - Required - The configuration for the new provider. - **displayName** (string) - Optional - The display name for the provider. - **enabled** (boolean) - Required - Whether the provider is enabled. - **providerId** (string) - Required - The unique ID of the provider. - **type** ('saml' | 'oidc') - Required - The type of the provider. ### Response #### Success Response (AuthProviderConfig) - Returns the created provider configuration. ### Request Example ```javascript const samlConfig = { providerId: "saml.example.com", enabled: true, displayName: "Example SAML Provider", type: "saml" }; const createdConfig = await auth.createProviderConfig(samlConfig); ``` ### Response Example ```json { "providerId": "saml.example.com", "enabled": true, "displayName": "Example SAML Provider", "type": "saml" } ``` ``` -------------------------------- ### TenantManager Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md Provides methods for managing Firebase Authentication tenants. This includes creating, deleting, retrieving, listing, and updating tenants, as well as obtaining an authenticated instance for a specific tenant. ```APIDOC ## TenantManager ### Description Manages Firebase Authentication tenants. Allows for CRUD operations on tenants and retrieval of tenant-specific authentication instances. ### Methods - **authForTenant(tenantId: string): TenantAwareAuth** Returns a `TenantAwareAuth` instance for the specified tenant. - **createTenant(tenantOptions: CreateTenantRequest): Promise** Creates a new Firebase Authentication tenant. - **deleteTenant(tenantId: string): Promise** Deletes an existing Firebase Authentication tenant. - **getTenant(tenantId: string): Promise** Retrieves a specific Firebase Authentication tenant by its ID. - **listTenants(maxResults?: number, pageToken?: string): Promise** Lists all Firebase Authentication tenants, with optional pagination. - **updateTenant(tenantId: string, tenantOptions: UpdateTenantRequest): Promise** Updates an existing Firebase Authentication tenant. ``` -------------------------------- ### Run Linter Source: https://github.com/firebase/firebase-admin-node/blob/main/CONTRIBUTING.md Command to run the TSLint linter on source files written in TypeScript. ```bash npm run lint ``` -------------------------------- ### Database.setRules(source) Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.database.api.md Sets the security rules for the database. ```APIDOC ## Database.setRules(source: string | Buffer | object) ### Description Sets the security rules for the database. ### Method `setRules` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **source** (string | Buffer | object) - Required - The security rules to set. Can be a string, Buffer, or JSON object. ``` -------------------------------- ### SecurityRules.createRuleset Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.security-rules.api.md Creates a new ruleset from a `RulesFile` object. This operation is asynchronous and returns a Promise that resolves with the created `Ruleset`. ```APIDOC ## SecurityRules.createRuleset ### Description Creates a new ruleset from a `RulesFile` object. This operation is asynchronous and returns a Promise that resolves with the created `Ruleset`. ### Method `createRuleset(file: RulesFile): Promise` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (RulesFile) - Required - An object representing the rules file to be created, containing `name` and `content`. ### Request Example ```typescript import { RulesFile, Ruleset } from 'firebase-admin/lib/security-rules'; const rulesFile: RulesFile = { name: 'my-rules.json', content: '{\n "rules": {\n "data": {\n ".read": "auth != null",\n ".write": "auth != null"\n }\n }\n}' }; securityRules.createRuleset(rulesFile) .then((ruleset: Ruleset) => { console.log('Ruleset created:', ruleset.name); }) .catch((error) => { console.error('Error creating ruleset:', error); }); ``` ### Response #### Success Response (200) - **Ruleset** - An object containing metadata about the newly created ruleset, including its `name` and `createTime`. ``` -------------------------------- ### generateSignInWithEmailLink Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md Generates a sign-in with email link. This link can be used to allow users to sign in to your application without a password. ```APIDOC ## generateSignInWithEmailLink ### Description Generates a sign-in with email link. This link can be used to allow users to sign in to your application without a password. ### Method generateSignInWithEmailLink ### Parameters #### Path Parameters - **email** (string) - Required - The email address of the user. - **actionCodeSettings** (ActionCodeSettings) - Required - Settings for the action code, such as continue URL. ### Response #### Success Response (string) - Returns the generated sign-in with email link as a string. ### Request Example ```javascript const email = "user@example.com"; const settings = { url: "https://example.com/finishSignUp" }; const link = await auth.generateSignInWithEmailLink(email, settings); ``` ### Response Example ```javascript "https://your-project.firebaseapp.com/__/auth/action?mode=signIn&oobCode=GENERATED_CODE" ``` ``` -------------------------------- ### Model Options Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.machine-learning.api.md Defines the options for creating or updating a machine learning model. ```APIDOC ## ModelOptions Defines the options for creating or updating a machine learning model. ### Properties - **displayName** (string) - Optional - The display name of the model. - **tags** (string[]) - Optional - An array of tags associated with the model. - **tfliteModel** (object) - Optional - Configuration for a TFLite model. - **gcsTfliteUri** (string) - The Google Cloud Storage URI of the TFLite model file. ``` -------------------------------- ### Tenant Source: https://github.com/firebase/firebase-admin-node/blob/main/etc/firebase-admin.auth.api.md Represents a Firebase Authentication tenant, allowing for isolated user management and configuration within a single project. ```APIDOC ## Tenant Represents a Firebase Authentication tenant. ### Properties * **tenantId** (string) - The unique identifier for the tenant. * **displayName** (string) - Optional - The display name of the tenant. * **anonymousSignInEnabled** (boolean) - Indicates if anonymous sign-in is enabled for the tenant. * **emailPrivacyConfig** (EmailPrivacyConfig) - Optional - Configuration for email privacy. * **smsRegionConfig** (SmsRegionConfig) - Optional - Configuration for SMS regions. * **passwordPolicyConfig** (PasswordPolicyConfig) - Optional - Configuration for password policies. * **emailSignInConfig** (EmailSignInProviderConfig) - Optional - Configuration for email sign-in providers. * **multiFactorConfig** (MultiFactorConfig) - Optional - Configuration for multi-factor authentication. * **recaptchaConfig** (RecaptchaConfig) - Optional - Configuration for reCAPTCHA. * **testPhoneNumbers** (object) - Optional - A map of test phone numbers and their verification codes. ### Methods * **toJSON()**: Converts the tenant object to a plain JavaScript object. ``` -------------------------------- ### Initialize Firebase Admin SDK (CommonJS) Source: https://github.com/firebase/firebase-admin-node/blob/main/README.md Initialize the Firebase Admin SDK in your Node.js application using CommonJS modules. This is a prerequisite for using other Firebase services. ```javascript const { initializeApp } = require("firebase-admin/app"); initializeApp(); ```