How can I fetch price from json?

What I’m doing wrong here?

$(eval api=$(urlfetch json https://recommendation.api.useinsider.com/10005127/tr_TR/user/0?details=true&size=20&currency=TRY&filter=([original_price.TRY][<][20000])*([category][~][knight-online])*([name][~][Knight%20Online%20Zero%20Gold%20Bar%20GB])&shuffle=true); data.price.TRY)

Hey @Dust_88!

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.

1 Like

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

1 Like

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