How can I fetch price from json?

Asked Mar 6, 2024·2 replies·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

2 replies

Hey @Royal Unicorn!

You almost got it:

$(eval const api = $(urlfetch json https://recommendation.api.useinsider.com/10005127/tr_TR/user/0?details=true&size=20&currency=TRY&filter=(%5Boriginal_price.TRY%5D%5B%3C%5D%5B20000%5D)*(%5Bcategory%5D%5B~%5D%5Bknight-online%5D)*(%5Bname%5D%5B~%5D%5BKnight%20Online%20Zero%20Gold%20Bar%20GB%5D)&shuffle=true); api.data[0].price.TRY)

The important part here is api.data[0].price.TRY. You store the data into the api variable, so in order to extract some of it, you need to refer to it, hence why I start with api, then you enter the data array, and because it's an array of length of 1, and because we're interested in the data inside of the first cell, we get it with data[0], and then we can finally access the price.TRY value.

Thank you very much. I tried using api. too, but missed [0].