API cache

Hello,
I noticed that there are API calls if:

  • You change Tab
  • You add a column in the Data Editor
  • If you view in an inline-list
  • If you switch from Layout to Data Editor
  • Also be careful, if you use a Text-Entry component directly to do a search, the APIs are called for each character entered. (I recommend using a button to validate the search)

Here is an attempt to cache API calls.

To limit the number of calls to an API, here is some code with caching.
(There may be another method !!)

4 Likes

This is an issue I want to solve too in order to use paid APIs more efficiently. Did this work nicely for you?

Yes, it does limit calls a lot.
There is still an issue when you open an application, you still have to do some tests.

yep … thats why i made restriction to return from function if parameter is empty… later i add if is bigger than 3 characters that dont contain digits thats cut off api calls by 80%

Version 2
I added a small error handling in case of problem with google map or a problem with the API key

2 Likes

The problem is if you use an array, for example, addresses and you add a YC column with the API calls, if you have 100 rows, I think and I’m pretty sure when opening the app (and even with this cache) it will have 100 API calls for refresh.
So for paying, it must be limited to a particular search

1 Like

add also restriction for stupid addresses like someone put just digits or address is way to short like less that 3 alpha characters

thats why i went back to triggered google script it only calling for a changed single cell … also your API key is exposed in App

no I do not limit to the number of characters because there are city names <4 characters, same for the numbers, sometimes we specify the postal code

thats why i said less than 3 :wink: … but anyway, you will for sure get wrong address if you put even 4 characters… so no sense to call with that

everything on computer media is hackable.
for APIs like those of google, there is still the possibility to restrict to https

No in France there are cities like

  • Y
  • By
  • Eu

this is the result of putting just Y

Screen Shot 2021-08-01 at 10.54.02 PM

so you just waisted one call

I know everything is hackable… but good luck finding my API key in Glide App, when it comes from google script

For my personal case, I filtered through France, so he easily finds “Y”

hmmm… but is a correct full address that you are looking for? :wink:
my point is… you can eliminate few unnecessary calls if you limit entry output… in a scale of a month with many users… that might save you good money… for a personal use. you prabably never gonna cross free limit… so no need for restrictions at-all

Just for Laughs,
I coded my Key Api in …

1 Like

i don’t think that’s funny… i think this is smart… :wink:

Well yes it’s funny
Because if someone is able to find the parameters from an application, it is necessarily reading a script

hmm… yep but it is another obstacle to cross…