Here for the API?Start building with us today

Learn about DeCommas API
Tutorial: How to Use the New NFT Endpoints using DeCommas API
Tutorial
December 08, 2023

Tutorial: How to Use the New NFT Endpoints using DeCommas API

In the blockchain industry, a new chapter has unfolded since the advent of NFTs. Though unique and immutable, these digital assets are revolutionizing how we perceive ownership and value in the digital space. At the center of this revolution is the DeCommas API — a cutting-edge toolset that is redefining how developers interact with NFTs.

Imagine this for a second: a toolkit so robust and intuitive that it simplifies the complexities of NFT data and opens up possibilities for innovation and creativity at the same time. This is the promise of the new NFT endpoints introduced by DeCommas. So, regardless of who you are, a seasoned developer or a newbie, these endpoints are designed to empower you to build, innovate, and transform the NFT space.

But why are these endpoints a game-changer in the NFT world? This is because they offer unprecedented access to detailed NFT data, enabling developers to build top-notch features. Features like tracking the top holders in an NFT collection and accessing rich metadata. It is safe to say these endpoints provide the keys to unlock web3 data.

This article explores these groundbreaking endpoints. By the end of this tutorial, you’ll not only grasp the full potential of these new tools but also be equipped to harness them in your projects, pushing the boundaries of what’s possible in the NFT space.

Tutorial: An Overview of DeCommas API New NFT Endpoints

This tutorial will guide you through the latest additions and adjustments to the DeCommas API. Here is a list of the new and adjusted endpoints we will cover:

  • nft_top_holder
  • Nft_collection_metadata
  • NFT Transfers (adjusted)

That’s not all. We will also recap how to get your personal mission control API key and set it up. Specifically, we will examine:

  • Get Your Personal Mission Control API Key
  • Setting Up Mission Control API in Your Development Environment
  • Building with DeCommas API endpoints

New Endpoints

  1. nft_top_holder: This endpoint retrieves a list of the top holders for a specific NFT collection. This is useful for identifying whales and influencers in the NFT space.
  2. nft_collection_metadata: This endpoint returns metadata for a specific NFT collection, such as the collection name, description, and logo.
  3. NFT Transfers (adjusted with fields parameters): This endpoint has been adjusted to include additional fields parameters, such as the block timestamp and transaction hash. This provides developers with robust data about NFT transfers.

Benefits of the New Decommas Endpoints to Developers:

  1. Access to comprehensive data: The new endpoints provide access to data that were previously unavailable, example of such data include, top holders and collection metadata.
  2. Enhanced functionality: The adjusted NFT Transfers endpoint provides more granular data about NFT transfers, making it easier to track and analyze NFT activity.
  3. Improved user experience: With the help of the new endpoints, developers can build applications that provide users with richer and better experiences.

Get Your Personal Mission Control API Key

If you recall in our previous tutorials, you need access to the Mission Control API to get your personal mission control API key. Fortunately, it’s often free to use with consistently low response times of 150 milliseconds. However, you can obtain your API key by following these steps:

Step 1: Visit https://build.decommas.io/

Step 2: Click “Get Started”

Step 3: Provide your email address for verification

Step 4: Check your email for the verification link, and click it to access with URL https://dashboard.decommas.io/ , your gateway to API keys.

Ensure your API keys are stored using robust security and readily accessible for future use. Furthermore, you can consult our documentation here for further research.

Setting Up the Mission Control API in your Development Environment

Whether you’re keen on making raw HTTPS requests or prefer the convenience of the JavaScript SDK, DeCommas offers both options. This section walks you through both options but concentrates mainly on the JavaScript SDK. Here are the steps to get started:

Step 1: Installation

To start, install the DeCommas API SDK:

npm install @decommas/sdk

Step 2: SDK Initialization

Post-installation, import the SDK. For development-only mode, you can initialize it without an API key:

import { Decommas } from '@decommas/sdk';
const decommas = new Decommas();
const getVitalikERC20Balances = async () => {
const address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; // Replace with any address
const tokens = await decommas.address.getTokens({ address });
console.log(tokens);
};

Step 3: Using an API Key

For full access to the DeCommas API features, sign up on the DeCommas dashboard to obtain your API key:

import { Decommas } from '@decommas/sdk';
const API_KEY = "YOUR_API_KEY";
const decommas = new Decommas(API_KEY);

Replace YOUR_API_KEY with the desired API KEY

Raw HTTPS Requests

For those who opt for raw HTTPS requests:

https://datalayer.decommas.net/datalayer/api/v1/token_holders/{chain_name}/{contract_address}?api-key={YOUR-API-KEY}

Replace CONTRACT_ADDRESS with the contract address of the token.

Building with DeCommas API endpoints

This section explains how to utilize the newly introduced endpoints, including nft_top_holder, nft_collection_metadata, NFT Transfers, and ERC Transfers. In addition, we will highlight the recent enhancements made to these endpoints, such as the introduction of field parameters.

  1. nft_holder Endpoint

What it does: It shows the top holders per NFT collection. We determine the ‘top’ status based on the number of NFTs per holder.

Example:

Via URL:

