BTAChain Developer APIs


BTAchain is the main platform of Bitcoin asset for blockchain explorer, search, API, and analytics.

The Team has developed the "BTAchain Developer APIs" to make developers be empowered with direct access to BTAchain explorer data and services via GET/POST requests.

The main objective of BTAchain's APIs is to make community service and without a warranty, so please use them for what's necessary.

It is required to put on the source attribution via a backlink or at least mention that your app is "powered by BTAchain APIs" except you're on personal/private usage.


API Endpoints

If you are keen on your app to show the user's balance of BTA, Check out the transaction history of a wallet address or acquire information about the new token and its price.

In that case, you will find a suitable endpoint from our range of APIs that you can simply query to provide data while you keep fully focused on your Apps building progress.

BTAchain has set two offers for API plans, a set of free community endpoints and API PRO which consists of additional derived blockchain data.


Tutorial

The amount of data can be really overwhelming to get a proper extraction from the Blockchain.

We've provided you shortlist steps tutorial on how to make it done to query and derive popular blockchain metrics.

For more experienced users, we've provided extra and more advanced guides such as how you might get contracts verified through API calls programmatically and more advanced use cases of endpoints eventually.


Support & FAQ

The shortlist of our support articles is common questions like rate limits, common error messages, and API key usage across different networks.

You may find a unique case or clarification feel free to get in touch with us via our support channels



How to Obtain Historical BTA Balance for a Single Address by BlockNo PRO
                                          https://btachain.com/api
?module=account
&action=balancehistory
&address=0x000000000000000000000000000000000000f000
&blockno=2000
&apikey=YourApiKeyToken

The above API endpoint is throttled to 2 calls/second regardless of API Pro tier.


How to obtain a list of 'Normal' Transactions By Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results


                                          https://btachain.com/api
?module=account
&action=txlist
&address=0x000000000000000000000000000000000000f000
&startblock=1
&endblock=99999999
&sort=asc
&apikey=YourApiKeyToken

(Returned 'isError' values: 0 = No Error, 1 = Got Error)

(Returns up to a maximum of the last 10000 transactions only)

or

                                          https://btachain.com/api
?module=account
&action=txlist&address=0x000000000000000000000000000000000000f000
&startblock=1
&endblock=99999999
&page=1
&offset=10
&sort=asc
&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)


How to Obtain a list of 'Internal' Transactions by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

                                          
                                            https://btachain.com/api
?module=account
&action=txlistinternal
&address=0x000000000000000000000000000000000000f000
&startblock=0
&endblock=2112557
&sort=asc
&apikey=YourApiKeyToken

(Returned 'isError' values: 0 = No Error, 1 = Got Error)

(Returns up to a maximum of the last 10000 transactions only)

or

                                          https://btachain.com/api
?module=account
&action=txlistinternal
&address=0x000000000000000000000000000000000000f000
&startblock=0
&endblock=2112557
&page=1
&offset=10
&sort=asc
&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)


How to obtain 'Internal Transactions' by Transaction Hash

                                          https://btachain.com/api
?module=account
&action=txlistinternal
&txhash=0x4d74a6fc84d57f18b8e1dfa07ee517c4feb296d16a8353ee41adc03669982028
&apikey=YourApiKeyToken

(Returned 'isError' values: 0 = Ok, 1 = Rejected/Cancelled)

(Returns up to a maximum of the last 10000 transactions only)


How to Obtain "Internal Transactions" by Block Range
                                          
                                            https://btachain.com/api
?module=account
&action=txlistinternal
&startblock=0
&endblock=2112557
&page=1
&offset=10
&sort=asc
&apikey=YourApiKeyToken

(Returns up to a maximum of the last 10000 transactions only)



How to Obtain a list of 'BTA-721 Token Transfer Events' by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results


                                          https://btachain.com/api
?module=account
&action=tokennfttx
&address=0xcd4ee0a77e09afa8d5a6518f7cf8539bef684e6c
&startblock=0
&endblock=999999999
&sort=asc

