Pyrebase in Firebase

Pyrebase in Firebase

Cloud Maestro
·May 3, 2021·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article


Pyrebase is a simple wrapper for the Firebase API which was written only for Python 3.(Does not Support Py 2)


  • Have an Linux Environment(My Choice)
  • Have a Google Account
  • Create a Firebase Project in Firebase Console
  • Go To Project Settings and Create a Web App and get the Configurations
config = {
  "apiKey": "apiKey",
  "authDomain": "",
  "databaseURL": "",
  "storageBucket": ""
  • On Your Local Computer,

    • Make Sure To Create an Virtual Environment to avoid conflicts (Believe Me From Experience : There is a Conflict)

      python3 -m venv env

    • Activate the Virtual Environment

      source env/bin/activate

    • Install the pyrebase

      pip3 install pyrebase

    • and Pyrebase supports Authentication, Database and Storage Services

      Authentication -> firebase.auth()

      Database -> firebase.database()

      Storage ->

  • Finally Open Your Code Editor, Let's Code...!

Firebase Initialization:

After Installation of Pyrebase, Initialize your app

import pyrebase

config = {
  "apiKey": "YourApiKey",
  "authDomain": "",
  "databaseURL": "",
  "storageBucket": ""

firebase = pyrebase.initialize_app(config)

Firebase Authentication:

Firebase provides authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more and it improves industry standards by integrating OAuth 2.0 and OpenID Connect with the custom backend.

-> Create an Authentication

auth = firebase.auth() # Creates Authentication

-> Input From User

user = input("Enter a User")  # Input Username
password = input("Enter a Password") # Input Password

-> Authenticate the User

signin = auth.sign_in_with_email_and_password(email, password)
print("Sign In Was Successfull")

-> You can also verify the email using code

print("Email Verification Sent")

->Send Password Reset Emails

print("Email Sent...Check Your Inbox")

Firebase Real Time Database

The Firebase Realtime Databaseis stored as JSON and synchronized in realtime to every connected client.

-> Intialize Database

db = firebase.database()
# data
data = {
  "cloud" : "maestro"

->Sending Data to the Database


->Update Data in the Database

data2 = {
  "cloud_maestro" : "saranmahadev"

-> Get the Data from the database

users = db.child("users").get() print(users.val()) # Prints the Values of the JSON Object print(users.key()) #Prints the Keys of the JSON Object

-> To delete the data in the database


Firebase Storage

Cloud Storage for Firebase is a powerful, simple, and cost-effective object storage service built for Google scale.

-> Creating the Object

storage =

-> Building Paths To Your Data


-> Uploading Images to the Storage


-> Downloading Images from the Storage


Reference : Codeloop

Share this