# BlockRun.AI Raw SQL Onchain Query

> BlockRun.AI Raw SQL Onchain Query is a paid API for AI agents from blockrun.ai, paid per call via x402, $0.02/call, status unknown (last checked 2026-09-14).

Execute arbitrary SQL queries against 80+ ClickHouse tables of onchain blockchain data with sub-second response times

## Facts

- Endpoint: POST https://blockrun.ai/api/v1/surf/onchain/sql
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/blockrun-ai-25fc4f9e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_JX0j7pgDFHsmkqf0wW9jt

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability blockrun-ai-25fc4f9e -d '<json body>'
```

Example prompt: Run this SQL query against BlockRun's onchain ClickHouse tables and return the results: SELECT chain, SUM(volume_usd) as total_volume FROM dex_trades WHERE block_time >= now() - INTERVAL 1 DAY GROUP BY chain ORDER BY total_volume DESC LIMIT 10

## When to prefer this

Use this endpoint when you need maximum flexibility to query onchain blockchain data with arbitrary SQL — joins, aggregations, filters, window functions — across 80+ ClickHouse tables. Prefer this over pre-built endpoints when no canned endpoint covers your specific analytic need, or when you want to combine multiple data dimensions in a single query with sub-second latency.

## Known failure modes

- Invalid SQL syntax returns a parse error response
- Querying a non-existent table returns a table-not-found error
- Query timeout if the SQL is too complex or scans too much data
- Missing or invalid payment header causes 402 Payment Required
- Unsupported SQL features or functions not available in ClickHouse return errors
- Rate limiting if too many requests are sent in a short period

## How this service works

Pay for the outcome. One endpoint for every model, tool and data source an agent needs — each call priced before it runs, at the best value per dollar. 103 models and 100 data and tool APIs.

## Output

Returns the result set of the executed SQL query as rows of data from BlockRun's 80+ ClickHouse onchain blockchain tables, including column names and values matching the query projection.

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/blockrun-ai-25fc4f9e/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from blockrun.ai](https://www.zero.xyz/host/blockrun.ai/llms.txt)
