Table Schema

GET/gateway/v1/onchain/schema

Discover tables and columns before writing SQL or structured queries. Example: call this endpoint first, then use `agent.ethereum_dex_trades` in `/v1/onchain/query` or `/v1/onchain/sql`.

The response includes database name, table name, column names, types, and comments. Pass the optional `table` parameter to include bounded physical source metadata: engine, partition key, sorting key, primary key, row estimate, and compressed bytes.

For transfer tables, `amount` is decimal-adjusted display units and `amount_raw` is the original base-unit value.

Query Parameters

tablestring

Optional logical table name from the agent database. Use this to include bounded physical partition, ordering-key, and size metadata.

Example: polymarket_trades
Table Schema
const options = {method: 'GET'};

fetch('https://api.asksurf.ai/gateway/v1/onchain/schema?table=polymarket_trades', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
OK
{
  "$schema": "https://example.com/schemas/DataResponseOnchainSchemaTable.json",
  "data": [
    {
      "columns": [
        {
          "comment": "<string>",
          "name": "<string>",
          "type": "<string>"
        }
      ],
      "database": "<string>",
      "engine": "<string>",
      "partition_key": "<string>",
      "physical_sources": [
        {
          "database": "<string>",
          "engine": "<string>",
          "partition_key": "<string>",
          "primary_key": "<string>",
          "sorting_key": "<string>",
          "table": "<string>",
          "total_bytes": 123,
          "total_rows": 123
        }
      ],
      "primary_key": "<string>",
      "sorting_key": "<string>",
      "table": "<string>",
      "total_bytes": 123,
      "total_rows": 123
    }
  ],
  "meta": {
    "cached": true,
    "credits_used": 123,
    "empty_reason": "<string>",
    "has_more": true,
    "limit": 123,
    "offset": 123,
    "total": 123,
    "watermark": 123
  }
}