How To Access Avalanche API

Learn how to access Avalanche API.

Step 1: To access the available Avalanche methods, use the following native access endpoint:

  • Network: Avalanche Mainnet
  • Request Type: POST
https://svc.blockdaemon.com/avalanche/mainnet/native/PATH_PARAMETER
  • Network: Avalanche Testnet
  • Request Type: POST
https://svc.blockdaemon.com/avalanche/testnet/native/PATH_PARAMETER

Depending on the method, add one of the following path parameters at the end:

MethodPath parameter
Ethereum C-Chainext/bc/c/eth
Avalanche C-Chain (AVAX)ext/bc/c/avax
Avalanche P-Chain (AVAX)ext/bc/p
Avalanche Healthext/health
Avalanche Infoext/info

Step 2: You should authorize your request. Learn more: Authentication Guide

Step 3: Specify an Avalanche method in the request body:

{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "YOUR_METHOD",
    "params": []
}

Example Requests

Example 1: Ethereum C-Chain Methods

Here is a cURL example for using eth_blockNumber to get the current block number in Avalanche Mainnet:

curl -X \
POST https://svc.blockdaemon.com/avalanche/mainnet/native/ext/bc/c/eth \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}'

The following is a typical response you will get:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x1335404"
}

Example 2: Avalanche C-Chain (AVAX) Methods

Here is a cURL example for using avax.getUTXOs to get the UTXOs that reference a given address in Avalanche Mainnet:

curl -X \
POST https://svc.blockdaemon.com/avalanche/mainnet/native/ext/bc/c/avax \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"jsonrpc": "2.0", "id": 1, "method": "avax.getUTXOs", "params": {"addresses": ["C-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], "sourceChain": "X"}}'

The following is a typical response you will get:

{
    "jsonrpc": "2.0",
    "result": {
        "numFetched": "0",
        "utxos": [],
        "endIndex": {
            "address": "C-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
            "utxo": "11111111111111111111111111111111LpoYY"
        },
        "encoding": "hex"
    },
    "id": 1
}

Example 3: Avalanche P-Chain (AVAX) Methods

Here is a cURL example for using platform.getBlockchainStatus to get the status of a blockchain in Avalanche Mainnet:

curl -X \
POST https://svc.blockdaemon.com/avalanche/mainnet/native/ext/bc/p \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"jsonrpc": "2.0", "id": 1, "method": "platform.getBlockchainStatus", "params": []}'

The following is a typical response you will get:

{
  "jsonrpc": "2.0",
  "result": {
    "status": "Created"
  },
  "id": 1
}

Example 4: Avalanche Health Methods

Here is a cURL example for using health.health to get the last set of health check results in Avalanche Mainnet:

curl -X \
POST https://svc.blockdaemon.com/avalanche/mainnet/native/ext/health \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"jsonrpc": "2.0", "id": 1, "method": "health.health", "params": []}'

The following is a typical response you will get:

{
    "jsonrpc": "2.0",
    "result": {
        "checks": {
            "C": {
                "message": {
                    "consensus": {
                        "longestRunningBlock": "51.804748ms",
                        "outstandingBlocks": 1
                    },
                    "vm": null
                },
                "timestamp": "2022-09-22T16:00:01.043148255Z",
                "duration": 7344
            },
            {...more items...}
        },
        "healthy": true
    },
    "id": 1
}

Example 5: Avalanche Info Methods

Here is a cURL example for using info.getTxFee to get the fees of the Avalanche Mainnet:

curl -X \
POST https://svc.blockdaemon.com/avalanche/mainnet/native/ext/info \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"jsonrpc": "2.0", "id": 1, "method": "info.getTxFee", "params": []}'

The following is a typical response you will get:

{
    "jsonrpc": "2.0",
    "result": {
        "txFee": "1000000",
        "creationTxFee": "10000000",
        "createAssetTxFee": "10000000",
        "createSubnetTxFee": "1000000000",
        "transformSubnetTxFee": "1000000000",
        "createBlockchainTxFee": "1000000000",
        "addPrimaryNetworkValidatorFee": "0",
        "addPrimaryNetworkDelegatorFee": "0",
        "addSubnetValidatorFee": "1000000",
        "addSubnetDelegatorFee": "1000000"
    },
    "id": 1
}

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.