Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any good examples of tutorials of the Firestore REST API RunQuery endpoint?

I've successfully gotten my Vapor app to read and write collections and documents from Firestore, but I now have a use case where a query is required. I've followed the documentation for Firestore Queries and am using them in my iOS client successfully, which utilizes the iOS Firestore library not the REST API, but on the server I've haven't been unable to figure out how to execute the same query. The Firestore documentation seems incomplete in this area.

This API endpoint tool from Google does allow me to submit queries but there appears to be very little documentation on how to format the fields in the request body for the RunQuery endpoint.

https://developers.google.com/apis-explorer/#search/firestore/firestore/v1/firestore.projects.databases.documents.runQuery

Does anyone have experience to share on how to format the request body to create a well formed query to Firestore with the REST API?

FWIW, this Medium post was awesome for getting started with the REST API but stops just short of the richer Firestore requests. https://medium.com/rocket-fuel/getting-started-with-firebase-for-server-side-swift-93c11098702a

like image 247
Scott Avatar asked Nov 06 '22 16:11

Scott


1 Answers

I've found a good example at https://www.jeansnyman.com/firebase/google-firestore-rest-api-examples/#get-selected-fields-in-a-document-that-meets-specific-requirements-limit-it-to-4-results-and-order-by-created-date

You may also use Chrome Devtools (or similar) to view the REST API runQuery request if you use the interactive query tool in the Firestore UI. The request in the Devtools network tab will start out with documents:runQuery

like image 116
Jim Raden Avatar answered Nov 11 '22 14:11

Jim Raden