Firebase Python

Posted : admin On 1/25/2022

Note: Every Firebase project is also a Google Cloud project. Visit Understand Firebase Projects to learn more about the Firebase and Google Cloud project relationship. Enable the API and install the SDK. Enable the Cloud Run API in the Google APIs console: Open the Cloud Run API page in the Google APIs console. When prompted, select your. Apr 20, 2021 Note: Every Firebase project is also a Google Cloud project. Visit Understand Firebase Projects to learn more about the Firebase and Google Cloud project relationship. Enable the API and install the SDK. Enable the Cloud Run API in the Google APIs console: Open the Cloud Run API page in the Google APIs console. When prompted, select your. Python-firebase has been unmaintained for years and is no longer supported. Please consider using another library instead. The following are 30 code examples for showing how to use firebaseadmin.initializeapp.These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

In this article, we will learn how we can connect a firebase database with a Python script. This article is the first part of the tutorial series of Setting up Firebase with Python. Firebase is a NoSQL based database designed by google which is capable of providing realtime updates to android devices connected to it. We will require the following python packages:

  • firebase-admin

Firebase is a backend platform for building Web, Android and IOS applications. It offers real time database, different APIs, multiple authentication types and hosting platform. This is an introductory tutorial, which covers the basics of the Firebase platform and explains how to deal with its various components and sub-components.

In addition to installing the firebase-admin SDK for python using the above package, we also need to create a new Firebase database.

Next tutorial: Reading data from Firebase database using Python and How to store and Delete data to Firebase database using Python.

Creating a Firebase database for our Python program

The first thing we need to do is to sign up for a google cloud account. You can do this using an existing Google account. Then navigate to the homepage of the Google Cloud Console. It looks as follows:

Next, create a new Google Cloud Project:

To do this select the drop-down menu beside the Smart Card System in the above image. You will be shown with a box as shown below, click NEW PROJECT. A new window asking the project name will pop up. Let’s say our project name is ‘My Third Project‘ as shown below:

Once this is done create a new Firebase database as shown below:

Then select database mode. We will choose the native mode for our project.

Select a database location:

After performing the above steps our database will be created:

Once, we reach the above window, we are ready to start with the next section of the article where we link our database with a python script.

Use Firebase with Python

  • We navigate to
  • Click on ADD PROJECT and select the GCP (Google Cloud Platform) project we just created. In our case, it would be ‘My Third Project‘.
  • Open ‘My Third Project’ and choose the ‘GEAR‘ icon beside ‘project overview’ and go to ‘project settings’.

Firebase Python Get Data

  • Then go to the ‘service accounts’ tab, select python and then click on the ‘Generate new private key button‘.
  • NOTE: THIS STEP IS GOING TO GENERATE A PRIVATE KEY, USED TO ACCESS YOUR DATABASE. YOU HAVE TO KEEP THIS KEY CONFIDENTIAL AT ALL TIMES, BECAUSE ANYONE HAVING THIS PRIVATE KEY WILL BE ABLE TO MODIFY YOUR DATABASE. Click on ‘Generate key‘. This step will download a JSON file containing your private key. For security reasons, never add this file to any version control system.

Once, the above steps are done, and the above-given code executes without any errors, then you have successfully connected your python script to the Firebase DB. We will look at how we can read and write to the database in another article – Reading data from Firebase database using Python script

Leave a Reply

Latest version


Python interface to the Firebase's REST API.

Project description

Python interface to the Firebase’s REST API


python-firebase highly makes use of the requests library so before you begin, you need to have that package installed.

Getting Started

You can fetch any of your data in JSON format by appending ‘.json’ to the end of the URL in which your data resides and, then send an HTTPS request through your browser. Like all other REST specific APIs, Firebase offers a client to update(PATCH, PUT), create(POST), or remove(DELETE) his stored data along with just to fetch it.

The library provides all the correspoding methods for those actions in both synchoronous and asynchronous manner. You can just start an asynchronous GET request with your callback function, and the method

To fetch all the users in your storage simply do the following:

The second argument of get method is the name of the snapshot. Thus, if you leave it NULL, you get the data in the URL /users.json. Besides, if you set it to 1, you get the data in the url /users/1.json. In other words, you get the user whose ID equals to 1.

You can also provide extra query parameters that will be appended to the url or extra key-value pairs sent in the HTTP header.

Creating new data requires a POST or PUT request. Assuming you don’t append print=silent to the url, if you use POST the returning value becomes the name of the snapshot, if PUT you get the data you just sent. If print=silent is provided, you get just NULL because the backend never sends an output.

Deleting data is relatively easy compared to other actions. You just set the url and that’s all. Backend sends no output as a result of a delete operation.


Authentication in Firebase is nothing but to simply creating a token that conforms to the JWT standarts and, putting it into the querystring with the name auth. The library creates that token for you so you never end up struggling with constructing a valid token on your own. If the data has been protected against write/read operations with some security rules, the backend sends an appropriate error message back to the client with the status code 403 Forbidden.


Firebase Python Auth

The interface heavily depends on the standart multiprocessing library when concurrency comes in. While creating an asynchronous call, an on-demand process pool is created and, the async method is executed by one of the idle process inside the pool. The pool remains alive until the main process dies. So every time you trigger an async call, you always use the same pool. When the method returns, the pool process ships the returning value back to the main process within the callback function provided.


  • Async calls must deliver exceptions raised back to the main process.
  • More regression/stress tests on asynchronous calls.
  • Docs must be generated.

Release historyRelease notifications RSS feed

Firebase Python Sdk

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-firebase, version 1.2
Filename, sizeFile typePython versionUpload dateHashes
Filename, size python-firebase-1.2.tar.gz (10.0 kB) File type Source Python version None Upload dateHashes

Firebase Python Github

Hashes for python-firebase-1.2.tar.gz

Firebase Python Client

Hashes for python-firebase-1.2.tar.gz
AlgorithmHash digest