🤖
Data Cloud API
Custom API services based on the deCrypto data cloud
We have opened up the API online service capabilities of deCrypto Data Cloud for developers to use directly.

🕵️‍♂️ API Struct

  • Method
    • POST
  • URL Endpoint
    • https://api.chainbase.online/v1/dw/query
  • Request Header
    • X-API-KEY (required): The API-Key used to access the data api.
  • POST Body
    • query (required): [String] SQL commands for querying indexes.
    • task_id (optional): [String] The task_id used to get the paged data.
    • page (optional) : [Int] Get the data on which page.

👇 Example

Note:
  1. 1.
    When quey_id is passed in, the content of query will be ignored
  2. 2.
    The executed request generates a task_id, which is valid for 1 hours
  3. 3.
    A maximum of 100,000 pieces of data are allowed to be obtained from the data cloud warehouse request, and 1,000 results are paginated per page

Request

Query the hashes of the last 3000 blocks in Ethereum, and the number of transactions in each block:
curl -X "POST" "https://api.chainbase.online/v1/dw/query" \
-H 'X-API-KEY: YOUR-API-KEY ' \
-H 'Content-Type: application/json; charset=utf-8' \
-d #x27;{
"query": "select number, transactions_count from ethereum.blocks order by number desc limit 3000;"
}'
If there are more than 1000 rows, you need to page through task_id and page to get the data:
curl -X "POST" "https://api.chainbase.online/v1/dw/query" \
-H 'X-API-KEY: YOUR-API-KEY ' \
-H 'Content-Type: application/json; charset=utf-8' \
-d #x27;{
"task_id": "xxxxxxxxxxxxxxxxxxxxx",
"page": 2
}'

Response

{
"data":{
"task_id":"",
"rows":30,
"rows_read":3474694,
"bytes_read":41696328,
"elapsed":0.049134601,
"meta":[
{
"name":"number",
"type":"UInt64"
},
{
"name":"transactions_count",
"type":"UInt32"
}
],
"result":[
{
"number":"15018304",
"transactions_count":23
},
{
"number":"15018303",
"transactions_count":328
},
{
"number":"15018302",
"transactions_count":219
},
{
"number":"15018301",
"transactions_count":417
},
{
"number":"15018300",
"transactions_count":52
},
{
"number":"15018299",
"transactions_count":253
},
{
"number":"15018298",
"transactions_count":81
},
{
"number":"15018297",
"transactions_count":146
},
{
"number":"15018296",
"transactions_count":224
},
{
"number":"15018295",
"transactions_count":228
}
],
"err_msg":""
},
"message":"success",
"code":200
}

More examples of queries

Query the latest block height:
select max(number) from ethereum.blocks;
Query transactions based on block height:
select block_number, transaction_hash, transaction_index, from_address, to_address, value from ethereum.transactions where block_number=(select max(number) from ethereum.blocks);
Query the initiated transaction of an address:
select block_number, transaction_hash, transaction_index from ethereum.transactions where from_address='0xd8da6bf26964af9d7eed9e03e53415d37aa96045';
Copy link
Outline
🕵️‍♂️ API Struct
👇 Example
More examples of queries