Are there any good examples of tutorials of the Firestore REST API RunQuery endpoint? - google-cloud-firestore

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

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

Related

qliksense rest api connection to get data out of qliksense

I want to get list of documents available in Qlik sense using rest api. I am trying to use the api url https://url/api/v1/apps/docs to get the list of documents
But this is not working. Is the url correct in getting the documents in qliksense?
Where can I find the details on the url for getting the docs? I have checked the Qlik website for rest documentation but could not get the details what I am looking for.
Thanks
Not sure what your use case is but will recommend using Qlik Repository Service API to get list of the apps. The url in your question looks like an Engine REST API endpoints but its non-existing in the endpoints list.
Repositository API is a wrapper around the internal PostgreSQL database, which contains all the metadata (list of apps, streams, extensions etc).
List with all Repository API methods can be found at Qlik QRS API reference page.
The Repository API supports few authentication methods
certificates (when using in server-to-server communication. aka backend)
JWT
Header
Session cookie (from the browser)
Have a look at the examples how to test the responses with Postman (few other examples are available there - Powershell, Node.JS, cURL etc.)

Custom Rest API And Firestore Database

I have been following a tutorial showing how to build a custom Rest API in Javascript which is then deployed to Firebase Functions which can then be used to communicate with a Firestore Database.
Everything appears to be working fine but one thing is bothering me.
One of my end points is url-to-api/read which fetches all the records in the database.
How can I prevent anyone from simply adding that url into a browser and reading all the data.
I have tried various Firestore rules but none seem to make any difference, adding /read on to the end of the API URL still shows all the data in the browser.
Cloud Functions access Firebase using the Admin SDK, which means they bypass the security rules and have unrestricted access to the database.
It is up to you to protect what users can do in this case. For example, you can require that they pass their ID token along, and use that to determine their authorization as shown in these examples of implementing an authorized HTTP endpoint and implementing an authorized JSON API.

how to import JSON data from rest API to google firebase?

I am planning to use Firebase as my backend service for the mobile application. As part of the functionality, I need to get the data from external rest API which returns JSON data. I need to update the data periodically so that I can have updated information.
I have an option to call the rest API and update firebase on the mobile application however it is not the right approach. I prefer to keep this logic on the backend service.
Is there a way to use Firebase cloud function to periodically update firebase database from external Rest API?
#Ioki, I assume what you are trying to do is make a mobile app which gets updated data every time a user goes to the app but you want this to be on the backend. I haven't tried it but you might want to use Node js with their Firebase Admin SDK.
See the link: https://firebase.google.com/docs/admin/setup
Although I think it might make more sense to use the real-time database via the iOS/ Android SDK because automatic/ value event updates are basically the purpose of the real- time database. Good luck! :)

Graphql architecture

In the new year, I want to learn how to use GraphQL. Why not using this technology for personal project or at work. So, for now I will use it with MongoDB at backend and VueJS 2.0 at frontend.
I have a question about how to send query and mutations. Do I need to send directly query like :
query {
posts {
_id
title
content
}
}
and mutations from client-side (write it at client side) and send it to server endpoint ? (it is secure ?) .
else I was thinking about writing all my queries at backend and simply request post request with action param like QUERY_POST and at backend I find my query for QUERY_POST and play GraphQL query and send it at vue-side.
What did you think, what is the best way ? I'm a little lost about it. Storing queries and mutations at client side or at server-side ?
Thanks!
Your question is a bit confusing... the whole point of GraphQL is the capability to request everything you need (and nothing more) in 1 query. A mutation is a specific type of query which will modify data on your back-end. GraphQL queries are to be issued by the client.
After this is your responsibility on server-side to implement authentication and access control so that your data is not exposed to the world.
If you are new to GraphQL, I recommend you to have a look at this excellent tutorial: https://learngraphql.com/basics/querying-graphql
You may be interested in https://www.graph.cool/ too.
Hope this helps :-)
Often you will send the query in the request body using something like Apollo Client, Relay, or some other networking library. Here is an example you could run from your vue app.
Here is a full tutorial & starter kit that can help you get started :)
https://github.com/kristianmandrup/vue2-apollo-scaphold

Google Play Game Services REST api Snapshot load/commit

Anyone know if it is possible to load/commit snapshot through the Google Play Game Services REST api?
Im using this documentation: https://developers.google.com/games/services/web/api/snapshots
But it only seems to allow fetching Snapshots metadata.
Thanks.
One of the fields of the metadata is driveId. This is the id to pass to the Drive API to read the data. See https://developers.google.com/drive/v2/reference/files/get for the API information for get.