The Blockchain API

About

Our vision is to make it super easy to interact with the decentralized web. We want you to be able to do this in any coding language and do it easily and quickly.

You're a key part of our vision. We love feature requests! Make one!

How to Use the API

To use the API, you simply need to create an API key pair.

Doing so takes less than a minute. Simply go to the dashboard, create an account, and generate a key pair. You can now use this pair to make API requests. You must create your first pair via the dashboard.

Feature Requests

Got a feature request? Submit it as an issue on our GitHub repo or email us.

Security

Common dogma is to never give out your seed phrase. We agree. It's a matter of security, and anyone who has your seed phrase can irreversibly empty your wallet.

When using an API endpoint that requires a seed phrase, we highly recommend that users use or create a wallet that they do not use as their primary wallet.

How you make this work depends on what you're doing. If you're minting an NFT for example, we recommend creating a new wallet and then transferring just enough SOL to that wallet to mint the NFT. This is possible on Solana because such transactions cost less than a penny. We will have more tutorials in the future that make it easier for you to be secure when using our API.

We have easy-to-use endpoints for creating a new seed phrase and then deriving a public key to enable you to transfer to that new wallet.

Let's have a constructive dialog about this. Feel free to contact us. I made a video discussing this matter here.

Note: We have had a couple of individuals harrass and threaten us. These individuals did not try our API or speak to anyone who has used it. They simply saw that we require a seed phrase for certain endpoints and figured that the proper response was to attack us. (I explain why we do here.) Such harrassment and threats are not only harmful, but they are also illegal, and we will report offenders. Do not harrass us. Rather, feel free to discuss your concerns with us and we will be more than happy to work with you to come up with a solution.

Pricing

Each user receives 50,000 free credits each month. Each endpoint costs a certain amount credits. Scroll below to any endpoint (i.e., function) to see how much each endpoint costs. (Or CMD+F Cost: 0 Credit, for example)

You can learn more about our pricing here.

We frequently do custom plans. If our pricing doesn't work for you, contact us.

If you have questions, concerns, feedback, or ideas, contact us.

SDKs / API Wrappers

We have examples using both our Python wrapper and our JavaScript wrapper here.

We have built a custom Python wrapper.

pip install theblockchainapi

We also have published a JavaScript Wrapper.

npm install theblockchainapi

We also have auto-generated wrappers for the following languages:

If you would like a different language as well, submit an issue here.

If you run into any bugs with the wrappers, submit an issue here.

Authentication

APIKeyID

Get a free API key pair here.

Security Scheme TypeAPI Key
Header parameter name:APIKeyID

APISecretKey

Get a free API key pair here.

Security Scheme TypeAPI Key
Header parameter name:APISecretKey

Wallet

Functions for using wallets, supported across several chains.

Generate seed phrase

See examples (Python, JavaScript).

Use this endpoint to securely and randomly generate a seed phrase for a wallet.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "avalanche" "binance_smart_chain" "ethereum" "near" "solana"

The blockchain you want to use

Request Body schema: application/json
n_words
number

The number of words to generate. Must be one of: 12, 15, 18, 21, or 24. Avalanche's default is 24. All other chains we support default to 12.

Responses

Request samples

Content type
application/json
{
  • "n_words": 12
}

Response samples

Content type
application/json
{
  • "secret_recovery_phrase": "fire owner display success half rescue pledge oval foam gossip window once"
}

Generate private key

See examples (Python, JavaScript).

Use this endpoint to securely and randomly generate a private key for a wallet.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "avalanche" "binance_smart_chain" "ethereum" "near" "solana"

The blockchain you want to use

Responses

Response samples

Content type
application/json
Example
{
  • "hex_private_key": "0x200b9e5baa38b0dc7551645be11b394e9bf2b04532e4af8824bed2b3de2e0dc0"
}

Derive private key

See examples (Python, JavaScript).

Use this endpoint to securely derive a private key for a wallet.

For example, if you have a seed phrase and want to derive the corresponding private key, use this endpoint.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "avalanche" "binance_smart_chain" "ethereum" "near" "solana"

The blockchain you want to use

