Skip to content

jdp/pyrebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pyrebase

https://travis-ci.org/jdp/pyrebase.png?branch=master

Pyrebase is a Firebase client library for Python.

Getting Started

Connecting to a Firebase location and adding data to it is easy. Here's how:

>>> import pyrebase
>>> f = pyrebase.Firebase('https://pyrebase.firebaseIO.com/')
>>> c = f.push({'foo': 'bar'})
>>> c.ref
u'https://pyrebase.firebaseIO.com/-JHFR_y14CzSOm8q86G1/'
>>> c.get()
{u'foo': u'bar'}

Traversing locations is simple with the parent, child, and root methods:

>>> f = pyrebase.Firebase('https://pyrebase.firebaseIO.com/pokemon/bulbasaur')
>>> f.root.ref
'https://pyrebase.firebaseIO.com/'
>>> f.parent.ref
'https://pyrebase.firebaseIO.com/pokemon/'
>>> f.parent.parent.ref
'https://pyrebase.firebaseIO.com/'
>>> f.parent.child('squirtle').ref
'https://pyrebase.firebaseIO.com/pokemon/squirtle/'

Remember to use the official firebase-token-generator package for authentication:

>>> from firebase_token_generator import create_token
>>> custom_data = {'pokemon_master': True}
>>> options = {'admin': True}
>>> token = create_token('not-a-fake-firebase-secret', custom_data, options)
>>> f = pyrebase.Firebase('https://pyrebase.firebaseIO.com/', auth=token)

Tests

Pyrebase is tested with pytest. To run the tests, use this command:

$ make test

License

Copyright 2014 Justin Poliey

ISC License

About

Firebase API client for Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages