Simple Firebase RTDB wrapper
Project description
Firebase Service
Simple Python wrapper for Firebase Realtime Database using firebase-admin.
Install
pip install firebase-service
Setup
- Create a Firebase project
- Generate a service account JSON
- Place it in your project root as:
firebase.json
The package loads
firebase.jsonfrom 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.jsonin the working directory - Uses Firebase Admin SDK
- Designed for simple scripts and small backends
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file firebase_service-0.1.0.tar.gz.
File metadata
- Download URL: firebase_service-0.1.0.tar.gz
- Upload date:
- Size: 40.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7da5ba7e40e66c1a7ee056dec30db4964e62c2da218476edb1dc67c6a4d7e97b
|
|
| MD5 |
35ada183df01cce3a6555cce2c49eaeb
|
|
| BLAKE2b-256 |
a098dcbb14fe40c2ca6c487d74c06710b021b08229c4ee737feefefb4bf413ff
|
File details
Details for the file firebase_service-0.1.0-py3-none-any.whl.
File metadata
- Download URL: firebase_service-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ae66281b21ec5d2655a6c40f6ab0ff9f083f2dc4318dec4d66204f92d84351b
|
|
| MD5 |
dc37d65c79f0265f8cc2e579cf5fd2a3
|
|
| BLAKE2b-256 |
6c1292becab5fb52b75846077b16b374211e9c8bb2155870252835ea86a73ba2
|