Request Body schema: application/json
required
GeneralSecretRecoveryPhrase (object) or HexPrivateKey (object) or GeneralPrivateKey (object) or GeneralB58PrivateKey (object) (GeneralWallet)

The wallet authentication information used to sign and submit the transaction. Click the > arrow next to "wallet" on the left to see more details. See our Security section here.

Responses

Request samples

Content type
application/json
{
  • "wallet": {
    }
}

Response samples

Content type
application/json
Example
{
  • "hex_private_key": "0x200b9e5baa38b0dc7551645be11b394e9bf2b04532e4af8824bed2b3de2e0dc0"
}

Derive wallet identifier

See examples (Python, JavaScript).

Derive the identifier for a wallet.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "avalanche" "binance_smart_chain" "ethereum" "near" "solana"

The blockchain you want to use

Request Body schema: application/json
required
GeneralSecretRecoveryPhrase (object) or HexPrivateKey (object) or GeneralPrivateKey (object) or GeneralB58PrivateKey (object) (GeneralWallet)

The wallet authentication information used to sign and submit the transaction. Click the > arrow next to "wallet" on the left to see more details. See our Security section here.

Responses

Request samples

Content type
application/json
{
  • "wallet": {
    }
}

Response samples

Content type
application/json
Example
{
  • "hex_public_address": "0xB2b2d42C3adA171633E36b427F062f85A642F453",
  • "hex_public_key": "0x0f7182c2c2f79aca13847bed68c67662c021df868ee5d20a78df6095e4cd162610c63ec9050989a3755a18255cdd707e50678bfd762db3f0feea647610e974c4"
}

Get wallet's balance of X

See examples (Python, JavaScript).

See the balance of a wallet in the native blockchain currency (e.g., ETH, SOL) or any token (e.g., ERC-20, NFTs, SPL, etc.).

To get the balance of a specific token, supply the token_blockchain_identifier of the token.

You can also use this endpoint to see whether or not a person owns an NFT. Just supply the token_blockchain_identifier of the NFT. A balance of "1" means the person owns the NFT, and a balance of "0" means the person does not own the NFT.

