firebase.database package
A simple python wrapper for Google’s Firebase Database REST API
- class firebase.database.Database(credentials, database_url, requests)[source]
Bases:
object
Firebase Database Service
- Parameters
credentials (
Credentials
) – Service Account Credentials.database_url (str) –
databaseURL
from Firebase configuration.requests (
Session
) – Session to make HTTP requests.
- conditional_remove(etag, token=None)[source]
Conditionally delete data from database.
- conditional_set(data, etag, token=None, json_kwargs={})[source]
Conditionally add data to database.
- Parameters
data (dict) – Data to be stored in database.
etag (str) – Unique identifier for specific data at a specified location.
token (str) – (Optional) Firebase Auth User ID Token, defaults to
None
.json_kwargs (dict) – (Optional) Keyword arguments to send to
json.dumps()
methods for serialization of data, defaults to{}
(emptydict
object).
- Returns
Successful attempt returns the data specified to store, failed attempt (due to ETag mismatch) returns the current
ETag
for the specified path.- Return type
- generate_key()[source]
Generate Firebase’s push IDs.
For more details:- Returns
Firebase’s push IDs
- Return type
- order_by_key()[source]
Filter data by their keys.
- Returns
A reference to the instance object.
- Return type
- order_by_value()[source]
Filter data by the value of their child keys.
- Returns
A reference to the instance object.
- Return type
- push(data, token=None, json_kwargs={})[source]
Add data to database.
This method adds a Firebase Push ID at the end of the specified path, and then adds/stores the data in database, unlike
set()
which does not use a Firebase Push ID.For more details:- Parameters
- Returns
Child key (Firebase Push ID) name of the data.
- Return type
- set(data, token=None, json_kwargs={})[source]
Add data to database.
This method writes the data in database in the specified path, unlike
push()
which creates a Firebase Push ID then writes the data to database.For more details:- Parameters
- Returns
Successful attempt returns the
data
specified to add to database.- Return type
- shallow()[source]
Limit the depth of the response.
For more details:- Returns
A reference to the instance object.
- Return type
- sort(origin, by_key, reverse=False)[source]
Further sort data based on a child key value.
- Parameters
- Returns
Sorted version of the data.
- Return type