Hello all,
Anyone having a good idea of the simplest way to cache data based on an API response
Cheers
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?
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?
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?
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!?
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.
I was unclear - there are several users. I must use acavhe to let all benefit from one call right!!?
You haven’t told me anything about the API so I can’t answer that!
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…
Use a cloud database for this type of storage and distribution
Yes that is what i thought and i am wondering if there is any best practices that can be share for this…
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.
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?
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…
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.