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

Solana Wallet

A wallet consists of two things: a public key and a secret recovery phrase pair. To create a wallet, you must first create a secret recovery phrase. Then, you can generate many public keys from a secret recovery phrase.

Generate secret phrase

See examples (Python, JavaScript).

Use this endpoint to securely and randomly generate a secret recovery phrase for a Solana wallet.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:

Responses

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 Solana wallet.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:

Responses

Response samples

Content type
application/json
{
  • "b58_private_key": "5UNBwP7bYMRZZeT5sENFZFaTQxwPFFhLsCKZVgicNDpB6uceSAS1qtfzGfQmAmPzM7Nf8P3b3sk2QUntY7huHhqS",
  • "private_key": [
    ]
}

Derive private key

See examples (Python, JavaScript).

Returns a private key array and a base58-encoded private key given wallet authentication.

A wallet is defined by a public key. A public key is derived from a combination of seed phrase, derivation path, and passphrase. Changing any one of these three will change the public key output.

You can generate a unique public key with each combination of secret recovery phrase, passphrase, and derivation path. Thus, with a single secret recovery phrase, you can generate many public keys. If you are just starting, just supply the secret recovery phrase you generated with the Solana Wallet Secret Recovery Phrase endpoint.

If you are trying to get a public key that already exists (e.g., created in the Phantom wallet), make sure you use the correct derivation path and passphrase. To read more about that, see the descriptions of those parameters below.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
Request Body schema: application/json
required
SecretRecoveryPhrase (object) or PrivateKey (object) or B58PrivateKey (object) (Wallet)

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
{
  • "b58_private_key": "5UNBwP7bYMRZZeT5sENFZFaTQxwPFFhLsCKZVgicNDpB6uceSAS1qtfzGfQmAmPzM7Nf8P3b3sk2QUntY7huHhqS",
  • "private_key": [
    ]
}

Derive public key

See examples (Python, JavaScript).

Returns a public key given wallet authentication.

A wallet is identified by a public key. A public key is derived from a combination of seed phrase, derivation path, and passphrase. Changing any one of these three will change the public key output.

It can also be derived from a private key.

*You can generate a unique public key with each combination of secret recovery phrase, passphrase, and derivation path; or from a private key. Thus, with a single secret recovery phrase, you can generate many public keys; however, with a private key, you can only generate one public key. If you are just starting, generate a secret recovery phrase or private key.

If you are trying to get a public key that already exists (e.g., created in the Phantom wallet), make sure you use the correct derivation path and passphrase; or just use the private key. To read more about that, see the descriptions of those parameters below.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
Request Body schema: application/json
required
SecretRecoveryPhrase (object) or PrivateKey (object) or B58PrivateKey (object) (Wallet)

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
{
  • "public_key": "GoUhxkKRiy8psWcr1csF1mbuDsfNd28JZXNHMQ5BSBnc"
}

Transfer SOL, a token, or an NFT to another address

See transfer SOL example (Python, JavaScript).

See transfer NFT example (can also be used for SPL token) (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 SOL, send an SPL token, or send an NFT. You can set the fee payer of the transaction; 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; no private keys required in this case).

Transfer SOL, a token or an NFT to another address. If you're transferring an NFT, supply the mint (the address of the mint) for the token_address.

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_public_key). If return_compiled_transaction = true, we compile the transaction (one of wallet or sender_public_key is required in this case; do not provide both).

RECIPIENT: recipient_address 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.

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

If you're transfering a token, supply the token address found on the explorer (e.g., see SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt for Serum Token) for the token_address. If you're transferring SOL, do not supply a value for token_address.

Cost: 2 Credit (See Pricing)

Authorizations:
Request Body schema: application/json
wait_for_confirmation
boolean
Default: true

Whether to wait for the transaction to be confirmed on the blockchain or simply be processed. Processed means that our node has picked up the transaction request, but not that it was confirmed by the Solana cluster. Confirmed means that the cluster voted on your transaction and approved it. To be completely sure that the transaction succeeded, you can either set wait_for_confirmation=True (call takes 20 seconds with True; about 4 seconds for processed) or you can get the transaction metadata using the signature in the response returned. Once it returns the metadata, then the transaction should have succeeded.

recipient_address
required
string

The public key address of the recipient to whom you want to send a token or NFT

SecretRecoveryPhrase (object) or PrivateKey (object) or B58PrivateKey (object) (Wallet)

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_address
string

If you're transfering an NFT, supply the mint (the address of the mint) for the token_address. If you're transfering a token, supply the token address found on the explorer (e.g., see SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt for Serum Token) for the token_address. If you're transferring SOL, do not supply a value for token_address.

