NFTs Quickstart

Welcome to the Defined NFT GraphQL API docs.

πŸ“˜

Don't have an API key yet?

Go to the Defined Dashboard and sign up for a free API account.

Explore NFT endpoints to get collection/asset metadata, events, detailed stats, or search through the 420M+ NFTs listed on Defined.

Enterprise users have access to websockets and can subscribe to real-time collection/asset events.


Copy-paste the code below to get started quickly with the Get NFT Collection Metadata endpoint on the command line or in your app.

  ## Note the use of `\` to escape the quote character
  
  curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization:<MY_KEY>" -d '{ "query": "{ getNftCollectionMetadata(collectionId: \"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1\") { contract { name symbol totalSupply } stats { tradeCount } } }"}' \
  https://graph.defined.fi/graphql
import axios from "axios";

axios
  .post(
    "https://graph.defined.fi/graphql",
    {
      query: `{  
        getNftCollectionMetadata(  
          collectionId: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1"  
        ) {  
          contract {  
            name  
            symbol  
            totalSupply  
          }  
          stats {  
            tradeCount  
          }  
        }  
      }`
    },{
      headers: {
        "Content-Type": "application/json",
        "Authorization": "<MY_KEY>"
      }
    }
  )
  .then((response) => {
    console.log(response.data);
  });

import requests
import json

url = "https://graph.defined.fi/graphql"

headers = {
  "content_type":"application/json",
  "Authorization": "<MY_KEY>"
}

getMetadata = """query GetNftCollectionMetadataQuery { 
	getNftCollectionMetadata(
  	collectionId: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1"
 	) {
    contract {
      name
      symbol
    	totalSupply
    }
    stats {
    	tradeCount
  	}
	} 
}"""

response = requests.post(url, headers=headers, json={"query": getMetadata})

print(json.loads(response.text))
<?php

$url = "https://graph.defined.fi/graphql";

$query = array(
    'query' => `{  
        getNftCollectionMetadata(  
          collectionId: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1"  
        ) {  
          contract {  
            name  
            symbol  
            totalSupply  
          }  
          stats {  
            tradeCount  
          }  
        }  
      }`
);

$headers = array(
    'Content-Type: application/json',
    'Authorization: ' . "<MY_KEY>"
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
package main

import (
  "bytes"
	"fmt"
	"net/http"
	"io/ioutil"
	"encoding/json"
)

func main() {
	url := "https://graph.defined.fi/graphql"
	apiKey := "<MY_KEY>"

	query := `query { getNftCollectionMetadata(collectionId: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1") { contract { name symbol totalSupply } stats { tradeCount } } }`
	payload := map[string]string{"query": query}
	payloadBytes, _ := json.Marshal(payload)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", apiKey)

	client := &http.Client{}
	res, _ := client.Do(req)
	defer res.Body.Close()

	body, _ := ioutil.ReadAll(res.Body)

	var response map[string]interface{}
	json.Unmarshal(body, &response)

	fmt.Println(response)
}
require 'net/http'
require 'json'

uri = URI('https://graph.defined.fi/graphql')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

headers = {
  'Content-Type' => 'application/json',
  'Authorization' => '<MY_KEY>'
}

query = {
  query: `{  
  	getNftCollectionMetadata(  
    	collectionId: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1"  
    ) {  
    	contract {  
      	name  
        symbol  
        totalSupply  
    	}  
      stats {  
      	tradeCount  
      }  
    }  
	}`
}

request = Net::HTTP::Post.new(uri.path, headers)
request.body = query.to_json

response = http.request(request)
puts response.body

Remember to replace <MY_KEY> with your new API key.