# API Reference

> Full reference for Market SQL: endpoint, authentication, parameters, limits, and every table in each dataset, with examples in cURL, JavaScript, and Python.

This section documents how to connect to Market SQL and which tables each dataset exposes.

Market SQL has a single endpoint. What you receive depends on the [**dataset**](/market-sql/api-reference/#datasets) you select and the SQL you send. Each dataset has its own page below listing every table and what it contains.

### Quickstart

Inspect five PumpSwap trades on Solana:

#### cURL

```bash
curl --fail-with-body \
  --user "<USER-ID>:<API-KEY>" \
  "https://market-sql.eu-central-1.getblock.io?database=solana&default_format=JSONEachRow" \
  --data-binary "SELECT block_time, direction, base_token, quote_token FROM pumpswap_all_swaps LIMIT 5"
```

#### JavaScript

```javascript
import { createClient } from '@clickhouse/client'

const client = createClient({
  host: 'https://market-sql.eu-central-1.getblock.io',
  username: process.env.GETBLOCK_USER_ID,
  password: process.env.GETBLOCK_API_KEY,
  database: 'solana'
})

const rows = await client.query({
  query: 'SELECT block_time, direction, base_token, quote_token FROM pumpswap_all_swaps LIMIT 5',
  format: 'JSONEachRow'
})

console.log(await rows.json())
```

#### Python

```python
import os
import clickhouse_connect

client = clickhouse_connect.get_client(
    host='market-sql.eu-central-1.getblock.io',
    port=443,
    username=os.environ['GETBLOCK_USER_ID'],
    password=os.environ['GETBLOCK_API_KEY'],
    database='solana',
    secure=True,
)

print(client.query_df(
    'SELECT block_time, direction, base_token, quote_token FROM pumpswap_all_swaps LIMIT 5'
))
```

### Response

```json
{"block_time":"2025-10-09 17:00:00","direction":"B","base_token":"HdbQVdtTh3gFuvmvVqHCh37w9ADPCiE9f24EX63npump","quote_token":"So11111111111111111111111111111111111111112"}
{"block_time":"2025-10-09 17:00:00","direction":"S","base_token":"So11111111111111111111111111111111111111112","quote_token":"2oyFNVveXsgPZGgwSPMSASriv59M5ZqZ9CCewanK38Q8"}
{"block_time":"2025-10-09 17:00:00","direction":"B","base_token":"So11111111111111111111111111111111111111112","quote_token":"5Dyr4rWsqGxJEtVRUM7HzgS6UQE93Babqot8mgevvHPh"}
{"block_time":"2025-10-09 17:00:00","direction":"S","base_token":"2ktfSdqv5Te5XRFo4Do5U21RNGKiyuWbQatXp7p8pump","quote_token":"So11111111111111111111111111111111111111112"}
{"block_time":"2025-10-09 17:00:00","direction":"S","base_token":"So11111111111111111111111111111111111111112","quote_token":"2rP2qcdjv3LFYvwU9Rp89TDm7EAf3Zv9iuRXP6Uckw2T"}

```

### Endpoint

```bash
https://market-sql.eu-central-1.getblock.io
```

### Authentication

Credentials go in **HTTP Basic Auth** on every request, not in the URL.

| Field | Value |
| --- | --- |
| Username | Your GetBlock user ID |
| Password | A GetBlock API key in `gb_…` format |

### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `database` | string | Yes | Dataset to query: `solana`, `polymarket`, `hyperliquid`, or `robinhood`. |
| `default_format` | string | No | Output format, for example `JSONEachRow`. A `FORMAT` clause in the SQL takes precedence. |

### Datasets

| Dataset | Description | Tables |
| --- | --- | --- |
| [`solana`](/market-sql/api-reference/solana/) | Swaps, launches, transfers, funding, blocks, and Jito tips | 21 |
| [`polymarket`](/market-sql/api-reference/polymarket/) | Prediction-market fills, events, and markets | 3 |
| [`hyperliquid`](/market-sql/api-reference/hyperliquid/) | Perpetual fills, wallet analytics, and positions | 4 |
| [`robinhood`](/market-sql/api-reference/robinhood/) | Launchpads, Uniswap v3/v4, and token metadata on Robinhood Chain | 25 |

### Choosing a dataset

| If you need | Use |
| --- | --- |
| Solana DEX swaps, token launches, and migrations | `solana` |
| Wallet funding paths and token transfers on Solana | `solana` |
| Perpetual fills, wallet PnL, and open positions | `hyperliquid` |
| Launchpad and Uniswap activity on Robinhood Chain | `robinhood` |
| Prediction-market fills and outcomes | `polymarket` |

### Concepts that apply to every query

1. **One dataset per plan:** Access is purchased per dataset. A query to a dataset your API key has no access to is rejected.
1. **Read-only:** The gateway runs every query under a managed, read-only identity. Only statements that read data are accepted.
1. **Execution limits:** Trials allow one concurrent query and 10 seconds of execution. Monthly access allows 60 seconds with higher query limits.
1. **Errors:** A failed query returns a non-2xx HTTP status with the error message in the response body. Use `curl --fail-with-body` to see the message while still failing the command.

| Symptom | Cause | Resolution |
| --- | --- | --- |
| Authentication is rejected | The user ID and API key belong to different accounts, or the key is invalid | Use the user ID of the account that owns the key |
| Access to a dataset is denied | No active trial or subscription for that `database` | Activate the dataset on the **Pricing** tab |
| A query stops before finishing | The query exceeded the plan's execution limit | Add filters, select fewer columns, add `LIMIT`, or upgrade the plan |
| A driver or IDE cannot connect | The client uses the native TCP protocol | Connect over HTTPS on port `443` |
| A second query fails during a trial | Trials allow one concurrent query | Run queries one after another |
