firebase-admin package

Firebase namespaced API (legacy).

Functions

Function Description
app(name)
appCheck(app) Gets the AppCheck service for the default app or a given app.admin.appCheck() can be called with no arguments to access the default app's AppCheck service or as admin.appCheck(app) to access the AppCheck service associated with a specific app.
auth(app) Gets the Auth service for the default app or a given app.admin.auth() can be called with no arguments to access the default app's Auth service or as admin.auth(app) to access the Auth service associated with a specific app.
database(app) Gets the Database service for the default app or a given app.admin.database() can be called with no arguments to access the default app's Database service or as admin.database(app) to access the Database service associated with a specific app.admin.database is also a namespace that can be used to access global constants and methods associated with the Database service.
firestore(app)
initializeApp(options, name)
installations(app) Gets the Installations service for the default app or a given app.admin.installations() can be called with no arguments to access the default app's Installations service or as admin.installations(app) to access the Installations service associated with a specific app.
instanceId(app) Gets the InstanceId service for the default app or a given app.admin.instanceId() can be called with no arguments to access the default app's InstanceId service or as admin.instanceId(app) to access the InstanceId service associated with a specific app.
machineLearning(app) Gets the MachineLearning service for the default app or a given app.admin.machineLearning() can be called with no arguments to access the default app's MachineLearning service or as admin.machineLearning(app) to access the MachineLearning service associated with a specific app.
messaging(app) Gets the Messaging service for the default app or a given app.admin.messaging() can be called with no arguments to access the default app's Messaging service or as admin.messaging(app) to access the Messaging service associated with a specific app.
projectManagement(app) Gets the ProjectManagement service for the default app or a given app.admin.projectManagement() can be called with no arguments to access the default app's ProjectManagement service, or as admin.projectManagement(app) to access the ProjectManagement service associated with a specific app.
remoteConfig(app) Gets the RemoteConfig service for the default app or a given app.admin.remoteConfig() can be called with no arguments to access the default app's RemoteConfig service or as admin.remoteConfig(app) to access the RemoteConfig service associated with a specific app.
securityRules(app) Gets the SecurityRules service for the default app or a given app.admin.securityRules() can be called with no arguments to access the default app's SecurityRules service, or as admin.securityRules(app) to access the SecurityRules service associated with a specific app.
storage(app) Gets the Storage service for the default app or a given app.admin.storage() can be called with no arguments to access the default app's Storage service or as admin.storage(app) to access the Storage service associated with a specific app.

Interfaces

Interface Description
AppOptions Available options to pass to initializeApp().
FirebaseArrayIndexError Composite type which includes both a FirebaseError object and an index which can be used to get the errored item.
FirebaseError FirebaseError is a subclass of the standard JavaScript Error object. In addition to a message string and stack trace, it contains a string code.
GoogleOAuthAccessToken Interface for Google OAuth 2.0 access tokens.
ServiceAccount

Namespaces

Namespace Description
app
appCheck
auth
credential
database
firestore
installations
instanceId
machineLearning
messaging
projectManagement
remoteConfig
securityRules
storage

Variables

Variable Description
apps
SDK_VERSION

app(name)

Signature:

export declare function app(name?: string): app.App;

Parameters

Parameter Type Description
name string

Returns:

app.App

appCheck(app)

Gets the AppCheck service for the default app or a given app.

admin.appCheck() can be called with no arguments to access the default app's AppCheck service or as admin.appCheck(app) to access the AppCheck service associated with a specific app.

Signature:

export declare function appCheck(app?: App): appCheck.AppCheck;

Parameters

Parameter Type Description
app App Optional app for which to return the AppCheck service. If not provided, the default AppCheck service is returned.

Returns:

appCheck.AppCheck

The default AppCheck service if no app is provided, or the AppCheck service associated with the provided app.

Example 1

// Get the `AppCheck` service for the default app
var defaultAppCheck = admin.appCheck();

Example 2

// Get the `AppCheck` service for a given app
var otherAppCheck = admin.appCheck(otherApp);

auth(app)

Gets the Auth service for the default app or a given app.

admin.auth() can be called with no arguments to access the default app's Auth service or as admin.auth(app) to access the Auth service associated with a specific app.

Signature:

export declare function auth(app?: App): auth.Auth;

Parameters

Parameter Type Description
app App

Returns:

auth.Auth

Example 1

// Get the Auth service for the default app
var defaultAuth = admin.auth();

Example 2

// Get the Auth service for a given app
var otherAuth = admin.auth(otherApp);

database(app)

Gets the Database service for the default app or a given app.

admin.database() can be called with no arguments to access the default app's Database service or as admin.database(app) to access the Database service associated with a specific app.

admin.database is also a namespace that can be used to access global constants and methods associated with the Database service.

Signature:

export declare function database(app?: App): database.Database;

Parameters

Parameter Type Description
app App

Returns:

database.Database

The default Database service if no app is provided or the Database service associated with the provided app.

Example 1

// Get the Database service for the default app
var defaultDatabase = admin.database();

Example 2

// Get the Database service for a specific app
var otherDatabase = admin.database(app);

firestore(app)

Signature:

export declare function firestore(app?: App): _firestore.Firestore;

Parameters

Parameter Type Description
app App

Returns:

_firestore.Firestore

initializeApp(options, name)

Signature:

export declare function initializeApp(options?: AppOptions, name?: string): app.App;

Parameters

Parameter Type Description
options AppOptions
name string

Returns:

app.App

installations(app)

Gets the Installations service for the default app or a given app.

admin.installations() can be called with no arguments to access the default app's Installations service or as admin.installations(app) to access the Installations service associated with a specific app.

Signature:

export declare function installations(app?: App): installations.Installations;