(Returns up to a maximum of the last 10000 transactions only)

or
                                        
                                          https://btachain.com/api
?module=account
&action=tokennfttx
&contractaddress=0x5e74094cd416f55179dbd0e45b1a8ed030e396a1
&page=1
&offset=100
&sort=asc

(To get paginated results use page= and offset=)

or
                                        
                                          https://btachain.com/api
?module=account
&action=tokennfttx
&contractaddress=0x5e74094cd416f55179dbd0e45b1a8ed030e396a1
&address=0xcd4ee0a77e09afa8d5a6518f7cf8539bef684e6c
&page=1
&offset=100
&sort=asc

(To get transfer events for a specific token contract, include the contractaddress parameter)



A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract.

                                                var Web3 = require('web3'); 
var web3 = new Web3(new Web3.providers.HttpProvider());
var version = web3.version.api;

$.getJSON('https://btachain.com/api?module=contract&action=getabi&address=0x000000000000000000000000000000000000f000&apikey=YourApiKeyToken', function (data) {
   var contractABI = "";
   contractABI = JSON.parse(data.result);
   if (contractABI != ''){
      var MyContract = web3.eth.contract(contractABI);
      var myContractInstance = MyContract.at("0x000000000000000000000000000000000000f000");
      var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715");
      console.log("result1 : " + result);
      var result = myContractInstance.members(1);
      console.log("result2 : " + result);
   } else {
      console.log("Error" );
   }
});

How to obtain Contract Source Code for Verified Contract Source Codes

                                          https://btachain.com/api
?module=contract
&action=getsourcecode
&address=0x000000000000000000000000000000000000f000
&apikey=YourApiKeyToken

(replace the address parameter with the actual contract address)

Terms of usage: Please see the usage terms policy


Verify Source Code
  1. Other than valid Btachain API key, it will be rejected

  2. Only 100 submissions per day per user can be done daily (subject to change)

  3. Only supports HTTP POST due to max transfer size limitations for HTTP GET

  4. Supports up to 10 different library pairs

  5. Contracts that use "imports" require to have the code concatenated into one file, separated file isn't supported.

  6. List of supported solc versions, only solc version v0.4.11 and above is supported e.g. v0.4.25+commit.59dbf8f1

  7. Upon successful submission, you will receive a GUID (50 characters) as a receipt

  8. You may use this GUID to track the status of your submission

  9. Verified Source Codes will be displayed on the Verified Contracts page.


Check Source Code Verification Submission Status

                                          //Check Source Code Verification Status 
$.ajax({
   type: "GET",
   url: "https://btachain.com/api",
   data: {
      apikey: $('#apikey').val(),
      guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above
      module: "contract",
      action: "checkverifystatus"
   },
   success: function (result) {
      console.log("status : " + result.status); //0=Error, 1=Pass
      console.log("message : " + result.message); //OK, NOTOK
      console.log("result : " + result.result); //result explanation
      $('#guidstatus').html(">> " + result.result);
   },
   error: function (result) {
      alert('error');
   }
});
How to obtain Block Rewards by BlockNo
                                        https://btachain.com/api
?module=block
&action=getblockreward
&blockno=2000
&apikey=YourApiKeyToken

How to obtain Block Countdown Time by BlockNo
                                          https://btachain.com/api
?module=block
&action=getblockcountdown
&blockno=20000000
&apikey=YourApiKeyToken

How to obtain Block Number by Timestamp

[Parameters] timestamp format: Unix timestamp (supports Unix timestamps in seconds), closest value: 'before' or 'after'

                                          https://btachain.com/api
?module=block
&action=getblocknobytime
&timestamp=1601510400
&closest=before
&apikey=YourApiKeyToken


How to obtain Daily Average Block Size PRO

[Parameters] startdate and enddate format 'yyyy-MM-dd'

                                          https://btachain.com/api
