Matt Matt - 3 months ago 52
reST (reStructuredText) Question

Get multiple child nodes in Firebase with REST API

I have following database hierarchy in my Firebase application.

enter image description here

I know about query parameters in REST API, but how can I get group1 and group2 by single http request?

Answer

The only way to get multiple nodes in a REST request is by having a query that matches the nodes you are looking for. Since Firebase Database queries don't have a WHERE key IN (a,b,c) type operation, the query will have to match some property value/range.

In your specific example you could order by key and limit to the first 2 results:

.../groups.json?orderBy="$key"&limitToFirst=2

But in general if you want to retrieve a set of N children through the Firebase API, it will require N calls.