Registry / gcp / firebase-admin

firebase-admin

JSON →
library7.3.0pypypi✓ verified 35d ago

The Firebase Admin Python SDK enables server-side (backend) Python developers to integrate Firebase into their services and applications. It provides programmatic access to Firebase services from trusted environments, allowing for tasks such as custom authentication, managing user data, sending FCM messages, and accessing Cloud Firestore and Storage. The current version is 7.3.0, and it maintains a regular release cadence with frequent updates.

gcpauth-securitydatabasecommunication
Install & Compatibility
Where this runs
tested against v7.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.930 runs
installs and imports cleanly · install 0.0s · import 1.186s · 83.7MB
glibc
py 3.103.930 runs
installs and imports cleanly · install 7.0s · import 1.093s · 82MB
83MB installed
● package 83MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
from firebase_admin import auth
from firebase_admin import storage
from firebase_admin import messaging

Initializes the Firebase Admin SDK using service account credentials (preferably from an environment variable) or Application Default Credentials. It then demonstrates connecting to Cloud Firestore, adding a new document to a collection, and reading all documents from that collection. Remember to replace placeholder project IDs and URLs, and secure your service account key.

import os import firebase_admin from firebase_admin import credentials, firestore # Best practice: store service account key in an environment variable # and load it, or use Application Default Credentials on Google Cloud. # Replace 'path/to/your/serviceAccountKey.json' with actual path if not using env var. SERVICE_ACCOUNT_KEY_PATH = os.environ.get('FIREBASE_SERVICE_ACCOUNT_KEY_PATH', '') if SERVICE_ACCOUNT_KEY_PATH: cred = credentials.Certificate(SERVICE_ACCOUNT_KEY_PATH) else: # Fallback for Google Cloud environments where ADC are available # or if you prefer not to use a file directly for local testing cred = credentials.ApplicationDefault() # Initialize the app firebase_admin.initialize_app(cred, { 'projectId': os.environ.get('FIREBASE_PROJECT_ID', 'your-project-id'), 'databaseURL': os.environ.get('FIREBASE_DATABASE_URL', 'https://your-project-id.firebaseio.com') }) db = firestore.client() # Add data to Firestore doc_ref = db.collection('users').document('alovelace') doc_ref.set({ 'first': 'Ada', 'last': 'Lovelace', 'born': 1815 }) print(f"Added document with ID: {doc_ref.id}") # Read data from Firestore users_ref = db.collection('users') docs = users_ref.stream() print("\nAll users:") for doc in docs: print(f"{doc.id} => {doc.to_dict()}") # Clean up (optional, for demonstration purposes) # firebase_admin.delete_app(firebase_admin.get_app())
Debug
Known footguns
breakingVersion 7.0.0 dropped support for Python 3.7 and 3.8. Python 3.9 support is deprecated; developers are strongly advised to use Python 3.10 or higher.
breakingIn version 7.0.0, the `send_all()` and `send_multicast()` FCM APIs were removed.
breakingThe dependency on `google-api-python-client` was removed in v7.0.0, significantly reducing the SDK's bundle size. While this generally improves performance, ensure your project does not implicitly rely on this dependency.
deprecatedThe `ActionCodeSettings.dynamic_link_domain` parameter was deprecated in v7.1.0 in favor of `link_domain` for customizing Firebase Hosting domains in email action flows.
gotchaThe Python Admin SDK for Firebase Realtime Database does not support real-time event listeners. All data retrieval operations are blocking.
gotchaService account JSON key files contain sensitive credentials. Never commit them directly to version control.
gotchaThe library failed to find default credentials (Application Default Credentials). This typically occurs when running on environments without Google Cloud metadata or without explicitly configured `GOOGLE_APPLICATION_CREDENTIALS`.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
19 hits · last 30 days
gptbot
4
petalbot
4
claudebot
4
ahrefsbot
3
dotbot
1
amazonbot
1
bytedance
1
Resources