Extracting all User’s Data from Firebase with Python

Vishal Roy
2 min readDec 14, 2019

--

I was recently working on a project in which I needed to extract all my user’s data stored in Firebase’s Firestore database, to send them an important email regarding some user policy changes.

What I wanted to do is to extract all the data & save it in a CSV file. After which I can easily send emails via SendInBlue’s email campaign. So here’s what I did.

Getting Started

As usual, just head over to your firebase console.

Step 1:

Open the Firebase project from which you want to extract the user’s data. Once loaded, click on the gear icon appearing near the top-left area and select the “Project settings” option.

Firebase Dummy Project

Step 2:

Now head over to the “Service accounts” section and scroll all the way down and click on the “Generate new private key” 🔑 button to generate & download a new JSON key file.

  • This JSON file contains all the information that anyone would need to get access to your Firebase project. So always keep it safe. In case you lose it, repeat step 2 to be safe :)
Service accounts section Screenshot

Step 3:

Lets fire up the terminal and install the Firebase Admin SDK in Python.

pip install --upgrade firebase-admin

Step 4:

Once the Firebase Admin SDK is ready to be used, download the “users_to_csv.py” and run it with Python 🐍

python path/to/users_to_csv.py
users_to_csv.py
Success message on termi

Hurray 🎉!!! Now you have all your users data into one well-formatted CSV file.

Thanks for reading through this article! If you enjoyed it, please click the 👏 button & feel free to leave your response below.

--

--