network
string
Default: "devnet"
Enum: "devnet" "mainnet-beta"
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.

  • NFT: This must be '1'.
  • SPL 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. You can get the number of decimals for a given SPL token here.
  • SOL: Supply this value denominated in SOL 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".
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_public_key). If true, we compile the transaction (either wallet or sender_public_key is required in this case; do not provide both).

sender_public_key
string
Default: null

To understand the purpose of sender_public_key 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 public key, which is the sender public key of the transaction. When you are not providing your wallet as authentication, we still need the sender_public_key to be able to return the compiled transaction. Thus, you provide sender_public_key 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_public_key. You will receive an error if you provide neither wallet nor sender_public_key.

SecretRecoveryPhrase (object) or PrivateKey (object) or B58PrivateKey (object) (FeePayerWallet)

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

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_address": "CK1LHEANTu7RFqN3XMzo2AnZhyus2W1vue1njrxLEM1d"
}

Response samples

Content type
application/json
Example
{
  • "transaction_signature": "38jivwh89t38hkN4dS2M585NZFRHbsGfmnuFb2MVDwrfTXdvYBamQPRo7QQNGdx8mfYahfkUV6s822nH3K7ej5nj",
  • "confirmed": true
}

Derive an associated token account address

See example (Python, JavaScript).

Each wallet can own tokens, but in Solana, each token is actually held by an associated token account (ATA), which is an account specific for a token owned by the wallet. When you transfer an SPL token, such as Serum, or transfer an NFT, you're transfering from an ATA you own to another person's ATA for that specific token. With this endpoint, you can derive an associated token address given a wallet and a token address.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
path Parameters
public_key
required
string
Example: 31LKs39pjT5oj6fWjC3F76dHWf9489asCthmgj8wu7pj

The public key of the wallet

mint_address
required
string
Example: 7EWJNaNYfPYMaqzdAAa4ps5kpqW95B7VHsjhW1kr18sj

The mint address of the token (either SPL or NFT)

Responses

Response samples

Content type
application/json
{
  • "associated_token_address": "CnW7tnQrfbSMkHYpvn5mtYw11qGpat6WM87D68cNT2hC"
}

Get an airdrop on devnet

See examples (Python, JavaScript).

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 a Metaplex NFT and then transfer it to another wallet.

Cost: 0 Credit (Free) (See Pricing)

Authorizations:
Request Body schema: application/json
recipient_address
required
string

The address to which to send the airdrop of 0.015 SOL

Responses

Request samples

Content type
application/json
{
  • "recipient_address": "string"
}

Response samples

Content type
application/json
{
  • "transaction_signature": "38jivwh89t38hkN4dS2M585NZFRHbsGfmnuFb2MVDwrfTXdvYBamQPRo7QQNGdx8mfYahfkUV6s822nH3K7ej5nj",
  • "confirmed": true
}

Get wallet's balance in SOL or any SPL

See examples (Python, JavaScript).

See the balance of a wallet in SOL or any SPL token.

To get the balance of an SPL token, supply the mint_address of the SPL token. The list of SPL tokens can be viewed here.

You can also use this endpoint to see whether or not a person owns an NFT. Just supply the mint_address 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. This works in most cases, but we are aware of one edge case where a balance of "0" will show up for a person who is actually the owner of the NFT. We just recommend using the getNFTOwner endpoint and comparing that output to the expected address.

Cost: 0.25 Credit (See Pricing)

Authorizations:
Request Body schema: application/json
public_key
required
string

The public key address of the wallet

unit
string
Default: "lamport"
Enum: "lamport" "sol"

If you are retrieving the SOL balance, you can select whether to retrieve this in SOL or Lamport units (1 SOL = 1e9 Lamports).

network
string
Default: "devnet"
Enum: "devnet" "mainnet-beta"
mint_address
string
Default: null

The mint address of the SPL token or NFT. If not provided, the balance returned is in SOL. Make sure to use the correct network.

You can see the mint addresses of popular SPL tokens here.

Some example mint addresses of SPL tokens:

  • USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
  • Mango: MangoCzJ36AjZyKwVj3VnYU4GTonjfVEnJmvvWaxLac
  • Serum: SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt
  • Raydium: 4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R
  • wSOL: So11111111111111111111111111111111111111112
  • ATLAS: ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx

Responses

Request samples

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

Response samples

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

Get address's tokens and respective balances

See examples (Python, JavaScript).

See the token holdings of a given public key address

Cost: 2 Credits (See Pricing)

Authorizations:
path Parameters
network
required
string
Example: mainnet-beta

The network ID (devnet, mainnet-beta)

public_key
required
string
Example: GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ

The public key of the account whose list of owned NFTs you want to get

<