A simple Python script to fetch documents from a Firebase Firestore collection and save them to a local .json
file. Helpful when your project is on the free tier and you don't want to enable billing on your account.
- Python 3.6+
- Firebase project with Firestore enabled
-
Clone the repository:
git clone https://github.com/bijx/Firestore-Data-Fetcher.git
-
Navigate to the project directory:
cd Firestore-Data-Fetcher
-
Install the required packages:
pip install firebase-admin
-
Obtain your Firebase service account key:
- Go to the Firebase Console.
- Navigate to your project.
- Click on "Project settings".
- Click on the "Service accounts" tab.
- Generate a new private key.
- Save the
.json
file with your credentials to the project directory.
-
Open the script and replace
'collection_name'
with the name of the Firestore collection you want to fetch. -
Run the script:
python script.py
-
The data will be saved in a file named
output.json
.
- Just a word of caution: Always keep your Firebase service account key secure and never expose it in public locations.