Skip to main content

Firebase Service

Simple Python wrapper for Firebase Realtime Database using firebase-admin.

Install

pip install firebase-service

Setup

  1. Create a Firebase project
  2. Generate a service account JSON
  3. Place it in your project root as:
firebase.json

The package loads firebase.json from the current working directory (CWD).


Usage

from firebase_service import FirebaseService

db = FirebaseService("test_node")

db.set("counter", 0)
print(db.get("counter"))

db.increment("counter", 5)
print(db.get("counter"))

Root Values

You can use None to access the root of your node:

db.set(None, "hello")
print(db.get(None))

Methods

get(directory=None)

Get data from a path.

set(directory, value)

Set a value at a path.

delete(directory)

Delete a value.

increment(directory, delta=1)

Atomically increment a number.

update(directory, callback)

Update a value using a function.

db.update("counter", lambda x: x * 2)

Example

from firebase_service import FirebaseService

emotion = FirebaseService("emotion_node")

emotion.set(None, "neutral")

def next_state(state):
    order = ["neutral", "happy", "sad", "angry"]
    return order[(order.index(state) + 1) % len(order)] if state in order else "neutral"

emotion.update(None, next_state)
print(emotion.get(None))

Notes

  • Requires firebase.json in the working directory
  • Uses Firebase Admin SDK
  • Designed for simple scripts and small backends

License

MIT

Metadata

Release files for firebase-service 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for firebase-service 0.1.0
File Size Uploaded
firebase_service-0.1.0.tar.gz 40.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for firebase-service 0.1.0
File Interpreter ABI Platform
firebase_service-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.5 kB

Release files / firebase_service-0.1.0.tar.gz

Download URL firebase_service-0.1.0.tar.gz
Size 40.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7da5ba7e40e66c1a7ee056dec30db4964e62c2da218476edb1dc67c6a4d7e97b
BLAKE2b-256 checksum
How to use checksums
a098dcbb14fe40c2ca6c487d74c06710b021b08229c4ee737feefefb4bf413ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / firebase_service-0.1.0-py3-none-any.whl

Download URL firebase_service-0.1.0-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ae66281b21ec5d2655a6c40f6ab0ff9f083f2dc4318dec4d66204f92d84351b
BLAKE2b-256 checksum
How to use checksums
6c1292becab5fb52b75846077b16b374211e9c8bb2155870252835ea86a73ba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page