# Services : Firebase : Emulator Suite ## Setup #### Install & Configure ```bash $ firebase init emulators downloading firebase-database-emulator-v4.11.2.jar... downloading cloud-firestore-emulator-v1.19.7.jar... downloading ui-v1.12.1.zip... writing configuration info to firebase.json... writing project information to .firebaserc... writing gitignore file to .gitignore... ``` [Java JDK >= 11](https://jdk.java.net/) required to run Database or Firestore emulators: ```bash $ tar xzvf openjdk-22.0.2_linux-x64_bin.tar.gz $ echo "export PATH=\"\$PATH:$PWD/bin\"" >> ~/.bashrc ``` You can edit the ports in `firebase.json`, and the project ID in `.firebaserc`. See [[Tech/Services/Firebase/Files|Files]]. #### Projects & Data The data in the Emulator Suite is keyed to the project, so if you don't specify a project when connecting (via credential or option), it will choose a default project ID for you and all data will get associated with it. Later, if you set the project ID, you'll find the services empty of data again. #### Run ```bash $ firebase emulators:start [--import=DIR] [--export-on-exit=DIR] [--project=PROJECT] ``` To export data to a directory when shutting down, or import data from a directory when starting up, use the `--import` and `--export-on-exit` options. #### Python SDK To point the Python SDK at the emulators: ``` FIREBASE_AUTH_EMULATOR_HOST = "localhost:9099" FIREBASE_DATABASE_EMULATOR_HOST = "localhost:9000" FIRESTORE_EMULATOR_HOST = "localhost:8080" ``` You can either provide a real Firebase certificate as usual, or just set the project ID: ```python from firebase_admin import initialize_app initialize_app( options=dict( projectId="..." ) ) ``` ## Cookbook Clear your Firebase Auth data between tests. ```http DELETE http://localhost:9102/emulator/v1/projects/PROJECT_ID/accounts ``` Clear your Firestore database between tests. ```http DELETE http://localhost:9104/emulator/v1/projects/PROJECT_ID/databases/(default)/documents ```