POST
/
v2
/
data
/
query
/
run
Run SQL Query
curl --request POST \
  --url https://api.cdp.coinbase.com/platform/v2/data/query/run \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "sql": "SELECT block_number, transaction_hash FROM base.transactions WHERE block_number > 1000000 LIMIT 10"
}'
{
"result": [
{
"event_signature": "Transfer(address,address,uint256)",
"from": "0x1234567890abcdef",
"to": "0x1234567890abcdef",
"amount": 1000000000000000000
},
{
"event_signature": "Transfer(address,address,uint256)",
"from": "0x1234567890abcdef",
"to": "0x1234567890abcdef",
"amount": 2000000000000000000
}
],
"schema": {
"columns": [
{
"name": "block_number",
"type": "UInt64"
},
{
"name": "transaction_hash",
"type": "String"
}
]
},
"metadata": {
"cached": false,
"executionTimeMs": 145,
"rowCount": 2
}
}

Authorizations

Authorization
string
header
required

A JWT signed using your CDP API Key Secret, encoded in base64. Refer to the Generate Bearer Token section of our Authentication docs for information on how to generate your Bearer Token.

Body

application/json

Request to execute a SQL query against indexed blockchain data.

sql
string
required

SQL query to execute against the indexed blockchain data.

Required string length: 1 - 10000
Example:

"SELECT block_number, transaction_hash FROM base.transactions WHERE block_number > 1000000 LIMIT 10"

Response

Query run successfully.

Result of executing a SQL query.

result
object[]

Query result as an array of objects representing rows.

Row data with column names as keys.

Example:
[
{
"event_signature": "Transfer(address,address,uint256)",
"from": "0x1234567890abcdef",
"to": "0x1234567890abcdef",
"amount": 1000000000000000000
},
{
"event_signature": "Transfer(address,address,uint256)",
"from": "0x1234567890abcdef",
"to": "0x1234567890abcdef",
"amount": 2000000000000000000
}
]
schema
object

Schema information for the query result. This is a derived schema from the query result, so types may not match the underlying table.

Example:
{
"columns": [
{ "name": "block_number", "type": "UInt64" },
{
"name": "transaction_hash",
"type": "String"
}
]
}
metadata
object

Metadata about query execution.

Example:
{
"cached": false,
"executionTimeMs": 145,
"rowCount": 2
}