questiondude
questiondude

Reputation: 822

Python firebase_admin vs. google.cloud packages

I am trying to get Firestore working and I am wondering which Python package I should use. It appears that there is some overlap between the functionality of the firebase_admin.firestore and google.cloud.firestore, as well as between firebase_admin.credentials and google.auth.credentials. But it also seems like there is some incompatibility between them, or at least they can't be used together.

What is the difference between these Python packages, and which is it recommended that a beginner should use?

Thanks!

Upvotes: 2

Views: 1027

Answers (2)

Gourav B
Gourav B

Reputation: 972

Here’s a simple answer for beginners, as requested:

Google provides Firebase and Google Cloud Platform as two different suites of products. Some Google products are shared across these, Cloud Firestore being one of them.

So, if one is using Cloud Firestore from within a Firebase project, it is recommended to use firebase_admin.firestore and firebase_admin.credentials packages and other Firebase APIs as required.

If on the other hand, one is using the Google Cloud Platform project, it is recommended to use google.cloud.firestore, and google.auth.credentials packages and other GCP Cloud APIs as required.

HTH, reach out for any additional questions/queries.

Upvotes: 3

Roopa M
Roopa M

Reputation: 3009

If you plan to use other Firebase functionality (e.g. eventually have mobile users that authenticate with Firebase, and connect to their Firestore instance from their phones or web pages), then firebase_admin is the best choice.

Otherwise, if you plan on using Firestore without Firebase, then google.cloud.firestore would be more straight-forward.

The same applies to the credentials libraries.

And the main differences are between the Cloud services:

Cloud Firestore supports SDKs for Android, IOS, and Web. Combined with Cloud Firestore security rules and Firebase Auth, the mobile and web SDKs support serverless app architectures where clients connect directly to your Cloud Firestore database. With a serverless architecture, you do not need to maintain an intermediary server between your clients and your Cloud Firestore database.

The Firebase Admin SDKs bundle the Google Cloud client libraries for Cloud Firestore alongside client libraries and SDKs for several other Firebase features. And it is for accessing your Firebase products on a backend server you control, which could be Cloud Functions, or even your desktop. It will typically have full access to everything, as determined by the service account you used to initialize it.

Upvotes: 0

Related Questions