# Searching in Firebase RealtimeDB via WebAPI

**URL:** <https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301>\
**Category:** Questions about Thunkable X\
**Created:** [April 13, 2020, 11:36am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301 "2020-04-13T11:36:27Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![billyljren](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/billyljren/32/65122_2.png) [@billyljren](https://community.thunkable.com/u/billyljren)\
**Post date:** [April 13, 2020, 11:36am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/1 "2020-04-13T11:36:27Z")

</div>

**ORIGINAL QUESTION**  
The RealtimeDB Component is a great way to store and retrieve data, but the question is if there’s a list of 100k entries (e.g. Movie Titles), how do you perform a search (Movie Title, Year, etc) and pagination ?

UPDATE: I realize that Web API could be used to perform the queries, but it doesn’t seem to do very well with alphabets filtering. See the following example:

A list of movies  
{  
{  
“name” : “Rambo”  
},  
{  
“name” : “Zombies”  
},  
{  
“name” : “Madagascar”  
},  
{  
“name” : “monster inc”  
},  
}

Upon querying with startAt=“M”, only “Madagascar” is displayed, “monster inc” also starts with “m” but it does not show up. Anyone with an idea to solve this issue?

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 13, 2020, 4:59pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/2 "2020-04-13T16:59:12Z")

</div>

Hey @billyljren, welcome to the community and thanks for posting the question! 👋

what are the blocks you are using to call your database?

can you show a screenshot sample of the data tree?

If you want to do use advanced features, you may need to use the API. [here are the docs to do what you are talking about. it even talks about how to order the results of the response](https://firebase.google.com/docs/database/rest/retrieve-data)

---

<div class="post-metadata">

**Author:** ![Townsend](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/townsend/32/67551_2.png) [@Townsend](https://community.thunkable.com/u/Townsend)\
**Post date:** [April 14, 2020, 1:40am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/3 "2020-04-14T01:40:57Z")

</div>

@jared I’ve been curious about this too. I see the specifics on Filtering data in the link you provided. (Now bookmarked.) But I’m new to Thunkable and Firebase’s NoSQL structure.

I’m no where near ready to begin coding these Filtering queries, but for now my question is a matter of theory. Does this Filtering facility allow for efficient (quick) retrieval of a single data-point from a list of 1000’s or even 100,000’s?

I know relational databases do this with keys, but… is this something that is just not possible with NoSQL db’s like Firebase? I suspect your answer will be something like, “it is possible if the data is structured correctly.” And If so, a few general pointers would be very helpful to this newbie.

This will make a big difference in my decision on what to build with Thunkable.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 14, 2020, 1:55am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/4 "2020-04-14T01:55:21Z")

</div>

You know, From the look of the docs, if you know the key, you can filter quickly. You can also return a filtered range of data, like all movies that start with the letter D for example. The bright side is you can easily construct these queries

Airtable does this easily but you my be limited by the Number of rows.

---

<div class="post-metadata">

**Author:** ![billyljren](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/billyljren/32/65122_2.png) [@billyljren](https://community.thunkable.com/u/billyljren)\
**Post date:** [April 14, 2020, 2:21am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/5 "2020-04-14T02:21:06Z")

</div>

Here’s the blocks I’ve used to query.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/3/0366aed387d0afed607146d23162cc6f031075da.png)

And here’s the results I got.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/2/a2cb2aca23af058f557ffd1e0f0ec81fe01edef6.png)

**UPDATE:** Ignore this part regarding T \< U, I’ve figured out it should be using T and T\uf8ff instead.  
It starts at “T” and ends at “U”, which brings out all entries beginning with T \< U but ignores t.

Maybe automatically converting to both Uppercase + Lowercase and performing the query twice is the only way ? One for T and one for t.

There’s also a question of what if users search anything in between ? e.g. searching for “matrix” would also match “The Matrix”. At this point, my understanding is that startAt and endAt doesn’t give that flexibility. Do shed some light.

@Townsend I found out that you’d have to achieve this using WebAPI instead of RealtimeDB component. Look at Firebase REST API docs. I’ve attached above on how my blocks look like. There’s also a limit results query parameter (limitToFirst) that can be added to restrict number of results returned, but its not straightforward like usual SQL that we are used to.

---

<div class="post-metadata">

**Author:** ![Daniel\_Coglitore](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@Daniel\_Coglitore](https://community.thunkable.com/u/Daniel_Coglitore)\
**Post date:** [April 14, 2020, 8:57am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/6 "2020-04-14T08:57:09Z")

</div>

I think this is why some recommend use “Argolia” because argolia ignores wheter is Mayus or Minus , or if user search the matrix or matrix, I think is a little complicated…

Maybe you can add an appart data call it maybe “Search” and you type the name of the movie only in minus and the user text you convert it in minus but this still the users have to write the exact same words

Since you are surfing throught Firebase API , take a look at Cloud firestore API, I Switched completly from database to Cloud firestore, using full WebAPI, is totally possible…

If you are interesting let me know and i’ll show you some examples codes here

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 14, 2020, 10:49am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/7 "2020-04-14T10:49:40Z")

