Welcome to Bilinear Labs! Query blockchain events with SQL. Get Started.
API Reference

API Reference

All queries available in the UI can also be executed via the REST API.

Authentication

Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Generate API keys from Settings > API Keys in the dashboard.

Endpoints

POST /api/v1/query

Execute a SQL query.

Request:

curl -X POST http://localhost:3000/api/v1/query \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "SELECT * FROM ethereum.events WHERE event_name = '\''Transfer'\'' LIMIT 5",
    "format": "json"
  }'

Response:

{
  "data": [
    {
      "block_number": 19845123,
      "tx_hash": "0xabc...def",
      "event_name": "Transfer",
      "contract_address": "0x6b17...1a2f",
      "args": {"from": "0x...", "to": "0x...", "value": "1000000"}
    }
  ],
  "meta": {
    "rows_returned": 5,
    "execution_time_ms": 87,
    "query_id": "q_abc123"
  }
}

Parameters:

Field Type Required Description
query string Yes SQL query to execute
format string No json (default) or csv

GET /api/v1/schemas

List available chain schemas and tables.

curl http://localhost:3000/api/v1/schemas \
  -H "Authorization: Bearer YOUR_API_KEY"

GET /api/v1/health

Health check (no auth required).

curl http://localhost:3000/api/v1/health

Rate Limits

Plan Requests/min Max rows/query
Free 10 1,000
Pro 100 10,000
Enterprise Unlimited 10,000

Error Codes

Code Meaning
400 Invalid SQL syntax
401 Missing or invalid API key
429 Rate limit exceeded
504 Query timeout (>30s)