Skip to main content

Don't have an API key yet?

Sign-up to Moralis to get your free API key and start building today.

Get Your Free API Key
Version: 2.2

How to get NFT trades by Markeplace

Step 1: Setup Moralis

Read the article Setting Up Moralis: Getting Started and make sure to finish all the steps. Only after that you can go ahead to complete this guide.

Step 2: Get All Transfers Of An NFT

In order to get all the trades of an NFT by marketplace, Moralis provides you with an getNFTTrades endpoint.

Here you'll need three parameters: address, marketplace, and chain.

Once you have obtained the address, marketplace and chain, you can copy the following code:

const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");

const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});

const address = "0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB";

const chain = EvmChain.ETHEREUM;

const marketplace = "opensea";

const response = await Moralis.EvmApi.nft.getNFTTrades({
address,
chain,
marketplace,
});

console.log(response.toJSON());
};

runApp();

Step 3: Run the script

To run the script, enter the following command:

node index.js

In your terminal, you should see the following JSON response:

{
"total": null,
"page": 0,
"page_size": 100,
"cursor": null,
"result": [
{
"transaction_hash": "0x5eba5d8d84c20a7f30b92d74afaee764d9476b62a1637b017319c721269245ed",
"transaction_index": "90",
"token_ids": ["1002", "7228", "1", "1"],
"seller_address": "0xe7f35f06a80a6a2a5edc823379fa147d9f9948a8",
"buyer_address": "0xd7c708080553068217a2fe6f44eccf9cac309915",
"token_address": "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb",
"marketplace_address": "0x7be8076f4ea4a4ad08075c2508e481d6c946d12b",
"price": "18980000000000000000",
"price_token_address": "0x60e4d786628fea6478f785a6d7e704777c86a7c6",
"block_timestamp": "2022-03-18T22:21:07.000Z",
"block_number": "14413068",
"block_hash": "0x50e740dd733efc1e7252e3863e76368624d146e1a8447fab32c9697685cf581d",
"verified_collection": true
}
]
}

Congratulations 🥳 You just got all the trades of an NFT with just a few lines of code using the Moralis NFT API!

API Reference

If you want to know more details on the endpoint and optional parameters, check out:

Support

If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.