Links

Covalent indexing and querying API

Introduction

Covalent provides a unified API to bring full transparency and visibility to assets across all blockchains including Fantom's Mainnet and Testnet.
To get started, sign up for an API Key.
CSV support
JSON support
The Covalent API is RESTful and offers the following out-of-the-box for Fantom:
Covalent API
Response formats
JSON and CSV
Real time response
2 blocks
Batch response
30 minutes
Request volume limit
None
Request rate limit
5 requests per second
Base URL
Networks & chain_id
Mainnet - 250 Testnet - 4002
Supported Endpoints
Try the supported endpoints directly in your browser from our API Reference or use the following code examples. The JSON response format is the same for all endpoints:
"data": ...,
"error": false,
"error_message": null,
"error_code": null

Curl

curl -X GET "https://api.covalenthq.com/v1/{chain_id}/address/{address}/balances_v2/?key={YOUR API KEY}" -H "Accept: application/json"

JavaScript

const APIKEY = 'YOUR API KEY';
const baseURL = 'https://api.covalenthq.com/v1'
const fantomChainId = '250'
const demoAddress = '0xFEC4f9D5B322Aa834056E85946A32c35A3f5aDD8'
async function getWalletBalance(chainId, address) {
const url = new URL(`${baseURL}/${chainId}/address/${address}/balances_v2/?key=${APIKEY}`);
const response = await fetch(url);
const result = await response.json();
const data = result.data;
console.log(data)
return data;
}
// Example address request
getWalletBalance(fantomChainId, demoAddress);

Python

import requests
API_KEY = 'YOUR API KEY'
base_url = 'https://api.covalenthq.com/v1'
fantom_chain_id = '250'
demo_address = '0xFEC4f9D5B322Aa834056E85946A32c35A3f5aDD8'
def get_wallet_balance(chain_id, address):
endpoint = f'/{chain_id}/address/{address}/balances_v2/?key={API_KEY}'
url = base_url + endpoint
result = requests.get(url).json()
data = result["data"]
print(data)
return(data)
# Example address request
get_wallet_balance(fantom_chain_id, demo_address)

Use Cases

The Covalent API supports a broad range of Web3 data use cases including:
Gaming
DeFi Taxes
KYC
NFTs
Wallets
Dashboards
On-Chain Forensics
DAO Data
DEXs & Trading
Predictive Analytics
Governance
Pricing
Check out our collection of ready-to-ship Code Templates you can use immediately to build Web3 data-powered dApps.

Resources

Here are some additional resources to help you get started with the Covalent API:

About Covalent

Covalent provides the industry-leading Unified API bringing visibility to billions of Web3 data points. Developers use Covalent to build exciting multi-chain applications like crypto wallets, NFT galleries, and investor dashboard tools utilizing data from most major blockchains. Covalent is trusted by a community of 15,000+ developers and powers data for hundreds of applications including 0x, Zerion, Rainbow Wallet, Rotki, Bitski and others.

Appendix

Fantom token

The Fantom token FTM is the native token of Fantom. This is similar to Ether in Ethereum. To interact with the Fantom network, FTM tokens are required to pay gas fees. The Covalent API response returns gas_* fields in fiat units.

Token mapping

Covalent maintains an on-chain real-time mapping of token addresses between Ethereum mainnet and the Fantom chain. These addresses are used to reverse-lookup prices on Fantom and also to return the right token logo urls.
Some example of mapped tokens:
Token
Ethereum mainnet
Fantom mainnet
USDT
0xdac17f958d2ee523a2206206994597c13d831ec7
0x1ffbd1e3584f139ca42d77ef99ef99550ecf46a8
YFI
0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e
0xc396b190f251d7f79c583fd06347a09781f085c9
For the current token mapping list, see: https://netapi.anyswap.net/bridge/v2/info

Token prices

For tokens that have a mapping back to Ethereum mainnet, Covalent is able to return the mapped prices.