Token

getTokenMetadata

Returns metadata (name, symbol, decimals, logo) for a given token contract address (asynchronous).

Options:

1
//Get metadata for one token
2
const options = { chain: "bsc", addresses: "0xe...556" };
3
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadata(options);
4
​
5
​
6
//Get metadata for an array of tokens
7
const options = { chain: "bsc", addresses: ["0xe...556", "0xe...742"] };
8
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadata(options);
Copied!

Example result:

1
[
2
{
3
"address": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
4
"name": "Kylin Network",
5
"symbol": "KYL",
6
"decimals": "18",
7
"logo": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c.png",
8
"logo_hash": "ee7aa2cdf100649a3521a082116258e862e6971261a39b5cd4e4354fcccbc54d",
9
"thumbnail": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c_thumb.png",
10
"block_number": "string",
11
"validated": "string"
12
}
13
]
Copied!

getTokenMetadataBySymbol

Returns metadata (name, address, decimals, logo) for given symbols (asynchronous).

Options:

1
//Get metadata for one token
2
const options = { chain: "bsc", symbols: "LINK" };
3
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadataBySymbol(options);
4
​
5
​
6
//Get metadata for an array of tokens
7
const options = { chain: "bsc", symbols: ["LINK", "AAVE"] };
8
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadataBySymbol(options);
Copied!

Example result:

1
[
2
{
3
"address": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
4
"name": "Kylin Network",
5
"symbol": "KYL",
6
"decimals": "18",
7
"logo": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c.png",
8
"logo_hash": "ee7aa2cdf100649a3521a082116258e862e6971261a39b5cd4e4354fcccbc54d",
9
"thumbnail": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c_thumb.png",
10
"block_number": "string",
11
"validated": "string"
12
}
13
]
Copied!

getTokenAllowance

