hicetnunc2000 / hicetnunc

hicetnunc UI/UX
http://hicetnunc.xyz
800 stars 281 forks source link

Querying an array of OBJKTs ids from the api #298

Closed mescalina closed 3 years ago

mescalina commented 3 years ago

Hi,

it would be great to be able to query more than 1 OBJKT data from the api with just one call using an array instead of a single id. It could save millions of calls to the api.

Quasimondo commented 3 years ago

Unfortunately the API is not maintained by hic et nunc so we do not have control over it. I think this is something that would have to be suggested to the Baking Bad developers who maintain https://better-call.dev/ who you can reach via their Telegram group: https://t.me/baking_bad_chat

mescalina commented 3 years ago

Ok, thanks, I'll try to drop the request on their telegram

In the .env.prod on this repo there is this link: https://51rknuvw76.execute-api.us-east-1.amazonaws.com/dev/objkt

I think it resolves to this api route: https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens

Quasimondo commented 3 years ago

Ah, I tried to use that objkt endpoint before, but I ran into CORS blocking when I deployed it to the site. Not sure if this has now been whitelisted.

And yes that api.better-call.dev link looks like this is one of the endpoints I am using in my experimental NFTs

mescalina commented 3 years ago

So, I got an answer from Baking Bad in their Telegram. I post here the update in case somebody else need this information.

The API endpoint to call is this: https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens By default it answers with the 10 most recent tokens, there's offset parameter to paginate.

To ask for a specific token by id this is the query GET parameter to use: https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens?token_id=1000 Querying for more than 1 id in the same request is not possible at the moment.

Here two useful links they gave me, this is the most updated API parameters reference: https://petstore.swagger.io/?url=https://api.better-call.dev/v1/swagger.json

This is an article covering the TzKT v1.4 Api with a lot of interesting information: https://baking-bad.org/blog/2021/03/03/tzkt-v14-released-with-improved-smart-contract-data-and-websocket-api/