A step-by-step guide on how to query NFT data using Javascript fetch.

For this guide, we will be using fetch

Javascript Fetch

node-fetchis a lightweight, common module that brings the Fetch API to Node.js and allows us to make our HTTP requests. You can see the documentation for more info: https://www.npmjs.com/package/node-fetch


Run the following command to install node-fetch with npm and yarn
With npm

npm install node-fetch

With yarn

yarn add node-fetch

Sample Code

In your project directory, you can create a new file called fetch-nftgo.js using your favorite file browser, code editor, or just directly in the terminal using the touch command like this.

touch fetch-nftgo.js

and then paste the following code snippet in to explore the get_nft_basic_info method:

import fetch from 'node-fetch';

// Replace with your NFTGo API key:
const apiKey = "YOUR-API-KEY";
const options= {
  method: 'GET',
  headers: {
    accept: 'application/json',
    'X-API-KEY': apiKey
// Replace with the contract address you want to query:
const contractAddress = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
// Replace with the token id you want to query:
const tokenId = "4495"
const url = `https://data-api.nftgo.io/eth/v1/nft/${contractAddress}/${tokenId}/info`;

// Make the request and print the formatted response:
fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));

From your command line, you can execute the script with:

node fetch-nftgo.js

Your output should look like the following:

  "blockchain": "ETH",
  "collection_name": "Bored Ape Yacht Club",
  "collection_slug": "bored-ape-yacht-club",
  "collection_opensea_slug": "boredapeyachtclub",
  "contract_address": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
  "token_id": "4495",
  "name": "Bored Ape Yacht Club #4495",
  "description": "string",
  "image": "https://static.nftgo.io/asset/metadata/image/5e236a5b9e95e4b88df604399ea7ca56229fdf86b9b8da78a6fd587a155b8b98",
  "animation_url": "string",
  "owner_addresses": [
  "traits": [
      "type": "Eyes",
      "value": "Wide Eyed",
      "percentage": 0.0549
      "type": "Background",
      "value": "Aquamarine",
      "percentage": 0.1266
      "type": "Fur",
      "value": "Black",
      "percentage": 0.1229
      "type": "Mouth",
      "value": "Bored",
      "percentage": 0.2272
      "type": "Clothes",
      "value": "Service",
      "percentage": 0.0142
  "rarity": {
    "score": 34.72,
    "rank": 9152,
    "total": 10000