?module=stats
&action=dailyavgblocksize
&startdate=2021-08-01
&enddate=2021-08-10
&sort=asc
&apikey=YourApiKeyToken

How to obtain Block Count and Rewards PRO

[Parameters] startdate and enddate format 'yyyy-MM-dd'

                                            https://btachain.com/api
?module=stats
&action=dailyblkcount
&startdate=2021-08-01
&enddate=2021-08-10
&sort=asc
&apikey=YourApiKeyToken

How to obtain Daily Block Rewards PRO

[Parameters] startdate and enddate format 'yyyy-MM-dd'

                                           https://btachain.com/api
?module=stats
&action=dailyblockrewards
&startdate=2021-08-01
&enddate=2021-08-10
&sort=asc
&apikey=YourApiKeyToken

The main idea of Event Log API is purposely to provide an alternative to the native eth_getLogs.

  • fromBlock, toBlock, address

- FromBlock & ToBlock accepts the blocknumber (integer, NOT hex) or 'latest' (earliest & pending is NOT supported yet)
- For performance & security considerations, only the first 1000 results are return. So please narrow down the filter parameters


We've provided some examples of how this filter can be used :

Get Event Logs from block number 50000 to 50002 Block, where log address = 0xdcfda9efc40fdad80af88fb851b18b65ffaedd55 and topic[0] = 0x93e4685446b51a34980d769e5f8bfd22a6e5234e4a591bd82ed666a9894a1cd7


                                          https://btachain.com/api?module=logs&action=getLogs
&fromBlock=50000
&toBlock=50002
&address=0xdcfda9efc40fdad80af88fb851b18b65ffaedd55
&apikey=YourApiKeyToken

The following are the limited list of supported Proxied APIs for Geth available through BtaChain.

bta_blockNumber

Returns the number of most recent block

                                          
                                            https://btachain.com/api
?module=proxy
&action=bta_blockNumber
&apikey=YourApiKeyToken


bta_getBlockTransactionCountByNumber

Returns the number of transactions in a block from a block matching the given block number

                                          
                                            https://btachain.com/api
?module=proxy
&action=bta_getBlockTransactionCountByNumber
&tag=0x3d0900
&apikey=YourApiKeyToken


bta_getTransactionByBlockNumberAndIndex

Returns information about a transaction by block number and transaction index position

                                          
                                            https://btachain.com/api
?module=proxy
&action=bta_getTransactionByBlockNumberAndIndex
&tag=0x3d0900
&index=0x0
&apikey=YourApiKeyToken


bta_sendRawTransaction

Creates new message call transaction or a contract creation for signed transactions

                                          
                                            https://btachain.com/api
?module=proxy
&action=bta_sendRawTransaction
&hex=0xf904808000831cfde080
&apikey=YourApiKeyToken

(Replace the hex value with your raw hex encoded transaction that you want to send.
Send as a POST request, if your hex code is particularly long)



bta_call

Executes a new message call immediately without creating a transaction on the block chain

                                          
                                            https://btachain.com/api
?module=proxy
&action=bta_call
&to=0xAEEF46DB4855E25702F8237E8f403FddcaF931C0
&data=0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724
&tag=latest
&apikey=YourApiKeyToken

(The gas parameter to eth_call is capped at 2x the current block gas limit)




bta_gasPrice

Returns the current price per gas in wei

                                          
                                            https://btachain.com/api
?module=proxy
&action=bta_gasPrice
&apikey=YourApiKeyToken

bta_estimateGas

Makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas

                                          
                                            https://btachain.com/api
?module=proxy
&action=bta_estimateGas
&data=0x4e71d92d
&to=0xf0160428a8552ac9bb7e050d90eeade4ddd52843
&value=0xff22
&gasPrice=0x51da038cc
&gas=0x5f5e0ff
&apikey=YourApiKeyToken

(The gas parameter to eth_estimateGas is capped at 2x the current block gas limit)




How to Obtain Token Holder List by Contract Address PRO

