While the easiest way to use Cloud Firestore is to use one of the native client libraries, there are some situations when it is useful to call the REST API directly.
The REST API can be helpful for the following use cases:
- Accessing Cloud Firestore from a resource-constrained environment, such as an internet of things (IoT) device, where running a complete client library is not possible.
- Automating database administration or retrieving detailed database metadata.
You can generate an
access_token for the Cloud Firestore REST API by using a
service account with a Google API Client Library
or by manually following the steps in Using OAuth 2.0 for Server to Server Applications.
This token must have the following scope, which will grant it full read/write access to Cloud Firestore:
After you obtain this token, pass it to the Cloud Firestore endpoints
Authorization header set to
Making REST calls
All REST API endpoints exist under the base URL
To create a path to a document with the ID
LA in the collection
under the project
YOUR_PROJECT_ID you would use the following structure.
To interact with this path, combine it with the base API URL.
The best way to begin experimenting with the REST API is to use the API Explorer, which will automatically generate tokens and allow you to easily examine the API.
Perform actions on indexes such as creating new indexes, disabling an existing index, or listing all current indexes. Useful for automating data structure migrations or synchronizing indexes between projects.
Also enables retrieval of document metadata, such as the list of all fields and subcollections for a given document.