Cost: 0.25 Credit (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "ethereum" "solana"

The blockchain you want to use

Request Body schema: application/json
blockchain_identifier
string

The address / public key of the wallet you're querying.

Examples:

  • Solana: GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ
  • Ethereum: 0xa84b9478d203cd25dF722e83C87590f8028f6aAA
unit
string

The unit parameter is only applicable if you are trying to retrieve the balance of the native token (e.g., SOL, ETH, BNB).

Applicable units:

  • Solana: lamport, sol (1 SOL = 1e9 Lamports)
  • Ethereum: wei, gwei, eth
network
string

The network of the blockchain you selected

  • Solana: devnet, mainnet-beta
  • Ethereum: ropsten, mainnet

Defaults when not provided (not applicable to path parameters):

  • Solana: devnet
  • Ethereum: ropsten
token_blockchain_identifier
string
Default: null

The token_blockchain_identifier identifies the token you wish to transfer.

  • If you're transferring a native blockchain currency (e.g., SOL, ETH, BNB), then simply do not supply this value.
  • If you're transfering an NFT, then supply the token address of the NFT. On Solana, this is the mint_address or mint (the address of the mint).
  • If you're transfering a token, supply the token address. For Solana, you can find on this on the Solana Explorer (e.g., see SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt for Serum Token) for the token_address.

Examples:

  • Ethereum: 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
  • Solana: CK1LHEANTu7RFqN3XMzo2AnZhyus2W1vue1njrxLEM1d

Responses

Request samples

Content type
application/json
{
  • "blockchain_identifier": "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ",
  • "network": "mainnet-beta",
  • "token_blockchain_identifier": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
}

Response samples

Content type
application/json
{
  • "balance": 3.322105,
  • "decimals": 6,
  • "integer_balance": 3322105,
  • "network": "mainnet-beta"
}

Get an airdrop

See examples (Python, JavaScript).

  • Ethereum: Receive an airdrop of 0.001 ETH on Ropsten (not real ETH).
  • Solana: Use this endpoint to get an airdrop of SOL on the devnet (not real SOL). Amount of 0.015, which is the minimum amount of SOL you need to mint an NFT and then transfer it to another wallet.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "ethereum" "solana"

The blockchain you want to use

Request Body schema: application/json
recipient_blockchain_identifier
required
string

The address/public key to which to send the airdrop.

Examples:

  • Solana: GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ
  • Ethereum: 0xa84b9478d203cd25dF722e83C87590f8028f6aAA

Responses

Request samples

Content type
application/json
{
  • "recipient_blockchain_identifier": "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ"
}

Response samples

Content type
application/json
Example
{
  • "transaction_blockchain_identifier": "38jivwh89t38hkN4dS2M585NZFRHbsGfmnuFb2MVDwrfTXdvYBamQPRo7QQNGdx8mfYahfkUV6s822nH3K7ej5nj",
  • "transaction_confirmed": true
}

Transfer crypto, a token, or an NFT to another wallet

See transfer ETH/SOL/crypto example (Python, JavaScript).

See transfer NFT/token example (Python, JavaScript).

This is a powerful function. It might be slightly confusing because there are several optional parameters, so take some time to review it.

This function can send

  • The native currency of the selected blockchain (e.g., SOL, ETH, BNB, etc.)
  • A token (e.g., an SPL token, ERC-20 token, etc.)
  • An NFT

You can sign and submit the transaction for confirmation; and you can select to simply return the compiled transaction so that you can submit it to the user for signing (e.g., via Phantom or Metamask; no private keys required in this case).

If you're transferring an NFT or a token, supply its respective token_blockchain_identifier.

SENDER: Note that the wallet information is used to authorize the sending of the tokens and identifies the source of the tokens. If return_compiled_transaction = false, we sign and submit the transaction (wallet is required in this case; do not provide a value for sender_blockchain_identifier). If return_compiled_transaction = true, we compile the transaction (sender_blockchain_identifier is required in this case; do not provide wallet).

RECIPIENT: recipient_blockchain_identifier identifies the receiver. This is entirely separate from the information used for the SENDER above. So, in this API call, there are two wallets involved, but only one (namely, the SENDER) is needed to authorize the transaction (if you want us to sign and submitting it).

FEE_PAYER (Solana only): The fee payer of the transaction defaults to wallet (or sender_blockchain_identifier). To set a different fee payer, provide a value for fee_payer_wallet.

Cost: 2 Credit (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "ethereum" "solana"

The blockchain you want to use

Request Body schema: application/json
recipient_blockchain_identifier
required
string

The blockchain identifier of the recipient to whom you want to send a token or NFT.

On Ethereum, this is the hex public address of the recipient (e.g., 0x150865ca659204a9a0cd0da00296c6b5db441172)

On Solana, this is the public key of the recipient (e.g., EW3nXn7X4NTWFKWaJgxKrFNoTSkop1cBUVHA21zrfF6u).

GeneralSecretRecoveryPhrase (object) or HexPrivateKey (object) or GeneralPrivateKey (object) or GeneralB58PrivateKey (object) (GeneralWallet)

The wallet authentication information used to sign and submit the transaction. Click the > arrow next to "wallet" on the left to see more details. See our Security section here.

token_blockchain_identifier
string

The token_blockchain_identifier identifies the token you wish to transfer.

  • If you're transferring a native blockchain currency (e.g., SOL, ETH, BNB), then simply do not supply this value.
  • If you're transfering an NFT, then supply the token address of the NFT. On Solana, this is the mint_address or mint (the address of the mint).
  • If you're transfering a token, supply the token address. For Solana, you can find on this on the Solana Explorer (e.g., see SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt for Serum Token) for the token_address.

Examples:

  • Ethereum: 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
  • Solana: CK1LHEANTu7RFqN3XMzo2AnZhyus2W1vue1njrxLEM1d
network
string

The network of the blockchain you selected

  • Solana: devnet, mainnet-beta
  • Ethereum: ropsten, mainnet

Defaults when not provided (not applicable to path parameters):

  • Solana: devnet
  • Ethereum: ropsten
amount
string
Default: "1"

This value must be a string. What you provide here depends on if you are sending an NFT, an SPL token, or SOL.

  • Native Currency (e.g., SOL, ETH, BNB): Supply this value denominated in the native currency (e.g., in SOL (but not in Lamports), or in ETH (but not in Wei)) in a string format. This does not need to be an integer. For example, if you want to send 0.0005 SOL, then amount = "0.0005". If you want to send 0.0005 ETH, then amount = "0.0005".
  • NFT: This must be 1.
  • Token: This must be an integer in string format. To convert from what you see on a wallet UI (e.g., 1 ATLAS, 1 USDC) to an integer value, you have to multiply that value by 10^x where x is the number of decimals. For example, to transfer 0.2 USDC, if USDC uses 6 decimals, then the amount is 0.2 * 10^6 = 200000.
    • For Solana, you can get the number of decimals for a given SPL token here. We are working on analogues of this endpoint for other blockchains.
return_compiled_transaction
boolean
Default: false
  • If false, we sign and submit the transaction (wallet is required in this case; do not provide a value for sender_blockchain_identifier).
  • If true, we compile the transaction (either wallet or sender_blockchain_identifier is required in this case; do not provide both).
sender_blockchain_identifier
string
Default: null

To understand the purpose of sender_blockchain_identifier first note the following: There are two ways you can complete a transfer transaction:

  • (1) we complete it for you with your wallet information or
  • (2) we return the raw instruction data that you can sign and submit yourself (no private keys required).

When you provide your wallet authentication, we are able to determine your wallet's blockchain identifier (public key or address) which is the sender public key of the transaction.

When you are not providing your wallet as authentication, we still need the sender_blockchain_identifier to be able to return the compiled transaction. Thus, you provide sender_blockchain_identifier if and only if you are not providing wallet authentication information and you are returning a compiled transaction.

You will receive an error if you provide both wallet and sender_blockchain_identifier. You will receive an error if you provide neither wallet nor sender_blockchain_identifier.

GeneralSecretRecoveryPhrase (object) or HexPrivateKey (object) or GeneralPrivateKey (object) or GeneralB58PrivateKey (object) (GeneralFeePayerWallet)

This feature is only supported for solana.

If you do NOT provide a wallet here, the fee payer of the transaction will be the wallet you provide or the sender_blockchain_identifier.

If you do provide a wallet, then the fee_payer_wallet will pay the fees of the transaction and any costs associated with creating a new associated token account (only if necessary; approx. 0.002 SOL when necessary). A new account is necessary if you are sending an NFT or SPL token to a user that has not received the same NFT or one of the SPL tokens before (thus, a new associated token account is needed).

Responses

Request samples

Content type
application/json
{
  • "wallet": {
    },
  • "token_blockchain_identifier": "CK1LHEANTu7RFqN3XMzo2AnZhyus2W1vue1njrxLEM1d"
}

Response samples

Content type
application/json
Example
{
  • "transaction_blockchain_identifier": "38jivwh89t38hkN4dS2M585NZFRHbsGfmnuFb2MVDwrfTXdvYBamQPRo7QQNGdx8mfYahfkUV6s822nH3K7ej5nj",
  • "transaction_confirmed": true
}

Transaction

Functions for interacting with transactions, supported across several chains.

Get the details of a transaction made on a blockchain

See examples (Python, JavaScript).

Get the details of a transaction made on the specified blockchain.

Cost: 0.25 Credit (See Pricing)

Authorizations:
path Parameters
blockchain
required
string
Enum: "ethereum" "solana"

The blockchain you want to use

network
required
string
Example: ropsten

The network of the blockchain you selected

  • Solana: devnet, mainnet-beta
  • Ethereum: ropsten, mainnet

Defaults when not provided (not applicable to path parameters):

  • Solana: devnet
  • Ethereum: ropsten
transaction_blockchain_identifier
required
string
Example: 0x5f36b787daa57bfe8568d69e24eae54ccb00720c6edfc826bd4a7b19c525eef4

The transaction signature of the transaction