Parameters

Parameter Type Description
app App Optional app whose Installations service to return. If not provided, the default Installations service is returned.

Returns:

installations.Installations

The default Installations service if no app is provided or the Installations service associated with the provided app.

Example 1

// Get the Installations service for the default app
var defaultInstallations = admin.installations();

Example 2

// Get the Installations service for a given app
var otherInstallations = admin.installations(otherApp);

instanceId(app)

Gets the InstanceId service for the default app or a given app.

admin.instanceId() can be called with no arguments to access the default app's InstanceId service or as admin.instanceId(app) to access the InstanceId service associated with a specific app.

Signature:

export declare function instanceId(app?: App): instanceId.InstanceId;

Parameters

Parameter Type Description
app App Optional app whose InstanceId service to return. If not provided, the default InstanceId service will be returned.

Returns:

instanceId.InstanceId

The default InstanceId service if no app is provided or the InstanceId service associated with the provided app.

Example 1

// Get the Instance ID service for the default app
var defaultInstanceId = admin.instanceId();

Example 2

// Get the Instance ID service for a given app
var otherInstanceId = admin.instanceId(otherApp);

machineLearning(app)

Gets the MachineLearning service for the default app or a given app.

admin.machineLearning() can be called with no arguments to access the default app's MachineLearning service or as admin.machineLearning(app) to access the MachineLearning service associated with a specific app.

Signature:

export declare function machineLearning(app?: App): machineLearning.MachineLearning;

Parameters

Parameter Type Description
app App Optional app whose MachineLearning service to return. If not provided, the default MachineLearning service will be returned.

Returns:

machineLearning.MachineLearning

The default MachineLearning service if no app is provided or the MachineLearning service associated with the provided app.

Example 1

// Get the MachineLearning service for the default app
var defaultMachineLearning = admin.machineLearning();

Example 2

// Get the MachineLearning service for a given app
var otherMachineLearning = admin.machineLearning(otherApp);

messaging(app)

Gets the Messaging service for the default app or a given app.

admin.messaging() can be called with no arguments to access the default app's Messaging service or as admin.messaging(app) to access the Messaging service associated with a specific app.

Signature:

export declare function messaging(app?: App): messaging.Messaging;

Parameters

Parameter Type Description
app App Optional app whose Messaging service to return. If not provided, the default Messaging service will be returned.

Returns:

messaging.Messaging

The default Messaging service if no app is provided or the Messaging service associated with the provided app.

Example 1

// Get the Messaging service for the default app
var defaultMessaging = admin.messaging();

Example 2

// Get the Messaging service for a given app
var otherMessaging = admin.messaging(otherApp);

projectManagement(app)

Gets the ProjectManagement service for the default app or a given app.

admin.projectManagement() can be called with no arguments to access the default app's ProjectManagement service, or as admin.projectManagement(app) to access the ProjectManagement service associated with a specific app.

Signature:

export declare function projectManagement(app?: App): projectManagement.ProjectManagement;

Parameters

Parameter Type Description
app App Optional app whose ProjectManagement service to return. If not provided, the default ProjectManagement service will be returned. *

Returns:

projectManagement.ProjectManagement

The default ProjectManagement service if no app is provided or the ProjectManagement service associated with the provided app.

Example 1

// Get the ProjectManagement service for the default app
var defaultProjectManagement = admin.projectManagement();

Example 2

// Get the ProjectManagement service for a given app
var otherProjectManagement = admin.projectManagement(otherApp);

remoteConfig(app)

Gets the RemoteConfig service for the default app or a given app.

admin.remoteConfig() can be called with no arguments to access the default app's RemoteConfig service or as admin.remoteConfig(app) to access the RemoteConfig service associated with a specific app.

Signature:

export declare function remoteConfig(app?: App): remoteConfig.RemoteConfig;

Parameters

Parameter Type Description
app App Optional app for which to return the RemoteConfig service. If not provided, the default RemoteConfig service is returned.

Returns:

remoteConfig.RemoteConfig

The default RemoteConfig service if no app is provided, or the RemoteConfig service associated with the provided app.

Example 1

// Get the `RemoteConfig` service for the default app
var defaultRemoteConfig = admin.remoteConfig();

Example 2

// Get the `RemoteConfig` service for a given app
var otherRemoteConfig = admin.remoteConfig(otherApp);

securityRules(app)

Gets the SecurityRules service for the default app or a given app.

admin.securityRules() can be called with no arguments to access the default app's SecurityRules service, or as admin.securityRules(app) to access the SecurityRules service associated with a specific app.

Signature:

export declare function securityRules(app?: App): securityRules.SecurityRules;

Parameters

Parameter Type Description
app App Optional app to return the SecurityRules service for. If not provided, the default SecurityRules service is returned.

Returns:

securityRules.SecurityRules

The default SecurityRules service if no app is provided, or the SecurityRules service associated with the provided app.

Example 1

// Get the SecurityRules service for the default app
var defaultSecurityRules = admin.securityRules();

Example 2

// Get the SecurityRules service for a given app
var otherSecurityRules = admin.securityRules(otherApp);

storage(app)

Gets the Storage service for the default app or a given app.

admin.storage() can be called with no arguments to access the default app's Storage service or as admin.storage(app) to access the Storage service associated with a specific app.

Signature:

export declare function storage(app?: App): storage.Storage;

Parameters

Parameter Type Description
app App

Returns:

storage.Storage

Example 1

// Get the Storage service for the default app
var defaultStorage = admin.storage();

Example 2

// Get the Storage service for a given app
var otherStorage = admin.storage(otherApp);

apps

Signature:

apps: (app.App | null)[]

SDK_VERSION

Signature:

SDK_VERSION: string