CCXT
Candles, quotes, order books, trades and perpetual funding from 100+ crypto exchanges
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/ccxt/index.md to help me query CCXT with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Daily BTC/USD candles on Coinbase for January 2025
Example output · captured
- Connector release
- v0.2.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT ts, close, volume
FROM ccxt.main.ohlcv('coinbase', 'BTC/USD', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-02-01')
ORDER BY ts
| ts | close | volume |
|---|---|---|
| 2025-01-01 00:00 | 94,383.59 | 6,871.74 |
| 2025-01-02 00:00 | 96,903.19 | 10,912.47 |
| 2025-01-03 00:00 | 98,136.51 | 9,021.89 |
| 2025-01-04 00:00 | 98,209.85 | 2,742.09 |
| 2025-01-05 00:00 | 98,345.33 | 2,377.92 |
Quick start
Choose where to run CCXT, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'ccxt' AS ccxt (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-ccxt-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'ccxt' AS ccxt (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-ccxt:0.2.0'
);
3. Run a query
SELECT ts, close, volume
FROM ccxt.main.ohlcv('coinbase', 'BTC/USD', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-02-01')
ORDER BY ts
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'ccxt' AS ccxt
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT ts, close, volume
FROM ccxt.main.ohlcv('coinbase', 'BTC/USD', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-02-01')
ORDER BY ts
Query Farm operates CCXT for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use ccxt as the catalog alias for the query below.
4. Run a query
SELECT ts, close, volume
FROM ccxt.main.ohlcv('coinbase', 'BTC/USD', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-02-01')
ORDER BY ts
Technical details
- Verified connector release
- v0.2.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'ccxt' AS ccxt (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-ccxt-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'ccxt' AS ccxt (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-ccxt:0.2.0'
);
Overview
Public cryptocurrency market data from more than one hundred centralized exchanges through the CCXT library: candles, trades, quotes, order books, and perpetual funding and open interest. Every query is a live request to the exchange. No API key needed.
Unified public market data from more than one hundred centralized crypto exchanges, served to DuckDB through the MIT-licensed CCXT library: candles, quotes, order books, trades, listed markets, and perpetual-swap funding and open interest.
Exchanges are named by CCXT id and markets by CCXT's unified symbol (BTC/USD for spot, BTC/USDT:USDT for a USDT-settled perpetual). No credentials are used or accepted.
Terms of use. Every call is a live request from your machine to the exchange's public API. Nothing is cached or redistributed by this worker; you are the API caller, and each exchange's terms of use and geographic restrictions apply to you (for example, Binance.com refuses US IP addresses).
Sources and references
Catalog
Everything ccxt exposes once attached — read straight from the worker's
released build.
main 1 table · 9 functions
Public crypto market data from CCXT exchanges: history, snapshots, derivatives and reference tables.
Schema examples (13)
Daily BTC/USD candles on Coinbase for January 2025
SELECT ts, close, volume
FROM ccxt.main.ohlcv('coinbase', 'BTC/USD', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-02-01')
ORDER BY ts;
| ts | close | volume |
|---|---|---|
| 2025-01-01 00:00 | 94,383.59 | 6,871.74 |
| 2025-01-02 00:00 | 96,903.19 | 10,912.47 |
| 2025-01-03 00:00 | 98,136.51 | 9,021.89 |
| 2025-01-04 00:00 | 98,209.85 | 2,742.09 |
| 2025-01-05 00:00 | 98,345.33 | 2,377.92 |
Buy versus sell volume in Kraken's most recent BTC/USD trades
SELECT side, count(*) AS trades, sum(amount) AS btc
FROM ccxt.main.trades('kraken', 'BTC/USD')
GROUP BY side
ORDER BY side;
Compare BTC/USD on two US exchanges
SELECT exchange, last, ask - bid AS spread, quote_volume
FROM ccxt.main.ticker(['kraken', 'coinbase'], 'BTC/USD')
WHERE error IS NULL
ORDER BY last;
Liquidity in the top 50 levels on each side of Kraken's BTC/USD book
SELECT side, sum(amount) AS btc, sum(price * amount) AS usd
FROM ccxt.main.order_book('kraken', 'BTC/USD', depth := 50)
GROUP BY side
ORDER BY side;
9 more examples
BTC perpetual swaps listed on OKX
SELECT symbol, settle, contract_size
FROM ccxt.main.markets('okx')
WHERE type = 'swap' AND base = 'BTC'
ORDER BY symbol;
Which of three exchanges publish funding-rate history
SELECT exchange, supported
FROM ccxt.main.has(['kraken', 'okx', 'binance'])
WHERE method = 'fetchFundingRateHistory'
ORDER BY exchange;
Number of settlements and average annualized BTC perpetual funding on Binance over June 2025 (for a rolling window, pass start_date := current_date - INTERVAL 30 DAY)
SELECT count(*) AS settlements, avg(funding_rate_annualized) AS avg_apr
FROM ccxt.main.funding_rates('binance', 'BTC/USDT:USDT', start_date := DATE '2025-06-01', end_date := DATE '2025-07-01');
Rank venues by annualized BTC perpetual funding
SELECT exchange, funding_rate, interval_hours, funding_rate_annualized
FROM ccxt.main.funding_rate(['binance', 'okx'], 'BTC/USDT:USDT')
WHERE error IS NULL
ORDER BY funding_rate_annualized DESC;
BTC perpetual open interest by venue, largest first
SELECT exchange, open_interest_value
FROM ccxt.main.open_interest(['binance', 'okx'], 'BTC/USDT:USDT')
WHERE error IS NULL
ORDER BY open_interest_value DESC;
Exchanges that publish both funding history and open interest
SELECT id, name
FROM ccxt.main.exchanges
WHERE has_funding_rate_history AND has_open_interest
ORDER BY id;
Current annualized BTC perpetual funding across Binance and OKX, weighted by each venue's open interest (funding_rate joined to open_interest)
SELECT sum(f.funding_rate_annualized * o.open_interest_value) / sum(o.open_interest_value) AS oi_weighted_apr,
sum(o.open_interest_value) AS total_oi_usdt, count(*) AS venues
FROM ccxt.main.funding_rate(['binance', 'okx'], 'BTC/USDT:USDT') AS f
JOIN ccxt.main.open_interest(['binance', 'okx'], 'BTC/USDT:USDT') AS o USING (exchange)
WHERE f.error IS NULL AND o.error IS NULL;
What a 2 BTC market buy on Kraken would cost: walk the ask side of the order book, then add the market's default taker fee from markets (filled_btc is below 2 if the book is too thin)
WITH asks AS (SELECT price, amount, sum(amount) OVER (ORDER BY level) - amount AS ahead FROM ccxt.main.order_book('kraken', 'BTC/USD', depth := 50) WHERE side = 'ask'), fill AS (SELECT sum(least(amount, greatest(2 - ahead, 0))) AS filled_btc, sum(price * least(amount, greatest(2 - ahead, 0))) AS cost_usd FROM asks) SELECT fill.filled_btc, fill.cost_usd / fill.filled_btc AS avg_fill_price, fill.cost_usd * (1 + m.taker) AS cost_with_taker_fee_usd
FROM fill
JOIN ccxt.main.markets('kraken') AS m ON m.symbol = 'BTC/USD';
Funding settled each UTC day on Binance's BTC perpetual next to that day's open-to-close return of the perpetual itself, first week of 2025 (funding_rates joined to ohlcv)
WITH funding AS (SELECT CAST(ts AS DATE) AS day, sum(funding_rate) AS daily_funding FROM ccxt.main.funding_rates('binance', 'BTC/USDT:USDT', start_date := DATE '2025-01-01', end_date := DATE '2025-01-08') GROUP BY day), candles AS (SELECT CAST(ts AS DATE) AS day, close / open - 1 AS price_return FROM ccxt.main.ohlcv('binance', 'BTC/USDT:USDT', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-01-08')) SELECT day, daily_funding, price_return
FROM funding
JOIN candles USING (day)
ORDER BY day;
exchanges
Every crypto exchange CCXT supports, with name, countries and key capabilities
Exchanges that publish both funding history and open interest
SELECT id, name
FROM ccxt.main.exchanges
WHERE has_funding_rate_history AND has_open_interest
ORDER BY id;
The ten countries listed for the most exchanges
SELECT unnest(countries) AS country, count(*) AS exchanges
FROM ccxt.main.exchanges
GROUP BY country
ORDER BY exchanges DESC
LIMIT 10;
funding_rate (exchange ANY, symbol VARCHAR)
Current funding rate of a perpetual swap, per interval and annualized, across exchanges
Rank venues by annualized BTC perpetual funding
SELECT exchange, funding_rate, interval_hours, funding_rate_annualized
FROM ccxt.main.funding_rate(['binance', 'okx'], 'BTC/USDT:USDT')
WHERE error IS NULL
ORDER BY funding_rate_annualized DESC;
The next ETH perpetual funding settlement on OKX
SELECT funding_rate, next_funding_ts
FROM ccxt.main.funding_rate('okx', 'ETH/USDT:USDT')
WHERE error IS NULL;
Current annualized BTC perpetual funding across Binance and OKX, weighted by each venue's open interest (funding_rate joined to open_interest)
SELECT sum(f.funding_rate_annualized * o.open_interest_value) / sum(o.open_interest_value) AS oi_weighted_apr,
sum(o.open_interest_value) AS total_oi_usdt, count(*) AS venues
FROM ccxt.main.funding_rate(['binance', 'okx'], 'BTC/USDT:USDT') AS f
JOIN ccxt.main.open_interest(['binance', 'okx'], 'BTC/USDT:USDT') AS o USING (exchange)
WHERE f.error IS NULL AND o.error IS NULL;
funding_rates (exchange VARCHAR, symbol VARCHAR, end_date := ANY, max_rows := BIGINT, start_date := ANY)
Historical funding rates of a perpetual swap, per interval and annualized
Number of settlements and average annualized BTC perpetual funding on Binance over June 2025 (for a rolling window, pass start_date := current_date - INTERVAL 30 DAY)
SELECT count(*) AS settlements, avg(funding_rate_annualized) AS avg_apr
FROM ccxt.main.funding_rates('binance', 'BTC/USDT:USDT', start_date := DATE '2025-06-01', end_date := DATE '2025-07-01');
Daily total ETH perpetual funding on Binance over the first two weeks of 2025
SELECT date_trunc('day', ts) AS day, sum(funding_rate) AS daily_funding
FROM ccxt.main.funding_rates('binance', 'ETH/USDT:USDT', start_date := DATE '2025-01-01', end_date := DATE '2025-01-15')
GROUP BY day
ORDER BY day;
Funding settled each UTC day on Binance's BTC perpetual next to that day's open-to-close return of the perpetual itself, first week of 2025 (funding_rates joined to ohlcv)
WITH funding AS (SELECT CAST(ts AS DATE) AS day, sum(funding_rate) AS daily_funding FROM ccxt.main.funding_rates('binance', 'BTC/USDT:USDT', start_date := DATE '2025-01-01', end_date := DATE '2025-01-08') GROUP BY day), candles AS (SELECT CAST(ts AS DATE) AS day, close / open - 1 AS price_return FROM ccxt.main.ohlcv('binance', 'BTC/USDT:USDT', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-01-08')) SELECT day, daily_funding, price_return
FROM funding
JOIN candles USING (day)
ORDER BY day;
has (exchange ANY)
Which CCXT methods an exchange supports: native, emulated or not at all
Which of three exchanges publish funding-rate history
SELECT exchange, supported
FROM ccxt.main.has(['kraken', 'okx', 'binance'])
WHERE method = 'fetchFundingRateHistory'
ORDER BY exchange;
Kraken's support for every method this worker uses
SELECT method, status
FROM ccxt.main.has('kraken')
WHERE exposed_by_worker
ORDER BY method;
SELECT method, supported
FROM ccxt.main.has('kraken')
WHERE method IN ('fetchOHLCV', 'fetchFundingRateHistory')
ORDER BY method;
markets (exchange VARCHAR)
Every market an exchange lists: symbols, currencies, contract terms, fees and limits
BTC perpetual swaps listed on OKX
SELECT symbol, settle, contract_size
FROM ccxt.main.markets('okx')
WHERE type = 'swap' AND base = 'BTC'
ORDER BY symbol;
Kraken's five most common quote currencies
SELECT quote, count(*) AS pairs
FROM ccxt.main.markets('kraken')
WHERE type = 'spot' AND active
GROUP BY quote
ORDER BY pairs DESC
LIMIT 5;
ohlcv (exchange VARCHAR, symbol VARCHAR, timeframe VARCHAR, max_rows := BIGINT, since := ANY, until := ANY)
OHLCV candles for one market on one exchange, backfilled over a time window
Daily BTC/USD candles on Coinbase for January 2025
SELECT ts, close, volume
FROM ccxt.main.ohlcv('coinbase', 'BTC/USD', '1d', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-02-01')
ORDER BY ts;
| ts | close | volume |
|---|---|---|
| 2025-01-01 00:00 | 94,383.59 | 6,871.74 |
| 2025-01-02 00:00 | 96,903.19 | 10,912.47 |
| 2025-01-03 00:00 | 98,136.51 | 9,021.89 |
| 2025-01-04 00:00 | 98,209.85 | 2,742.09 |
| 2025-01-05 00:00 | 98,345.33 | 2,377.92 |
Daily high-low range of ETH/USDT on OKX in the first week of 2025, from hourly candles
SELECT date_trunc('day', ts) AS day, max(high) - min(low) AS range_usdt
FROM ccxt.main.ohlcv('okx', 'ETH/USDT', '1h', since := TIMESTAMP '2025-01-01', until := TIMESTAMP '2025-01-08')
GROUP BY day
ORDER BY day;
open_interest (exchange ANY, symbol VARCHAR)
Current open interest of a perpetual or futures market, across one or more exchanges
BTC perpetual open interest by venue, largest first
SELECT exchange, open_interest_value
FROM ccxt.main.open_interest(['binance', 'okx'], 'BTC/USDT:USDT')
WHERE error IS NULL
ORDER BY open_interest_value DESC;
ETH perpetual open interest on OKX
SELECT open_interest_amount
FROM ccxt.main.open_interest('okx', 'ETH/USDT:USDT');
order_book (exchange VARCHAR, symbol VARCHAR, depth := BIGINT)
Order-book depth snapshot for one market: bids and asks by level
Liquidity in the top 50 levels on each side of Kraken's BTC/USD book
SELECT side, sum(amount) AS btc, sum(price * amount) AS usd
FROM ccxt.main.order_book('kraken', 'BTC/USD', depth := 50)
GROUP BY side
ORDER BY side;
Best bid and ask for ETH/USD on Coinbase
SELECT max(price) FILTER (side = 'bid') AS best_bid,
min(price) FILTER (side = 'ask') AS best_ask
FROM ccxt.main.order_book('coinbase', 'ETH/USD', depth := 1);
What a 2 BTC market buy on Kraken would cost: walk the ask side of the order book, then add the market's default taker fee from markets (filled_btc is below 2 if the book is too thin)
WITH asks AS (SELECT price, amount, sum(amount) OVER (ORDER BY level) - amount AS ahead FROM ccxt.main.order_book('kraken', 'BTC/USD', depth := 50) WHERE side = 'ask'), fill AS (SELECT sum(least(amount, greatest(2 - ahead, 0))) AS filled_btc, sum(price * least(amount, greatest(2 - ahead, 0))) AS cost_usd FROM asks) SELECT fill.filled_btc, fill.cost_usd / fill.filled_btc AS avg_fill_price, fill.cost_usd * (1 + m.taker) AS cost_with_taker_fee_usd
FROM fill
JOIN ccxt.main.markets('kraken') AS m ON m.symbol = 'BTC/USD';
ticker (exchange ANY, symbol VARCHAR)
Current price, best bid/ask and 24-hour stats for a market, across one or more exchanges
Compare BTC/USD on two US exchanges
SELECT exchange, last, ask - bid AS spread, quote_volume
FROM ccxt.main.ticker(['kraken', 'coinbase'], 'BTC/USD')
WHERE error IS NULL
ORDER BY last;
The current ETH/USDT price and 24-hour change on OKX
SELECT last, change_pct FROM ccxt.main.ticker('okx', 'ETH/USDT');
trades (exchange VARCHAR, symbol VARCHAR, max_rows := BIGINT, since := ANY, until := ANY)
Public trades (time and sales) for one market on one exchange over a time window
Buy versus sell volume in Kraken's most recent BTC/USD trades
SELECT side, count(*) AS trades, sum(amount) AS btc
FROM ccxt.main.trades('kraken', 'BTC/USD')
GROUP BY side
ORDER BY side;
Volume-weighted average price over Coinbase's most recent ETH/USD trades
SELECT sum(price * amount) / sum(amount) AS vwap, min(ts) AS first_trade
FROM ccxt.main.trades('coinbase', 'ETH/USD');
Try these queries
Buy versus sell volume in Kraken's most recent BTC/USD trades
SELECT side, count(*) AS trades, sum(amount) AS btc
FROM ccxt.main.trades('kraken', 'BTC/USD')
GROUP BY side
ORDER BY side
Uses trades
Compare BTC/USD on two US exchanges
SELECT exchange, last, ask - bid AS spread, quote_volume
FROM ccxt.main.ticker(['kraken', 'coinbase'], 'BTC/USD')
WHERE error IS NULL
ORDER BY last
Uses ticker
Liquidity in the top 50 levels on each side of Kraken's BTC/USD book
SELECT side, sum(amount) AS btc, sum(price * amount) AS usd
FROM ccxt.main.order_book('kraken', 'BTC/USD', depth := 50)
GROUP BY side
ORDER BY side
Uses order_book
BTC perpetual swaps listed on OKX
SELECT symbol, settle, contract_size
FROM ccxt.main.markets('okx')
WHERE type = 'swap' AND base = 'BTC'
ORDER BY symbol
Uses markets
Which of three exchanges publish funding-rate history
SELECT exchange, supported
FROM ccxt.main.has(['kraken', 'okx', 'binance'])
WHERE method = 'fetchFundingRateHistory'
ORDER BY exchange
Uses has
Number of settlements and average annualized BTC perpetual funding on Binance over June 2025 (for a rolling window, pass start_date := current_date - INTERVAL 30 DAY)
SELECT count(*) AS settlements, avg(funding_rate_annualized) AS avg_apr
FROM ccxt.main.funding_rates('binance', 'BTC/USDT:USDT', start_date := DATE '2025-06-01', end_date := DATE '2025-07-01')
Uses funding_rates
17 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- Using the ccxt worker, does the Kraken exchange support fetching OHLCV candles?
- Using the ccxt worker, how many exchanges support fetching funding rate history?
- Using the ccxt worker, list Coinbase's daily BTC/USD closing prices for the first week of January 2025, oldest first.
- Using the ccxt worker, what was the average annualized funding rate of the BTC/USDT:USDT perpetual on OKX over the last 30 days?
- Using the ccxt worker, what is the current bid-ask spread of BTC/USD on Kraken and on Coinbase?
- Using the ccxt worker, how many trades are in Kraken's most recent page of BTC/USD trades?
CCXT is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Perps
Markets & finance
Funding, marks, books and carry for US-regulated perps, benchmarked against offshore venues
Tastytrade
Markets & finance
Query your tastytrade brokerage accounts and market data from SQL, read-only
Yahoo Finance
Markets & finance
Yahoo Finance price history, quotes and symbol search