Functions

Function Description
app(name)
auth(app) Gets the service for the default app or a given app.admin.auth() can be called with no arguments to access the default app's service or as admin.auth(app) to access the service associated with a specific app.
database(app) Gets the service for the default app or a given app.admin.database() can be called with no arguments to access the default app's service or as admin.database(app) to access the 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)
instanceId(app) Gets the service for the default app or a given app.admin.instanceId() can be called with no arguments to access the default app's service or as admin.instanceId(app) to access the service associated with a specific app.
machineLearning(app) Gets the service for the default app or a given app.admin.machineLearning() can be called with no arguments to access the default app's service or as admin.machineLearning(app) to access the service associated with a specific app.
messaging(app) Gets the service for the default app or a given app.admin.messaging() can be called with no arguments to access the default app's service or as admin.messaging(app) to access the service associated with a specific app.
projectManagement(app) Gets the service for the default app or a given app.admin.projectManagement() can be called with no arguments to access the default app's service, or as admin.projectManagement(app) to access the service associated with a specific app.
remoteConfig(app) Gets the service for the default app or a given app.admin.remoteConfig() can be called with no arguments to access the default app's service or as admin.remoteConfig(app) to access the service associated with a specific app.
securityRules(app) Gets the service for the default app or a given app.admin.securityRules() can be called with no arguments to access the default app's service, or as admin.securityRules(app) to access the service associated with a specific app.
storage(app) Gets the service for the default app or a given app.admin.storage() can be called with no arguments to access the default app's service or as admin.storage(app) to access the service associated with a specific app.

Interfaces

Interface Description
App A Firebase app holds the initialization information for a collection of services.Do not call this constructor directly. Instead, use to create an app.
AppOptions Available options to pass to [initializeApp()](admin#.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
auth
credential
database
firestore
instanceId
machineLearning
messaging
projectManagement
remoteConfig
securityRules
storage

Variables

Variable Description
apps
SDK_VERSION

app()

Signature:

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

Parameters

Parameter Type Description
name string

Returns:

app.App

auth()

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

admin.auth() can be called with no arguments to access the default app's service or as admin.auth(app) to access the 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()

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

admin.database() can be called with no arguments to access the default app's service or as admin.database(app) to access the 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

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()

Signature:

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

Parameters

Parameter Type Description
app App

Returns:

_firestore.Firestore

initializeApp()

Signature:

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

Parameters

Parameter Type Description
options AppOptions
name string

Returns:

app.App

instanceId()

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

admin.instanceId() can be called with no arguments to access the default app's service or as admin.instanceId(app) to access the 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. The default InstanceId service if no app is provided or the InstanceId service associated with the provided app.

Returns:

instanceId.InstanceId

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()

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

admin.machineLearning() can be called with no arguments to access the default app's service or as admin.machineLearning(app) to access the 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. The default MachineLearning service if no app is provided or the MachineLearning service associated with the provided app.

Returns:

machineLearning.MachineLearning

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()

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

admin.messaging() can be called with no arguments to access the default app's service or as admin.messaging(app) to access the 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. The default Messaging service if no app is provided or the Messaging service associated with the provided app.

Returns:

messaging.Messaging

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()

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

admin.projectManagement() can be called with no arguments to access the default app's service, or as admin.projectManagement(app) to access the 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. * The default ProjectManagement service if no app is provided or the ProjectManagement service associated with the provided app.

Returns:

projectManagement.ProjectManagement

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()

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

admin.remoteConfig() can be called with no arguments to access the default app's service or as admin.remoteConfig(app) to access the 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. The default RemoteConfig service if no app is provided, or the RemoteConfig service associated with the provided app.

Returns:

remoteConfig.RemoteConfig

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()

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

admin.securityRules() can be called with no arguments to access the default app's service, or as admin.securityRules(app) to access the 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. The default SecurityRules service if no app is provided, or the SecurityRules service associated with the provided app.

Returns:

securityRules.SecurityRules

Example 1

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

Example 2

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

storage()

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

admin.storage() can be called with no arguments to access the default app's service or as admin.storage(app) to access the 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