</div>

@Daniel_Coglitore I am. What benefit do you find using Firestone instead of Firebase

---

<div class="post-metadata">

**Author:** ![billyljren](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/billyljren/32/65122_2.png) [@billyljren](https://community.thunkable.com/u/billyljren)\
**Post date:** [April 14, 2020, 1:08pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/8 "2020-04-14T13:08:41Z")

</div>

> [@Daniel\_Coglitore](#):
>
> Argolia

I’d be interested to explore that, could you share more information ?

---

<div class="post-metadata">

**Author:** ![Daniel\_Coglitore](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@Daniel\_Coglitore](https://community.thunkable.com/u/Daniel_Coglitore)\
**Post date:** [April 14, 2020, 2:22pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/9 "2020-04-14T14:22:03Z")

</div>

Sorry is “Algolia” is a full text search? visit their web page or maybe in youtube some examples!

oh sorry I think Algolia doesnt have API for HTTPS,

you still can try the example I give you

---

<div class="post-metadata">

**Author:** ![Daniel\_Coglitore](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@Daniel\_Coglitore](https://community.thunkable.com/u/Daniel_Coglitore)\
**Post date:** [April 14, 2020, 2:29pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/10 "2020-04-14T14:29:01Z")

</div>

Is because of the querying , for example if you want to search in your database all the “restaurants” of “Japanese” food , located in the country of “Canada” in the city “Toronto” with the rates of “5” starts you can totally do that

also you can easily create a “Like” or “Counter” system, the function “Transform” allows you to easily do maths function in the firestore database.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 14, 2020, 2:32pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/11 "2020-04-14T14:32:43Z")

</div>

that’s awesome! could you share an example by chance?

---

<div class="post-metadata">

**Author:** ![Daniel\_Coglitore](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@Daniel\_Coglitore](https://community.thunkable.com/u/Daniel_Coglitore)\
**Post date:** [April 14, 2020, 3:20pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/12 "2020-04-14T15:20:56Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/4/04144d70c710f57017cce85dce9da2aadb335de8.png)  
I’m going to get “upcomingMatches” from \> Category = Honor and Country = Chile

API Url : [https://firestore.googleapis.com/v1/projects/test-d03ac/databases/(default)/documents/Club/VBQMMKZlyqeYlhzmVa528LblHfC3:runQuery](https://firestore.googleapis.com/v1/projects/test-d03ac/databases/(default)/documents/Club/VBQMMKZlyqeYlhzmVa528LblHfC3:runQuery)

API Body :

{  
“structuredQuery”: {  
“from”: [  
{  
“collectionId”: “upcomingMatches”  
}  
],  
“where”: {  
“compositeFilter”: {  
“filters”: [  
{  
“fieldFilter”: {  
“field”: {  
“fieldPath”: “Filters.Category”  
},  
“op”: “EQUAL”,  
“value”: {  
“stringValue”: “Honor”  
}  
}  
},  
{  
“fieldFilter”: {  
“field”: {  
“fieldPath”: “Filters.Country”  
},  
“op”: “EQUAL”,  
“value”: {  
“stringValue”: “Chile”  
}  
}  
}  
],  
“op”: “AND”  
}  
}  
}  
}

This is the tool you’ll use for creating the body it will help you a lot

> **[Method: projects.databases.documents.runQuery  |  Firestore](https://cloud.google.com/firestore/docs/reference/rest/v1beta1/projects.databases.documents/runQuery)**

Parent(url in the google tool api): projects/test-d03ac/databases/(default)/documents/Club/VBQMMKZlyqeYlhzmVa528LblHfC3

Body

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/4/2470f7b425ff51c176d844992fd1dcd3a04c8c68.png)

Response :

[{  
“document”: {  
“name”: “projects/test-d03ac/databases/(default)/documents/Club/VBQMMKZlyqeYlhzmVa528LblHfC3/upcomingMatches/202003062300mi8fdXFvY2g52IDHVKS8H9m5yPr2”,  
“fields”: {  
“Player2”: {  
“mapValue”: {  
“fields”: {  
“ID”: {  
“stringValue”: “dakshgdas”  
},  
“FullName”: {  
“stringValue”: “- - - - -”  
},  
“Picture”: {  
“stringValue”: “- - - - -”  
}  
}  
}  
},  
“Player1”: {  
“mapValue”: {  
“fields”: {  
“ID”: {  
“stringValue”: “mi8fdXFvY2g52IDHVKS8H9m5yPr2”  
},  
“FullName”: {  
“stringValue”: “D. Coglitore”  
},  
“Picture”: {  
“stringValue”: “[http://res.cloudinary.com/dcfaahtoy/image/upload/v1583083064/2019/iehbhccimtt4rjbferkk.jpg](http://res.cloudinary.com/dcfaahtoy/image/upload/v1583083064/2019/iehbhccimtt4rjbferkk.jpg)”  
}  
}  
}  
},  
“Filters”: {  
“mapValue”: {  
“fields”: {  
“City”: {  
“stringValue”: “Concepcion”  
},  
“Category”: {  
“stringValue”: “Honor”  
},  
“Mode”: {  
“stringValue”: “Singles”  
},  
“Country”: {  
“stringValue”: “Chile”  
}  
}  
}  
},  
“Status”: {  
“mapValue”: {  
“fields”: {  
“Value”: {  
“stringValue”: “Finished”  
},  
“Reason”: {  
“stringValue”: “Game Finished without score given”  
}  
}  
}  
},  
“Player4”: {  
“mapValue”: {  
“fields”: {  
“Picture”: {  
“stringValue”: “- - - - -”  
},  
“ID”: {  
“stringValue”: “- - - - -”  
},  
“FullName”: {  
“stringValue”: “- - - - -”  
}  
}  
}  
},  
“MatchID”: {  
“stringValue”: “202003062300mi8fdXFvY2g52IDHVKS8H9m5yPr2”  
},  
“Date”: {  
“mapValue”: {  
“fields”: {  
“Complete”: {  
“stringValue”: “March 06, 2020”  
},  
“Format”: {  
“stringValue”: “2020-03-06”  
}  
}  
}  
},  
“Club”: {  
“mapValue”: {  
“fields”: {  
“ID”: {  
“stringValue”: “VBQMMKZlyqeYlhzmVa528LblHfC3”  
},  
“Picture”: {  
“stringValue”: “[https://res.cloudinary.com/dcfaahtoy/image/upload/v1578071094/2019/LogoClubDeTenisDeConcepcion.png](https://res.cloudinary.com/dcfaahtoy/image/upload/v1578071094/2019/LogoClubDeTenisDeConcepcion.png)”  
},  
“Name”: {  
“stringValue”: “Club de Tenis de Concepcion”  
}  
}  
}  
},  
“Time”: {  
“mapValue”: {  
“fields”: {  
“Complete”: {  
“stringValue”: “23:00”  
},  
“Format”: {  
“stringValue”: “23-00”  
}  
}  
}  
},  
“Score”: {  
“stringValue”: “NA”  
},  
“Player3”: {  
“mapValue”: {  
“fields”: {  
“Picture”: {  
“stringValue”: “- - - - -”  
},  
“ID”: {  
“stringValue”: “ASDasd”  
},  
“FullName”: {  
“stringValue”: “asdasd”  
}  
}  
}  
}  
},  
“createTime”: “2020-03-07T01:07:39.928846Z”,  
“updateTime”: “2020-03-09T21:07:06.521173Z”  
},  
“readTime”: “2020-04-14T15:04:58.711755Z”  
}  
,

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 14, 2020, 3:23pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/13 "2020-04-14T15:23:24Z")

</div>

VERY COOL! thanks for sharing @Daniel_Coglitore! Thunkable apps can be powerful when we learn to move slightly beyond a pure #noCode approach!

---

<div class="post-metadata">

**Author:** ![billyljren](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/billyljren/32/65122_2.png) [@billyljren](https://community.thunkable.com/u/billyljren)\
**Post date:** [April 15, 2020, 1:16am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/14 "2020-04-15T01:16:05Z")

</div>

Thanks for sharing @Daniel_Coglitore! It is surely more complicated that I imagined.

I’ve been researching around and I found this RestDB, which seem to make life easier using Web API and simple query parameters. From the docs, it seems to support filter queries easily. I’m going to explore this one.  
[https://restdb.io/docs/querying-with-the-api#restdb](https://restdb.io/docs/querying-with-the-api#restdb)

---

<div class="post-metadata">

**Author:** ![jeffd](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jeffd](https://community.thunkable.com/u/jeffd)\
**Post date:** [February 19, 2021, 5:12pm UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/15 "2021-02-19T17:12:09Z")

</div>

> [@billyljren](#):
>
> I’ve been researching around and I found this RestDB, which seem to make life easier using Web API and simple query parameters. From the docs, it seems to support filter queries easily. I’m going to explore this one.  
> [REST API Examples - querying with the API - mongodb syntax - Restdb.io](https://restdb.io/docs/querying-with-the-api#restdb)

Have you had any success using the RestDB API queries with thunkable?

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:39am UTC](https://community.thunkable.com/t/searching-in-firebase-realtimedb-via-webapi/563301/16 "2024-11-08T11:39:03Z")

</div>


