# Cache API response data

**URL:** <https://community.thunkable.com/t/cache-api-response-data/2792079>\
**Category:** Questions about Thunkable X\
**Created:** [January 19, 2024, 2:22pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079 "2024-01-19T14:22:29Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [January 19, 2024, 2:22pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/1 "2024-01-19T14:22:29Z")

</div>

Hello all,  
Anyone having a good idea of the simplest way to cache data based on an API response  
Cheers

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 19, 2024, 2:37pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/2 "2024-01-19T14:37:21Z")

</div>

You can store an API response in a variable but I’m not sure that’s what you mean.

Can you say more about that?

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [January 20, 2024, 8:18am UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/3 "2024-01-20T08:18:57Z")

</div>

Hi there  
Well i am after a best practice  
The api requires one call per minute  
So how can i best way make a check and if call the api if its the first this time in a minute. Alternative picke data from a cache. Is a db enough or do i need a separate software at complement my db?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 20, 2024, 11:26pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/4 "2024-01-20T23:26:28Z")

</div>

Your question is different than I understood at first.

So you want to know how to call the API once per minute? Do you need the data that frequently?

You can use a Timer in Thunkable to do that.

Which API is it?

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [January 21, 2024, 10:43am UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/5 "2024-01-21T10:43:56Z")

</div>

Hi there  
It is my STRUL app. Asking the commuter trafic companies for their status of current traffic. Each user had different fequirements…so  
For each user asking the apo should check if there is cached data avalable since \< min. If \> than a minute make a new call present it and save it in the casche…  
Get it!?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 21, 2024, 6:55pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/6 "2024-01-21T18:55:02Z")

</div>

I don’t know how you would check if the data in the app is the most current. You would have to call the API to do that. And then there’s no point of checking… you just call and update the data instead.

So I recommend you use a timer and forget about the cached data. Just make a call to the API every minute and replace the existing data with the new data.

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [January 21, 2024, 7:36pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/7 "2024-01-21T19:36:27Z")

</div>

I was unclear - there are several users. I must use acavhe to let all benefit from one call right!!?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 21, 2024, 8:28pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/8 "2024-01-21T20:28:08Z")

</div>

You haven’t told me anything about the API so I can’t answer that!

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [January 21, 2024, 10:14pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/9 "2024-01-21T22:14:44Z")

</div>

Regardless of what api it is. The response must be stored somewhere so it can be collected by everyone using my app (without making new calls every time) that is what i mean…

---

<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:** [January 21, 2024, 10:46pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/10 "2024-01-21T22:46:14Z")

</div>

Use a cloud database for this type of storage and distribution

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [January 22, 2024, 6:22am UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/11 "2024-01-22T06:22:48Z")

</div>

Yes that is what i thought and i am wondering if there is any best practices that can be share for this…

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 22, 2024, 6:47am UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/12 "2024-01-22T06:47:24Z")

</div>

Okay, sorry, I think I understand now. You want to make one API call (let’s say, each minute) and have the data update on each user’s phone.

You can use any cloud database for that. If users are not simultaneously editing the same data and you’re not storing confidential information, Google Sheets or Airtable should be fine. Otherwise, Firebase makes sense.

You would just replace the existing data in the cloud database and the app would always check that same location for data. So if the data is 59 seconds old, the user would see the data in the database. If the data is 1 second old, same thing.

---

<div class="post-metadata">

**Author:** ![finbarr.mccarthytl32](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@finbarr.mccarthytl32](https://community.thunkable.com/u/finbarr.mccarthytl32)\
**Post date:** [January 23, 2024, 1:48pm UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/13 "2024-01-23T13:48:03Z")

</div>

Hi Stefan,  
Are you looking to retrieve unique data for each app user (in which case can they not poll the relevant commuter traffic API to update their data every minute using a timer?  
Or is there a charge from the commuter traffic companies for each API call?

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [January 26, 2024, 6:34am UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/14 "2024-01-26T06:34:16Z")

</div>

This is the usecase  
When using the API there are a number of variables that can be set by user.  
When Submit - the app should check 1. Has exactly the same call been made within the last minute by other users. If the answer is YES there should be a cached version of the same call response to display.  
If not The call should pick up new data, display it and store it in the cache.

as i see it now i think firebase is the simplest way to handle/store the cached data…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [April 25, 2024, 6:34am UTC](https://community.thunkable.com/t/cache-api-response-data/2792079/15 "2024-04-25T06:34:50Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