Returns the amount which the spender is allowed to withdraw from the spender (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • owner_address (required): The address of the token owner
  • spender_address (required): The address of the token spender
  • address(required): The address of the token contract
1
//Get token allowace on ETH
2
const options = {
3
owner_address: "0xe...556",
4
spender_address: "0xe...556",
5
address: "0xe...556"
6
};
7
const allowance = await Moralis.Web3API.token.getTokenAllowance(options);
Copied!

Example result:

1
{
2
"allowance": "string"
3
}
Copied!

getTokenPrice

Returns the price nominated in the native token and usd for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • exchange(optional): The factory name or address of the token exchange. Possible exchanges, for different chains are: ETH mainnet: uniswap-v3, sushiswap, uniswap-v2 BSC mainnet: pancakeswap-v2, pancakeswap-v1 Polygon mainnet: quickswap If no exchange is specified, all exchanges are checked (in the order as listed above) until a valid pool has been found. Note that this request can take more time. So specifying the exchange will result in faster responses most of the time.
  • address(required): The address of the token contract
  • to_block(optional): Returns the price for a given blocknumber (historical price-data)
1
//Get token price on PancakeSwap v2 BSC
2
const options = {
3
address: "0x7...2",
4
chain: "bsc",
5
exchange: "PancakeSwapv2"
6
};
7
const price = await Moralis.Web3API.token.getTokenPrice(options);
Copied!

Example result:

1
{
2
"nativePrice": {
3
"value": "8409770570506626",
4
"decimals": 18,
5
"name": "Ether",
6
"symbol": "ETH"
7
},
8
"usdPrice": 19.722370676,
9
"exchangeAddress": "0x1f98431c8ad98523631ae4a59f267346ea31f984",
10
"exchangeName": "Uniswap v3"
11
}
Copied!

getAllTokenIds

Returns an object with a number of NFTs and an array with NFT metadata (name, symbol) for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • offset (optional): offset.
  • limit(optional): limit.
  • address(required): The address of the token contract.
1
const options = { address: "0xd...07", chain: "bsc" };
2
const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
Copied!

Example result:

1
[
2
{
3
"token_address": "0xdf7952b35f24acf7fc0487d01c8d5690a60dba07",
4
"token_id": "384165",
5
"amount": "1",
6
"block_number": "10111462",
7
"block_number_minted": "10111462",
8
"contract_type": "ERC721",
9
"name": "Pancake Bunnies",
10
"symbol": "PB",
11
"token_uri": "https://ipfs.moralis.io:2053/ipfs/QmSs1sgcU57XeAsZneMsivFx3cgxhn3QZrswbwZxwpnuaJ/lottie.json",
12
"metadata": "{\n \"name\": \"Lottie\",\n \"description\": \"Lottie's looking hotto for lotto!\",\n \"mp4_url\": \"ipfs://QmWnhyxSrD8v9bx5tE9mDkwW853bpjoCXGd7o2fe1BtQJ8/lottie.mp4\",\n \"gif_url\": \"ipfs://QmWnhyxSrD8v9bx5tE9mDkwW853bpjoCXGd7o2fe1BtQJ8/lottie.gif\",\n \"webm_url\": \"ipfs://QmWnhyxSrD8v9bx5tE9mDkwW853bpjoCXGd7o2fe1BtQJ8/lottie.webm\",\n \"image\": \"ipfs://QmWnhyxSrD8v9bx5tE9mDkwW853bpjoCXGd7o2fe1BtQJ8/lottie.png\",\n \"attributes\": {\n \"bunnyId\": \"18\"\n }\n }",
13
"is_valid": 1,
14
"syncing": 2,
15
"synced_at": "2021-12-04T07:36:07.567Z",
16
"frozen": 0
17
},
18
]
Copied!

getNFTMetadata

Returns the contract level metadata (name, symbol, base token uri) for the given contract (asynchronous).

Options:

1
const options = { address: "0xd...07", chain: "bsc" };
2
const metaData = await Moralis.Web3API.token.getNFTMetadata(options);
Copied!
Requests for contract addresses not yet indexed will automatically start the indexing process for that NFT collection

Example result:

1
{
2
token_address: "0xdf7952b35f24acf7fc0487d01c8d5690a60dba07",
3
name: "Pancake Bunnies",
4
symbol: "PB",
5
abi: null,
6
contract_type: "ERC721",
7
supports_token_uri: null,
8
synced_at: "2021-09-16",
9
10
}
Copied!

getNFTOwners

Returns an object with a number of NFT owners and an array with NFT metadata (name, symbol) for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • offset (optional): offset.
  • limit(optional): limit.
  • address(required): Address of the contract
1
const options = { address: "0xd...07", chain: "bsc" };
2
const nftOwners = await Moralis.Web3API.token.getNFTOwners(options);
Copied!
1
const options = { address: "0xd...07" };
2
const nftOwners = await Moralis.Web3API.token.getNFTOwners(options);
Copied!
Make sure to include a sort parm on a column like token_id for consistent pagination results
Requests for contract addresses not yet indexed will automatically start the indexing process for that NFT collection

Example result:

1
[
2
{
3
"token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
"token_id": "15",
5
"contract_type": "ERC721",
6
"owner_of": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
7
"block_number": "88256",
8
"block_number_minted": "88256",
9
"token_uri": "string",
10
"metadata": "string",
11
"synced_at": "string",
12
"amount": "1",
13
"name": "CryptoKitties",
14
"symbol": "RARI"
15
}
16
]
Copied!

searchNFTs

Very powerful and fast tool for getting the NFT data based on a metadata search (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • offset (optional): offset.
  • limit(optional): limit.
  • q (required): The search string parameter
  • filter(required): What fields the search should match on. To look into the entire metadata set the value to global. To have a better response time you can look into a specific field like name. Available values : name; description; attributes; global; name,description; name,attributes; description,attributes; name,description,attributes
1
const options = { q: "Pancake", chain: "bsc", filter: "name" };
2
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
Copied!

Example result:

1
[
2
{
3
"token_id": "124436",
4
"token_address": "0x3afa102b264b5f79ce80fed29e0724f922ba57c7",
5
"token_uri": "https://ipfs.moralis.io:2053/ipfs/QmVAD8v4s2SXF8FgjePqMdQ2GV5hE2isZnzxcrA36XcSDA/metadata.json",
6
"metadata": "{\"name\":\"Pancake\",\"description\":\"The dessert series 1\",\"image\":\"ipfs://QmNQFXCZ6LGzvpMW9Q5PWbCrEnLknQrPwr2r8pbQAgzQ9A/4863BD6B-6C92-4B96-BF80-8020B2F7C3A5.jpeg\"}",
7
"contract_type": "ERC721",
8
"token_hash": "d03fe436e972bf9215d7bb8c64c4c556",
9
"synced_at": null,
10
"created_at": "2021-09-19T10:36:16.610Z"
11
}
12
]
Copied!

Searching by global:

1
const options = { q: "bored ape", chain: "bsc", filter: "global" };
2
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
Copied!

Searching by description,attributes:

1
const options = { q: "loves bananas", chain: "bsc", filter: "description,attributes" };
2
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
Copied!

getContractNFTTransfers

Returns an object with number of NFT transfers and an array with NFT transfers for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value is decimal.
  • offset (optional): offset.
  • limit(optional): limit.
​
  • address(required): Address of the contract
1
const options = { address: "0xd...07", chain: "bsc" };
2
const nftTransfers = await Moralis.Web3API.token.getContractNFTTransfers(options);
Copied!

Example result:

1
[
2
{
3
"token_address": "0xdf7952b35f24acf7fc0487d01c8d5690a60dba07",
4
"token_id": "191123",
5
"from_address": "0x0000000000000000000000000000000000000000",
6
"to_address": "0xccbc6f1df01bad0f477fe085760571572d115eed",
7
"amount": "1",
8
"contract_type": "ERC721",
9
"block_number": "6827111",
10
"block_timestamp": "2021-04-23T22:25:35.000Z",
11
"block_hash": "0x79b8618df3d5b62ee4f230386284ea78037bc61f36418488db71564d2aca583c",
12
"transaction_hash": "0x9dedbb0fa63eba77634564ef6682826ccfdd1cb58be6e7b2f44cdf0aada07733",
13
"transaction_type": "Single",
14
"transaction_index": 129,
15
"log_index": 415
16
}
17
]
Copied!

getTokenIdMetadata

Returns data, including fully resolved metadata for the given token id of the given contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value is decimal.
  • address(required): Address of the contract
  • token_id (required): The id of the token
1
const options = { address: "0xd...07", token_id: "1", chain: "bsc" };
2
const tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(options);
Copied!

Example result:

1
{
2
"token_address": "0xdf7952b35f24acf7fc0487d01c8d5690a60dba07",
3
"token_id": "222",
4
"contract_type": "ERC721",
5
"token_uri": "ipfs://QmYu9WwPNKNSZQiTCDfRk7aCR472GURavR9M1qosDmqpev/sparkle.json",
6
"metadata": "{\n \"name\": \"Sparkle\",\n \"description\": \"It’s sparkling syrup, pancakes, and even lottery tickets! This bunny really loves it.\",\n \"image\": \"ipfs://QmXdHqg3nywpNJWDevJQPtkz93vpfoHcZWQovFz2nmtPf5/sparkle.png\",\n \"attributes\": {\n \"bunnyId\": \"4\"\n }\n}",
7
"synced_at": "2021-08-19T10:49:00.324Z",
8
"amount": "1",
9
"name": "Pancake Bunnies",
10
"symbol": "PB"
11
}
Copied!

getTokenIdOwners

Returns an object with number of NFT transfers and an array with all owners of NFT items within a given contract collection (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value is decimal
  • offset (optional): offset.
  • limit(optional): limit.
  • address(required): Address of the contract.
  • token_id(requierd): The id of the token.
1
const options = { address: "0xd...07", token_id: "1", chain: "bsc" };
2
const tokenIdOwners= await Moralis.Web3API.token.getTokenIdOwners(options);
Copied!

Example result:

1
[
2
{
3
"token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
"token_id": "15",
5
"contract_type": "ERC721",
6
"owner_of": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
7
"block_number": "88256",
8
"block_number_minted": "88256",
9
"token_uri": "string",
10
"metadata": "string",
11
"synced_at": "string",
12
"amount": "1",
13
"name": "CryptoKitties",
14
"symbol": "RARI"
15
}
16
]
Copied!

getWalletTokenIdTransfers

Returns an object with number of NFT transfers and an array with all transfers of NFT by token id (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value is decimal
  • offset (optional): offset.
  • limit(optional): limit.
  • address(required): Address of the contract.
  • token_id(requierd): The id of the token.
1
const options = { address: "0xd...07", token_id: "1", chain: "bsc" };
2
const transfers = await Moralis.Web3API.token.getWalletTokenIdTransfers(options);
Copied!

Example result:

1
[
2
{
3
"token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
"token_id": "15",
5
"from_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
6
"to_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
7
"amount": "1",
8
"contract_type": "ERC721",
9
"block_number": "88256",
10
"block_timestamp": "2021-06-04T16:00:15",
11
"block_hash": "string",
12
"transaction_hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
13
"transaction_type": "string",
14
"transaction_index": "string",
15
"log_index": 0
16
}
17
]
Copied!

πŸ”₯ getNFTTrades

Returns an object with NFT trades for a given contract and marketplace

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • from_date (optional): The date from where to get the trades(any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_date (optional): Get the trades to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • from_block (optional): The minimum block number from where to get the tradesProvide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_block (optional): The maximum block number from where to get the trades. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • offset(optional): Offset.
  • limit(optional): Limit.
  • marketplace (optional): Marketplace from where to get the trades (only opensea is supported at the moment).
  • address (required): Address of the contract(i.e. 0x1a2b3x...).
1
const options = { address: "0xd...07", limit: "10", chain: "bsc" };
2
const NFTTrades = await Moralis.Web3API.token.getNFTTrades(options);
Copied!

Example result:

1
[
2
{
3
"transaction_hash": "0x4de0bcef1450492bd5c2e7693cf644c40005868d0dcc8a7a50a80ef2efa88d1e",
4
"transaction_index": "164",
5
"token_ids": [
6
"16404"
7
],
8
"seller_address": "0xbae90f486d751f133702655627ce599249cd26b8",
9
"buyer_address": "0x8795e90de359c1e0bf2579646486f7f12f270d2f",
10
"token_address": "0xdf7952b35f24acf7fc0487d01c8d5690a60dba07",
11
"marketplace_address": "0x7be8076f4ea4a4ad08075c2508e481d6c946d12b",
12
"price": "280000000000000000",
13
"price_token_address": null,
14
"block_timestamp": "2021-05-09T23:00:25.000Z",
15
"block_number": "7281522",
16
"block_hash": "0xe870c197b0c614e055f4de5b264bc7c69eafc93a6d0ce300309de444b2ff7e3a"
17
},
18
19
]
Copied!

πŸ”₯ getNFTLowestPrice

Returns an object with the lowest price found for a NFT token contract for the last x days (only trades paid in ETH)

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • days (optional): The number of days to look back to find the lowest price If not provided 7 days will be the default
  • marketplace (optional): Marketplace from where to get the trades (only opensea is supported at the moment).
  • address (required): Address of the contract(i.e. 0x1a2b3x...).
1
const options = { address: "0xd...07", days: "3" };
2
const NFTLowestPrice = await Moralis.Web3API.token.getNFTLowestPrice(options);
Copied!

Example result:

1
[
2
{
3
"token_ids": [
4
"15",
5
"54"
6
],
7
"from_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
8
"to_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
9
"value": "1000000000000000",
10
"gas": "6721975",
11
"gas_price": "20000000000",
12
"receipt_cumulative_gas_used": "1340925",
13
"receipt_gas_used": "1340925",
14
"block_number": "88256",
15
"block_timestamp": "2021-06-04T16:00:15",
16
"transaction_hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
17
"transaction_index": "string"
18
}
19
]
Copied!
Last modified 1mo ago