Accessing NFT Data
Guide to retrieving NFT content and metadata.
Retrieve the NFT & metadata from the blockchain
Retrieve the Image/media from IPFS
1. Retrieve the NFT & metadata
GhostMarket REST API provides the simplest method of retrieving the NFT Metadata in simple to digest JSON format. We monitor all supported chains and index NFT events, simplifying and standardizing the retrieval of Metadata from the disparate blockchains which we support.
see our API reference for all supported APIs
Use the API endpoint:
Use the metadata
API endpoint, populating the {chain}, {contract} and {token_id} params.
https://api.ghostmarket.io/api/v2/metadata?chain={chain}&contract={contract}&tokenId={tokenId}
See the Blockchain Short Name table for the list of supported chain names.
See the NFT Contract table for current NFT contracts.
The token_id is an integer specifying the NFT within the collection (NFT contract)
Example:
The returned json
object is escaped, so, should be unescaped before use.
Following is an example of the unescaped object ( "\" removed for clarity ).
2. Retrieve the Image/media
IPFS Media
If the image
field contains one of the prefixes "ipfs://" the content must be retrieved from IPFS:
Extract the IPFS hash from the image
field of the metadata (The Hash is the text following the "//" in the URL), and append this to the IPFS HTTP gateway - https://ipfs.io/ipfs/{hash} URL.
e.g. Using a browser to render above image
URI, browse to:
To programmatically retrieve IPFS data, other possible alternatives for accessing IPFS is to set up your own IPFS node or use the Infura IPFS Gateway.
Non IPFS Media
If the image
field points to a non IPFS URL, e.g. AWS or a generic HTTP(S) address, then directly access the image using the supplied URL.
Last updated