Fast Api response

Good morning,
I’m using the current blocks to parse API resposne and populate a data source to br shown on a data viewer list ,


it works fine except for being slow.
Are there any better strategy for a faster process especially some community members mentioned that there is a better process without giving any details.
here is the post page
What is the fastest way of filling up a local-source DVL from JSON data? - Questions about Thunkable - Community
@kartik14

can you try this ?
create a variable, say list_item and set it to the block i encircled. then insert the set block as first step inside the count loop. of course you can now replace occurrences of the block with the variable list_item.
do you have to do all those replacements of quotes to spaces? there are no more quotes inside because json automatically takes care of them for you. so also try your code without enclosing with the text replacement box. see if it speeds it speeds it up a little. (ie, do not do text replacement)

actually you can still do better.
build the list , say data_list, BEFORE the count block - then adjust remaining blocks accordingly.
i hope this helps.

2 Likes

In addition to what @manyone suggested, you are using a function block (“list of values in”) inside of a loop so every time the loop iterates, it has to get the full list of values in the Category column again. Instead, set a variable to that list of values block before the loop starts and then use the variable where you currently have the “list of values in” block inside your loop.

1 Like

@tatiang
Dear could you please send me the blocks image, if possible.
It’s a little difficult for me to fully digest what you say.

@manyone
I have to do text replacement as the normal Api response give results in quotation mark, as any image link in Quotation mark will not be displayed.

It may be faster to use the substring block from 2 to last minus 1. The replace all has to check every cell before replacing it if needed. But you already know where those quote marks are.

1 Like

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