Return the current token holder and number of tokens held

                                          https://btachain.com/api
?module=token
&action=tokenholderlist
&contractaddress=0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82
&page=1
&offset=10000
&apikey=YourApiKeyToken

Sample return of token info API:

                                          { 
   "status": "1",
   "message": "OK",
   "result": [
      {
         "TokenHolderAddress": "0x0000000000000000000000000000000000000000",
         "TokenHolderQuantity": "0"
      },
      {
         "TokenHolderAddress": "0x0000000000000000000000000000000000000001",
         "TokenHolderQuantity": "844975208812149014804348"
      },
      {
         "TokenHolderAddress": "0x0000000000000000000000000000000000000002",
         "TokenHolderQuantity": "120243030179598696424583296"
      }
   ]
}

How to Obtain Historical BTA-20 Token TotalSupply by ContractAddress & BlockNo PRO
                                          https://btachain.com/api
?module=stats
&action=tokensupplyhistory
&contractaddress=0xdcfda9efc40fdad80af88fb851b18b65ffaedd55
&blockno=4000000
&apikey=YourApiKeyToken

This endpoint is throttled to 2 calls/second regardless of the API Pro tier.


How to obtain Historical BTA-20 Token Account Balance by ContractAddress & BlockNo PRO
                                          https://btachain.com/api
?module=account
&action=tokenbalancehistory
&contractaddress=0xdcfda9efc40fdad80af88fb851b18b65ffaedd55
&address=0x7bb89460599dbf32ee3aa50798bbceae2a5f7f6a
&blockno=4000000
&apikey=YourApiKeyToken

This endpoint is throttled to 2 calls/second regardless of the API Pro tier.


How to obtain Token Info by ContractAddress PRO
                                          https://btachain.com/api
?module=token
&action=tokeninfo
&contractaddress=0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82
&apikey=YourApiKeyToken

This endpoint is throttled to 2 calls/second regardless of the API Pro tier.

Sample return of token info API:

                                          {
   "status": "1",
   "message": "OK",
   "result": [
     {
      "contractAddress": "0x...",
      "tokenName": "Token Name",
      "symbol": "Token Symbol",
      "divisor": "18",
      "tokenType": "BEP20",
      "totalSupply": "1000000000000000",
      "blueCheckmark": "true",
      "description": "Token Description",
      "website": "https://token.website",
      "email": "[email protected]",
      "blog": "https://blog.token.website/",
      "reddit": "https://www.reddit.com/r/tokenwebsite/",
      "slack": "https://chat.token.website/",
      "facebook": "https://facebook.com/tokenwebsite",
      "twitter": "https://twitter.com/tokenwebsite",
      "bitcointalk": "https://www.bitcointalk.org/index.php?topic=xxxxx",
      "github": "https://github.com/tokenwebsite",
      "telegram": "https://t.me/tokenwebsite",
      "wechat": "https://token.website/wechat",
      "linkedin": "https://www.linkedin.com/tokenwebsite/",
      "discord": "https://discord.com/tokenwebsite",
      "whitepaper": "https://token.website/documents/document.pdf",
      "tokenPriceUSD": "00.00"
     }
   ]
}
How to obtain the Total Supply of BTA on the Btachain
                                          
                                            https://btachain.com/api
?module=stats
&action=btasupply
&apikey=YourApiKeyToken

(Result returned in Wei, to get value in BTA divide the returned results by 1000000000000000000)




How to obtain Daily Network Transaction Fee PRO

[Parameters] startdate and enddate format 'yyyy-MM-dd'

                                          https://btachain.com/api
?module=stats
&action=dailytxnfee
&startdate=2020-10-01
&enddate=2020-10-10
&sort=asc
&apikey=YourApiKeyToken

How to obtain Daily New Address Count PRO

[Parameters] startdate and enddate format 'yyyy-MM-dd'

                                          https://btachain.com/api
