Post
Share your knowledge.
How to query more than 50 NFTs using getObjects API?
I'm trying to retrieve a large number of NFTs from a blockchain address but ran into a limit in the getObjects API, which restricts the number of objects I can fetch at a time to 50. What's the correct way to handle this limitation and obtain more results? Is there any specific method or example code for handling pagination?
- Sui
- Architecture
Answers
2To overcome the 50-object limit in the getObjects API, you should utilize pagination. This involves using the cursor provided by the API to fetch the next set of results. Start by making an initial API call, then check the response for pagination details like 'nextCursor' and 'hasNextPage'. Use the 'nextCursor' as a parameter in your subsequent API calls until 'hasNextPage' is false, indicating there are no more objects to fetch.
For implementation, refer to the Sui API documentation about pagination and querying objects. This typically involves making a series of requests using the cursor until you have retrieved all desired data. Each response will provide a cursor for the next set of objects, allowing you to handle larger datasets effectively .
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.