EndpointOS

Connect Firestore

Serve documents from a Firestore collection through an authenticated, logged API.

Back to docs · Beta

When to use it

A document collection you want readable and writable over a stable HTTP contract, with filtering and paging applied by Firestore itself rather than after the fact.

What to grant

roles/datastore.user on the project, scoped to the database where possible.

Setup

1. Create a service account and grant it access

In the Google Cloud console, create a service account and grant it roles/datastore.user.

gcloud projects add-iam-policy-binding YOUR_PROJECT \
  --member=serviceAccount:endpointos@YOUR_PROJECT.iam.gserviceaccount.com \
  --role=roles/datastore.user

2. Download the key file

Create a JSON key and download it. You paste the whole file, and it is encrypted at rest.

gcloud iam service-accounts keys create key.json \
  --iam-account=endpointos@YOUR_PROJECT.iam.gserviceaccount.com

3. Connect it in EndpointOS

Create a resource, choose Firestore, and enter the project id, the collection, and the key file. Leave the database id blank unless you use a non-default database.

What you will be asked for

What the API supports for this source

Generated from the same declaration the API enforces on every request, so it cannot promise something a request would be rejected for.

Filteringequals, not equal, one of, greater than, greater or equal, less than, less or equal on any declared field
SortingAny field you declare. Not createdAt or updatedAt, which this source does not maintain
Search (q)Not supported
Writescreate, update, delete
Paginglimit and offset
Record countApproximate: the total reflects the page

Worth knowing first

If something goes wrong

FAILED_PRECONDITION, with a request for an index

Why: Firestore needs a composite index for this combination of filters and ordering, and does not create one automatically.

Fix: Follow the console link in the error, which creates the index it wants. The request works once the index finishes building.

A filter returns nothing when you can see matching documents

Why: Firestore compares by type as well as value, so a number filter will not match a field stored as a string.

Fix: Declare the field with the type Firestore actually stores, then filter again.

Sorting returns fewer documents than not sorting

Why: Firestore leaves out any document that does not have the field being sorted by. This is Firestore behaviour, not a filter being applied.

Fix: Sort by a field every document has, or backfill the field on the documents missing it.

Cannot be sorted by createdAt

Why: Firestore does not maintain createdAt or updatedAt, so there is no such field to order by.

Fix: Sort by one of your own fields, or write your own timestamp into each document and sort by that.

Permission denied

Why: The service account lacks roles/datastore.user, or is scoped to a different database.

Fix: Grant roles/datastore.user, and set the database id if you are not using the default database.

Connect Firestore · EndpointOS | EndpointOS