0
votes

Is it possible to use requests library to querying data from cloud firestore? For example this is how database look like:database:

I tried to get data(get all documents where "add_date" is equal to "01.08.2020" and limit these to 3):

result = requests.get('https://firestore.googleapis.com/v1/projects/**************************maindata/.json?orderBy="add_date"&EqualTo="01.01.2020"&limitToLast=3')

but I am getting error:

{'error': {'code': 400, 'message': 'Invalid JSON payload received. Unknown name "limitToLast": Cannot bind query parameter. Field 'limitToLast' could not be found in request message.\nInvalid JSON payload received. Unknown name "EqualTo": Cannot bind query parameter. Field 'EqualTo' could not be found in request message.', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'description': 'Invalid JSON payload received. Unknown name "limitToLast": Cannot bind query parameter. Field 'limitToLast' could not be found in request message.'}, {'description': 'Invalid JSON payload received. Unknown name "EqualTo": Cannot bind query parameter. Field 'EqualTo' could not be found in request message.'}]}]}}

For realtime database that was okay.

I know that the problem is much more complicated but I don't know where to start to solve it.

Many thanks.

1
Yes, it's possible. Firestore has a REST API. It's different than Realtime Database. Without seeing the details of what you sent, it's not possible for us to see where you went wrong. - Doug Stevenson
I edited my post to show my problem better. - Trevor Philips
You can't use the Realtime Database API to query Firestore. They have completely different APIs. - Doug Stevenson

1 Answers

0
votes

Realtime Database and Firestore are two different products, although both are available in Firebase. Ex. Firestore is available also on Google Cloud Console, while Realtime Database is not. Please take a look at this article for more details.

So if they are completely different products, it's hard to imagine that they will work on the same API's.

I suppose that you have created example request with this Realtime Database API. This of course will not work with Firestore. There is an equivalent API for Firestore which is much more complicated. This is not very surprising as Firestore is designed for more advance use.

So if you asking for starting point I suggest to get familiar with the API and try to play with it. I hope it will help! Good luck!