2
votes

I want to open a connection with Firestore REST API and push or receive events on data changes.

This can be done using the EventSource / Server-Sent Events protocol.

I found the documentation for Firebase Realtime database REST API here https://firebase.google.com/docs/database/rest/retrieve-data#section-rest-streaming and here https://firebase.google.com/docs/reference/rest/database

But I could'nt find the documentation for Firestore REST API and if it is even possible to stream from it.

I tried sending get request with postman and adding the Accept header to text/event-stream but it just returns a normal response and when I change the data in my firestore database postman doesn't receive anything. This is the format of the URL I'm requesting: https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents/MY_DOCUMENT?key=MY_KEY postman

Note: I'm already able to communicate with the rest api, my question is about the streaming capability of the api using EventSource / Server-Sent Events protocol, like this one for firebase realtime databse firebase.googleblog.com/2014/03/… but I want to know if it is available for firestore

1

1 Answers

3
votes

Unfortunately the Firestore REST API does not have the same Streaming capabilities as the Realtime Database has for it's REST API, therefore it's only possible to make streaming of data using the Cloud SDK or using the RPC API's listen method, more details on this documentation.

NOTE: The problem with RPC API in this case is that you'll need to take a dependency on gRPC to implement it if that's really what you want and there aren't many environments that have a gRPC implementation that don't have a Firestore SDK, so its very likely that this will also not be of help for what you want to achieve.