Rules to Read/Write/Validate data
{
"rules": {
".read": false,
".write": false,
"public": {
".read": true,
".write": true
}
}
}
{
"rules": {
"messages": {
"$message": {
// only messages from the last ten minutes can be read
".read": "data.child('timestamp').val() > (now - 600000)",
// new messages must have a string content and a number timestamp
".validate":
"newData.hasChildren(['content', 'timestamp']) && "
"newData.child('content').isString() && "
"newData.child('timestamp').isNumber()"
}
}
}
}
python-firebase
Pyrebase
python-firebase
python-firebase
requests
python-firebase
from firebase.firebase import FirebaseApplication
from firebase.firebase import FirebaseAuthentication
auth = FirebaseAuthentication(TOKEN, EMAIL, True, True)
ref = FirebaseApplication(URL, auth)
python-firebase
# Get value
ref.get(path, key)
# Push new value to the list
ref.post(path, value)
# Set value
ref.put(path, key, value)
# Update value
ref.patch(path, key, value)
# Delete value
ref.delete(path, key)
Pyrebase
Pyrebase
requests
, but on Python 3.4Pyrebase
from pyrebase import Firebase
ref = Firebase(URL, TOKEN)
Pyrebase
# Get value
ref.child(path).get().val()
# Add new key to the list (POST)
ref.child(path).push(value)
# Set value
ref.child(path).set(value)
# Update value
ref.child(path).update(value)
# Delete value
ref.child(path).remove()
Pyrebase
def stream_handler(posts):
for post in posts:
...
stream = ref.child(path).stream(stream_handler)
...
stream.close()