?module=stats
&action=dailynewaddress
&startdate=2020-10-01
&enddate=2020-10-10
&sort=asc
&apikey=YourApiKeyToken

How to obtain Daily Transaction Count PRO

[Parameters] startdate and enddate format 'yyyy-MM-dd'

                                          https://btachain.com/api
?module=stats
&action=dailytx
&startdate=2020-10-01
&enddate=2020-10-10
&sort=asc
&apikey=YourApiKeyToken

How to obtain BTA Historical Price PRO

[Parameters] startdate and enddate format 'yyyy-MM-dd'

                                          https://btachain.com/api
?module=stats
&action=BTAdailyprice
&startdate=2020-10-01
&enddate=2020-10-10
&sort=asc
&apikey=YourApiKeyToken

The following is a complete list of additional API endpoints available under the API PRO subscription.

You can upgrade your API plan by visiting Btachain APIs.

How to Obtain Historical BTA Balance for a Single Address by BlockNo PRO

Returns the historical BTA balance of an address at a certain block height.

                                        https://btachain.com/api
?module=account
&action=balancehistory
&address=0x000000000000000000000000000000000000f000
&blockno=1000
&apikey=YourApiKeyToken

How to Obtain Daily Average Block Size PRO

Returns the daily average block size within a date range.

                                          https://btachain.com/api
?module=stats
&action=dailyavgblocksize
&startdate=2020-10-01
&enddate=2020-10-10
&sort=asc
&apikey=YourApiKeyToken

How to Obtain Daily Block Count and Rewards PRO

Returns the number of blocks validated daily and the number of block rewards.

                                          https://btachain.com/api
?module=stats
&action=dailyblkcount
&startdate=2020-10-01
&enddate=2020-10-10
&sort=asc
&apikey=YourApiKeyToken


How to obtain Daily Block Rewards PRO

Returns the number of block rewards distributed to validators daily.

                                          https://btachain.com/api
?module=stats
&action=dailyblockrewards
&startdate=2020-10-01
&enddate=2020-10-10
&sort=asc
&apikey=YourApiKeyToken

How to obtain Token Info by Contract Address PRO

Returns project information and social media links of a BTA-20 token.

                                           https://btachain.com/api
?module=token
&action=tokeninfo
&contractaddress=0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82
&apikey=YourApiKeyToken

How to Obtain Address BTA20 Token Holding PRO

Returns the BTA-20 tokens and amount held by an address.

                                           https://btachain.com/api
?module=account
&action=addresstokenbalance
&address=0x99817ce62abf5b17f58e71071e590cf958e5a1bf
&page=1
&offset=100
&apikey=YourApiKeyToken

How to obtain Address BTA721 Token Holding PRO

Returns the BTA-721 tokens and amount held by an address.

                                           https://btachain.com/api
?module=account
&action=addresstokennftbalance
&address=0x99817ce62abf5b17f58e71071e590cf958e5a1bf
&page=1
&offset=100
&apikey=YourApiKeyToken

How to obtain Address BTA721 Token Inventory By Contract Address PRO

Returns the BTA-721 token inventory of an address, filtered by contract address.

                                           https://btachain.com/api
?module=account
&action=addresstokennftinventory
&address=0x99817ce62abf5b17f58e71071e590cf958e5a1bf
&contractaddress=0x5e74094cd416f55179dbd0e45b1a8ed030e396a1
&page=1
&offset=100
&apikey=YourApiKeyToken
Mainnet BTA RPC Nodes
                                              Mainnet BTA RPC Endpoints (ChainID 1657):

https://dataseed1.btachain.com/
https://dataseed2.btachain.com/

Testnet BTA RPC Nodes
                                            Testnet BTA RPC Endpoints (ChainID 1650):

https://bta-data.btachain.com/seed1/

Usage Notes:
                                          Start
You can start the HTTP JSON-RPC with the --rpc flag

## mainnet
geth attach https://dataseed1.btachain.com/

## testnet
geth attach https://bta-data.btachain.com/seed1/