GET https://datalayer.decommas.net/datalayer/api/v1/nft_holders/{chain_name}/{contract_a

Via SDK:

const decommas = new Decommas('YOUR_API_KEY');
const topHolders = await decommas.metadata.getNftHolders({ chainName, contractAddress })
console.log(topHolders);

Response example:

{
  "status": 200,
  "result": [
    {
      "holder_address": "0x24e267d13314dd742d86c3321e727b801ed99542",
      "amount": "104",
      "chain_id": 1,
      "chain_name": "mainnet"
      },
  {
  "holder_address": "0xb6c1078f6fd3e682f3c69f8f6e616476765749a7",
  "amount": "63",
  "chain_id": 1,
  "chain_name": "mainnet"
  },
  …
 ]
}

2. nft_collection_metadata

What it does: It provides access to detailed information about a specific NFT collection, including its name, description, type, and other relevant attributes.

Example:

Via URL:

GET https://datalayer.decommas.net/datalayer/api/v1/nft_collection_metadata/{chain_name}

Via SDK:

const decommas = new Decommas('YOUR_API_KEY');
const collectionMetadata = await decommas.metadata.getNftCollection({ chainName, contractAddress })
console.log(collectionMetadata);

Response Example:

{
  "status": 0,
  "result": {
    "chain_name": "string",
    "chain_id": 0,
    "contract_address": "string",
    "collection_name": "string",
    "floor_price_usd": "string",
    "market_cap_usd": "string",
    "collection_verified": Boolean,
    "contract_type": "string"
  }
}

Announcement:

You can now filter NFT collections to receive only verified NFTs with the verified option [true|false].

Example

Via URL:

GET https://datalayer.decommas.net/datalayer/api/v1/nft_collection_metadata/{chain_name}"?verified=true"

Via SDK:

const decommas = new Decommas('YOUR_API_KEY');
const collectionMetadata = await decommas.decommas.address.getNfts({ address, limit?, offset?, chains?, verified? })
console.log(collectionMetadata);

Response Example:

Use collection_verified=true only when you want verified collections returned.

{
  "status": 0,
  "result": {
    "chain_name": "string",
    "chain_id": 0,
    "contract_address": "string",
    "collection_name": "string",
    "floor_price_usd": "string",
    "market_cap_usd": "string",
    "collection_verified": true,
    "contract_type": "string"
  }
}

Introducing Enhancement in NFT Transfers and ERC Transfers Endpoints

The NFT Transfers and ERC Transfers endpoints have been enhanced with the recent addition of field parameters for fee, gas_price, gas_used, and block_base_fee_per_gas. These parameters provide more granular data about NFT and ERC-20 token transfers and enable more detailed analysis of gas costs and transaction fees.

Example Usage for NFT Transfers

Using API:

GET https://datalayer.decommas.net/datalayer/api/v1/transfers_nft/{address}

Using SDK:

const decommas = new Decommas('YOUR_API_KEY');
const nftTransfers = await decommas.address.getNftTransfers({ address, limit?, offset?, chain? })
console.log(nftTransfers);

Response Example:

{
  "status": 0,
  "result": [
    {
    "chain_name": "string",
    "chain_id": 0,
    "block_number": 0,
    "block_timestamp": 0,
    "log_index": 0,
    "from_address": "string",
    "to_address": "string",
    "contract_address": "string",
    "token_id": "string",
    "contract_type": "string",
    "amount": "string",
    "transaction_hash": "string",
    "method": "string",
    "method_hash": "string",
    "fee": "string",
    "gas_price": "string",
    "gas_used": "string",
    "block_base_fee_per_gas": "string"
    }
  ]
}

Example Usage for ERC Transfers

Using API:

https://datalayer.decommas.net/datalayer/api/v1/transfers_erc20/{address}

Using SDK:

const decommas = new Decommas(YOUR_API_KEY);
const ercTransfers = await decommas.address.getErc20Transfers({ address, limit?, offset?, chain? })
console.log(ercTransfers);

Response Example:

{
  "status": 0,
  "result": [
    {
    "chain_name": "string",
    "chain_id": 0,
    "block_number": 0,
    "block_timestamp": 0,
    "log_index": 0,
    "from_address": "string",
    "to_address": "string",
    "token_address": "string",
    "amount": "string",
    "transaction_hash": "string",
    "method": "string",
    "method_hash": "string",
    "fee": "string",
    "gas_price": "string",
    "gas_used": "string",
    "block_base_fee_per_gas": "string"
    }
  ]
}

Wrapping Up — New DeCommas API Endpoints Usage

We’ve navigated the latest NFT endpoints in the DeCommas API, delved into their functionalities, and wrapped up with how to use these cutting-edge features for your projects.

While we’ve provided you with the insights and tools to kickstart your exploration of these NFT features, always remember there’s so much more you can build on this foundation. The world of digital assets is expansive, and with DeCommas as your ally, the possibilities are limitless. Whether building an innovative NFT marketplace, conducting in-depth market analysis, or enhancing user experiences in your digital gallery, these new endpoints are the building blocks of your success.

Should in case you have questions or hit a roadblock, feel free to contact us at [email protected]. We’ll be happy to assist.

Happy building!