Moralis-Python-SDK

token API:

evm_api.token


get_multiple_token_prices

evm_api.token.get_multiple_token_prices()

Returns an array of token prices denominated in the blockchain’s native token and USD for a given token contract address

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "chain": "eth", 
    "include": "", 
}
body = {
    "tokens": [{'token_address': '0xdac17f958d2ee523a2206206994597c13d831ec7'}, {'token_address': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'}, {'token_address': '0xae7ab96520de3a18e5e111b5eaab095312d7fe84', 'exchange': 'uniswapv2', 'to_block': '16314545'}, {'token_address': '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0'}], 
}

result = evm_api.token.get_multiple_token_prices(
    api_key=api_key,
    params=params,
    body=body,
)

print(result)

Parameters

Name Type Description Required Default Example
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”
include enum[str]:
- “percent_change”
If the result should contain the 24hr percent change   ”” ””

Body

Object with the properties:

Name Type Description Required Default Example
tokens List of object:
- token_address: str
- exchange: str
- to_block: str
The tokens to be fetched Yes   [{‘token_address’: ‘0xdac17f958d2ee523a2206206994597c13d831ec7’}, {‘token_address’: ‘0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48’}, {‘token_address’: ‘0xae7ab96520de3a18e5e111b5eaab095312d7fe84’, ‘exchange’: ‘uniswapv2’, ‘to_block’: ‘16314545’}, {‘token_address’: ‘0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0’}]

get_token_allowance

evm_api.token.get_token_allowance()

Get the amount which the spender is allowed to withdraw on behalf of the owner.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "", 
    "owner_address": "", 
    "spender_address": "", 
    "chain": "eth", 
}

result = evm_api.token.get_token_allowance(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
address str The address of the token contract Yes   ””
owner_address str The address of the token owner Yes   ””
spender_address str The address of the token spender Yes   ””
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”

get_token_metadata

evm_api.token.get_token_metadata()

Get the metadata for a given token contract address (name, symbol, decimals, logo).

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "addresses": [], 
    "chain": "eth", 
}

result = evm_api.token.get_token_metadata(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
addresses List of str The addresses to get metadata for Yes   []
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”

get_token_metadata_by_symbol

evm_api.token.get_token_metadata_by_symbol()

Get the metadata for a list of token symbols (name, symbol, decimals, logo).

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "symbols": [], 
    "chain": "eth", 
}

result = evm_api.token.get_token_metadata_by_symbol(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
symbols List of str The symbols to get metadata for Yes   []
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”

get_token_owners

evm_api.token.get_token_owners()

Identify the major holders of an ERC20 token and understand their ownership percentages

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "token_address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0", 
    "chain": "eth", 
    "limit": 0, 
    "cursor": "", 
    "order": "DESC", 
}

result = evm_api.token.get_token_owners(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
token_address str The address of the token contract Yes   “0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0”
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”
limit int The desired page size of the result.     0
cursor str The cursor returned in the previous response (used for getting the next page).     ””
order enum[str]:
- “ASC”
- “DESC”
The order of the result, in ascending (ASC) or descending (DESC)   “DESC” “DESC”

get_token_pair_ohlc

evm_api.token.get_token_pair_ohlc()

Get OHLC candle sticks of token pair.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "token0": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", 
    "token1": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", 
    "exchange": "", 
    "interval": "1h", 
    "price_format": "", 
    "from_date": "", 
    "to_date": "", 
    "chain": "eth", 
    "limit": 0, 
    "cursor": "", 
}

result = evm_api.token.get_token_pair_ohlc(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
token0 str The base token address Yes   “0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2”
token1 str The quote token address Yes   “0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48”
exchange str The factory name or address of the token exchange Yes   ””
interval str The interval of the ohlc candles Yes “1h” “1h”
price_format str The price format of the ohlc candles (usd, native) Yes   ””
from_date str The date from where to get the ohlc candles (format in seconds or datestring accepted by momentjs). Yes   ””
to_date str Get ohlc candles up until this date (format in seconds or datestring accepted by momentjs). Yes   ””
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”
limit int The maximum number of ohlc candles to return (max 100)     0
cursor str The cursor returned in the previous response (used for getting the next page).     ””

get_token_price

evm_api.token.get_token_price()

Get the token price denominated in the blockchain’s native token and USD.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0", 
    "chain": "eth", 
    "exchange": "", 
    "to_block": 0, 
    "include": "", 
}

result = evm_api.token.get_token_price(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
address str The address of the token contract Yes   “0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0”
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”
exchange str The factory name or address of the token exchange     ””
to_block int The block number from which the token price should be checked     0
include enum[str]:
- “percent_change”
If the result should contain the 24hr percent change   ”” ””

get_token_stats

evm_api.token.get_token_stats()

Get the stats for a erc20 token

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "", 
    "chain": "eth", 
}

result = evm_api.token.get_token_stats(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
address str The address of the erc20 token Yes   ””
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”

get_token_transfers

evm_api.token.get_token_transfers()

Get ERC20 token transactions from a contract ordered by block number in descending order.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0", 
    "chain": "eth", 
    "from_block": 0, 
    "to_block": 0, 
    "from_date": "", 
    "to_date": "", 
    "limit": 0, 
    "order": "DESC", 
    "cursor": "", 
}

result = evm_api.token.get_token_transfers(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
address str The address of the token contract Yes   “0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0”
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”
from_block int The minimum block number from which to get the transfers
* Provide the param ‘from_block’ or ‘from_date’
* If ‘from_date’ and ‘from_block’ are provided, ‘from_block’ will be used.
    0
to_block int The maximum block number from which to get the transfers.
* Provide the param ‘to_block’ or ‘to_date’
* If ‘to_date’ and ‘to_block’ are provided, ‘to_block’ will be used.
    0
from_date str The start date from which to get the transfers (format in seconds or datestring 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 str Get transfers up until this date (format in seconds or datestring accepted by momentjs)
* Provide the param ‘to_block’ or ‘to_date’
* If ‘to_date’ and ‘to_block’ are provided, ‘to_block’ will be used.
    ””
limit int The desired page size of the result.     0
order enum[str]:
- “ASC”
- “DESC”
The order of the result, in ascending (ASC) or descending (DESC)   “DESC” “DESC”
cursor str The cursor returned in the previous response (used for getting the next page).     ””

get_wallet_token_balances

evm_api.token.get_wallet_token_balances()

Get token balances for a specific wallet address.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", 
    "chain": "eth", 
    "to_block": 1.2, 
    "token_addresses": [], 
    "exclude_spam": True, 
}

result = evm_api.token.get_wallet_token_balances(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
address str The address from which token balances will be checked Yes   “0xd8da6bf26964af9d7eed9e03e53415d37aa96045”
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”
to_block float The block number up to which the balances will be checked.     1.2
token_addresses List of str The addresses to get balances for (optional)     []
exclude_spam bool Exclude spam tokens from the result   True True

get_wallet_token_transfers

evm_api.token.get_wallet_token_transfers()

Get ERC20 token transactions ordered by block number in descending order.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", 
    "chain": "eth", 
    "from_block": 0, 
    "to_block": 0, 
    "from_date": "", 
    "to_date": "", 
    "contract_addresses": [], 
    "limit": 0, 
    "order": "DESC", 
    "cursor": "", 
}

result = evm_api.token.get_wallet_token_transfers(
    api_key=api_key,
    params=params,
)

print(result)

Parameters

Name Type Description Required Default Example
address str The address of the wallet Yes   “0xd8da6bf26964af9d7eed9e03e53415d37aa96045”
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
- “moonbeam”
- “0x504”
- “moonriver”
- “0x505”
- “moonbase”
- “0x507”
The chain to query   “eth” “eth”
from_block int The minimum block number from which to get the transactions
* Provide the param ‘from_block’ or ‘from_date’
* If ‘from_date’ and ‘from_block’ are provided, ‘from_block’ will be used.
    0
to_block int The maximum block number from which to get the transactions.
* Provide the param ‘to_block’ or ‘to_date’
* If ‘to_date’ and ‘to_block’ are provided, ‘to_block’ will be used.
    0
from_date str The start date from which to get the transactions (format in seconds or datestring 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 str Get the transactions up to this date (format in seconds or datestring accepted by momentjs)
* Provide the param ‘to_block’ or ‘to_date’
* If ‘to_date’ and ‘to_block’ are provided, ‘to_block’ will be used.
    ””
contract_addresses List of str List of contract addresses of transfers     []
limit int The desired page size of the result.     0
order enum[str]:
- “ASC”
- “DESC”
The order of the result, in ascending (ASC) or descending (DESC)   “DESC” “DESC”
cursor str The cursor returned in the previous response (used for getting the next page).     ””