Comment on page
HTTP API
Query web3 data with SQL via the HTTP API
Blockchain and contract data may be queried by posting SQL to the
/v1/sql
API and /v1/firesql
API for Firecached data. For documentation on the Spice Firecache see Firecache.- 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
/v1/sql
Perform a SQL query
post
https://data.spiceai.io
/v1/firesql
Perform a Firecache SQL Query
cURL
Javascript
curl --request POST \
--url https://data.spiceai.io/v1/sql \
--header 'Content-Type: text/plain' \
--header 'X-API-Key: [api-key]' \
--data 'select count(number) from eth.recent_blocks'
import { SpiceClient } from '@spiceai/spice';
const main = async () => {
const spiceClient = new SpiceClient('API_KEY');
const table = await spiceClient.query(
'select count(number) as num_blocks from eth.recent_blocks'
);
console.table(table.toArray());
};
Last modified 1mo ago