# Accessing NFT Data

1. Retrieve the NFT & metadata from the blockchain
2. 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](https://docs.ghostmarket.io/developer-guides/api) for all supported APIs

Use the  API endpoint:&#x20;

Use the [`metadata`](https://docs.ghostmarket.io/developer-guides/api) 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](#blockchain-short-names) table for the list of supported ***chain*** names.
* See the [NFT Contract](https://docs.ghostmarket.io/smart-contracts/nft-smart-contracts) table for current NFT ***contract***&#x73;.
* The ***token\_id*** is an integer specifying the NFT within the collection (NFT contract)

Example:

```bash
curl -X 'GET' \
'https://api.ghostmarket.io/api/v2/metadata?chain=bsc&contract=0xF41db445D7eaF45536985cE185ce131FA4b42E68&tokenId=1 | jq .json'
```

The returned `json` object is escaped, so, should be unescaped before use.\
Following is an example of the unescaped object ( "\\" removed for clarity ).

```json
{
json: {
        "name": "GHOST Genesis NFT #1",
        "image": "ipfs://QmefnzTwshjRhZgMpRfRhp5Xg1hdWnWo7cnuZH8QhDmnjQ",
        "attributes": [
            {
                "trait_type": "Genesis",
                "value": true,
                "display_type": ""
            }
        ],  
        "properties": {
            "type": 2,
            "has_locked": false  
        },
        "description": "The owner of this exclusive NFT is granted 100% discount on GhostMarket trading fees, for life."
    }
}
```

### 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}](https://ipfs.io/ipfs/%7Bhash%7D) URL.<br>

e.g. Using a browser to render above `image` URI,  browse to:

```bash
https://ipfs.io/ipfs/QmefnzTwshjRhZgMpRfRhp5Xg1hdWnWo7cnuZH8QhDmnjQ
```

To programmatically retrieve IPFS data, other possible alternatives for accessing IPFS is to [set up your own IPFS node](https://docs.ipfs.io/install/) or use the [Infura](https://infura.io/docs/ipfs) 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.
