Issue Fetching NFT Data from DID Explorer API
I’m currently working on fetching NFT data using the DID Explorer API. Specifically, I’m using the DID did:abt:zjdfNpWudcV9ZL8mA5g5Tp1fTPWUZAsGMQMw, but when I make the API call, the response is returning HTML instead of JSON.
I’m expecting the API to return the assets or NFTs associated with the DID, but it seems like the response is either incorrect or the data is not available. Could you please confirm if this DID has associated assets, or if there are any known issues with the API?
Any guidance would be appreciated.
13 replies
How did you call the API? The ArcBlock Chain exposes a GraphQL endpoint for developers to query data and send transactions, and we have a dedicated client library for that, check out the following code snippet for how to query NFT State:
A few site nodes:
@ocap/clientas dependency to your projecthttps://beta.abtnetwork.io/api/if your NFT is on test chainInitially, I tried calling the API directly from the frontend using a standard
fetchrequest in my React component. Here's an example of how I made the API call:However, I encountered issues like receiving HTML instead of JSON, which I believe might be related to CORS restrictions or other limitations.
I see now that you recommend using
@ocap/client, which requires setting up a Node.js backend to handle these requests. Since I'm building a custom component in the Pages Kit, I was trying to avoid adding a backend setup for simplicity.Do you have any suggestions for how I might be able to make this work without setting up a separate backend, or is the backend approach the only viable option with the current API setup?
Thanks for your help!
The custom component I’m building in the Pages Kit is designed so that users can easily enter their DID and display their NFT collection of choice. My goal is to keep the process simple by avoiding a backend setup, allowing users to manage and showcase their collections directly through the frontend.
If you are using the API in Pages Kit, you should consider using the following code snippet:
In the code snippet you provided, I see the placeholder endpoint
https://main.abtnetwork.io/developer/api. and I also see Replace with your actual GraphQL endpoint.Could you please provide the actual GraphQL endpoint for querying asset states or NFT data? I’m currently getting a
404error.or am i just totally doing this wrong 🙂
athis is the code im using in the custom component area. I don't know why it is having api issue.
Removing the
/developerpart should fix the issuethank you!
thank you we got it!
Thank you for all your help.
I will continue to fine tune the component, but it is now working.
This custom component for pages kit has props for title, backround image and opacity, column qty, and for DIDs to be entered in order create card holders.
I think this will be tremendously helpful for people who want to have a way to quickly show of their collections.
Here is an example of the the gallery
The Daily Arc
Perhaps you can publish this component as a blocklet to Blocklet Store, so that others can reuse it, 😄
Certainly.