Links

HTTP API

Query web3 data with SQL via the HTTP API
Blockchain and contract data may be queried by posting SQL to the /v0.1/sql API.
See Tables for a list of tables to query or browse the example queries listed in the menu.

Requirements and limitations

  • An API key is required for all SQL queries.
  • Results are limited to 500 rows. Use the Apache Arrow Flight API to fetch up to 1M rows in a single query or the Async HTTP API to fetch results with paging.
  • Requests are limited to 90 seconds.
post
https://data.spiceai.io
/v0.1/sql
Perform a SQL query
cURL
Javascript
curl --request POST \
--url https://data.spiceai.io/v0.1/sql \
--header 'Content-Type: text/plain' \
--header 'X-API-Key: [api-key]' \
--data 'select count(number) from eth.recent_blocks'
const API_KEY = "[api-key]";
const query = `
select count(number) as num_blocks
from eth.recent_blocks
`;
const res = await fetch("https://data.spiceai.io/v0.1/sql", {
method: "POST",
headers: {
"Content-Type": "text/plain",
"X-API-Key": API_KEY,
},
body: query,
});
console.log(await res.json());