CCXT library support for Go developers to interact with cryptocurrency exchanges via REST and WebSocket APIs.
Install
mkdir -p .claude/skills/ccxt-go && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4151" && unzip -o skill.zip -d .claude/skills/ccxt-go && rm skill.zipInstalls to .claude/skills/ccxt-go
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
CCXT cryptocurrency exchange library for Go developers. Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors in Go projects. Use when working with crypto exchanges in Go applications, microservices, or trading systems.Key capabilities
- →Connect to crypto exchanges
- →Fetch market data (tickers, orderbooks)
- →Place limit and market orders
- →Stream real-time data via WebSockets
- →Manage authentication and errors
How it works
The library provides a unified interface for both REST and WebSocket APIs across multiple cryptocurrency exchanges, abstracting exchange-specific differences into common Go methods.
Inputs & outputs
When to use ccxt-go
- →Fetching crypto market tickers
- →Placing automated orders
- →Streaming live orderbooks
- →Building trading bots
About this skill
CCXT for Go
A comprehensive guide to using CCXT in Go projects for cryptocurrency exchange integration.
Installation
go get github.com/ccxt/ccxt/go/v4 # REST (package ccxt)
go get github.com/ccxt/ccxt/go/v4/pro # WebSocket (package ccxtpro) — same module
Every exchange lives in one package: there is no per-exchange import path. Construct with ccxt.New<Exchange>(config) (e.g. ccxt.NewBinance, ccxt.NewOkx, ccxt.NewKraken) or dynamically with ccxt.CreateExchange("binance", config).
Quick Start
REST API
package main
import (
"fmt"
ccxt "github.com/ccxt/ccxt/go/v4"
)
func main() {
exchange := ccxt.NewBinance(nil)
ticker, err := exchange.FetchTicker("BTC/USDT")
if err != nil {
panic(err)
}
fmt.Println(*ticker.Last)
}
WebSocket API - Real-time Updates
package main
import (
"fmt"
ccxtpro "github.com/ccxt/ccxt/go/v4/pro"
)
func main() {
exchange := ccxtpro.NewBinance(nil)
defer exchange.Close()
for {
ticker, err := exchange.WatchTicker("BTC/USDT")
if err != nil {
panic(err)
}
fmt.Println(*ticker.Last) // live updates
}
}
REST vs WebSocket
| Feature | REST API | WebSocket API |
|---|---|---|
| Use for | One-time queries, placing orders | Real-time monitoring, live price feeds |
| Import | ccxt "github.com/ccxt/ccxt/go/v4" | ccxtpro "github.com/ccxt/ccxt/go/v4/pro" |
| Constructor | ccxt.NewBinance(cfg) | ccxtpro.NewBinance(cfg) |
| Methods | Fetch* (FetchTicker, FetchOrderBook) | Watch* (WatchTicker, WatchOrderBook) |
| Best for | Trading, account management | Price monitoring, arbitrage detection |
How Go calls work (read this first)
- Required arguments are positional; every optional argument is a functional option named
ccxt.With<Method><Arg>(...):exchange.FetchOHLCV("BTC/USDT", ccxt.WithFetchOHLCVTimeframe("1h"), ccxt.WithFetchOHLCVLimit(100)). Do not passnilplaceholders. - Methods whose first unified argument is optional (e.g.
FetchOpenOrders,FetchMyTrades,WatchOrders,CancelAllOrders) take only options:exchange.FetchOpenOrders(ccxt.WithFetchOpenOrdersSymbol("BTC/USDT")). - Exchange-specific extras go in
ccxt.With<Method>Params(map[string]any{...}). - Every method returns
(value, error). Values are structs (ccxt.Ticker,ccxt.Order,[]ccxt.Trade), and most numeric/string fields are pointers (*float64,*string) because exchanges may omit them — nil-check before dereferencing. - The pro package re-uses the REST types, so
WatchOrderBookoptions are stillccxt.WithWatchOrderBookLimit(...).
Creating Exchange Instance
import (
"os"
ccxt "github.com/ccxt/ccxt/go/v4"
ccxtpro "github.com/ccxt/ccxt/go/v4/pro"
)
// Public API (no authentication)
public := ccxt.NewBinance(nil)
// Private API — pass credentials in the config map
exchange := ccxt.NewBinance(map[string]any{
"apiKey": os.Getenv("BINANCE_APIKEY"),
"secret": os.Getenv("BINANCE_SECRET"),
"enableRateLimit": true, // default: true
"options": map[string]any{"defaultType": "swap"}, // optional
})
// Testnet / sandbox — call right after construction
exchange.SetSandboxMode(true)
// WebSocket (same config shape)
ws := ccxtpro.NewBinance(map[string]any{"apiKey": "...", "secret": "..."})
defer ws.Close()
Common REST Operations
Loading Markets
if _, err := exchange.LoadMarkets(); err != nil {
panic(err)
}
market := exchange.GetMarket("BTC/USDT") // typed ccxt.MarketInterface
if market.Limits.Amount.Min != nil {
fmt.Println("min amount:", *market.Limits.Amount.Min)
}
fmt.Println(exchange.AmountToPrecision("BTC/USDT", 0.0012345)) // round to the market's step
Fetching Ticker
ticker, err := exchange.FetchTicker("BTC/USDT")
if err != nil {
panic(err)
}
fmt.Println(*ticker.Last, *ticker.Bid, *ticker.Ask)
tickers, err := exchange.FetchTickers(ccxt.WithFetchTickersSymbols([]string{"BTC/USDT", "ETH/USDT"}))
fmt.Println(tickers.Tickers["ETH/USDT"])
Fetching Order Book
orderbook, err := exchange.FetchOrderBook("BTC/USDT", ccxt.WithFetchOrderBookLimit(5))
if err != nil {
panic(err)
}
fmt.Println(orderbook.Bids[0]) // [price, amount]
fmt.Println(orderbook.Asks[0])
Fetching OHLCV
candles, err := exchange.FetchOHLCV("BTC/USDT",
ccxt.WithFetchOHLCVTimeframe("1h"),
ccxt.WithFetchOHLCVLimit(100),
)
fmt.Println(candles[0].Timestamp, candles[0].Close)
Creating Orders
// Limit
order, err := exchange.CreateLimitBuyOrder("BTC/USDT", 0.001, 50000)
order, err = exchange.CreateLimitSellOrder("BTC/USDT", 0.001, 70000)
order, err = exchange.CreateOrder("BTC/USDT", "limit", "buy", 0.001, ccxt.WithCreateOrderPrice(50000))
// Market
order, err = exchange.CreateMarketBuyOrder("BTC/USDT", 0.001)
order, err = exchange.CreateOrder("BTC/USDT", "market", "sell", 0.001)
// Extra unified/exchange params (stop loss, post-only, client id, ...)
order, err = exchange.CreateOrder("BTC/USDT", "limit", "buy", 0.001,
ccxt.WithCreateOrderPrice(50000),
ccxt.WithCreateOrderParams(map[string]any{"postOnly": true, "clientOrderId": "my-id-1"}),
)
if err != nil {
panic(err)
}
fmt.Println(*order.Id)
Fetching Balance
balance, err := exchange.FetchBalance()
if err != nil {
panic(err)
}
fmt.Println(*balance.Free["USDT"]) // available
fmt.Println(*balance.Balances["BTC"].Total) // per-currency struct: Free / Used / Total
Fetching Orders
openOrders, err := exchange.FetchOpenOrders(ccxt.WithFetchOpenOrdersSymbol("BTC/USDT"))
closedOrders, err := exchange.FetchClosedOrders(ccxt.WithFetchClosedOrdersSymbol("BTC/USDT"))
order, err := exchange.FetchOrder(orderId, ccxt.WithFetchOrderSymbol("BTC/USDT"))
Fetching Trades
trades, err := exchange.FetchTrades("BTC/USDT", ccxt.WithFetchTradesLimit(10))
myTrades, err := exchange.FetchMyTrades(ccxt.WithFetchMyTradesSymbol("BTC/USDT")) // auth required
Canceling Orders
canceled, err := exchange.CancelOrder(orderId, ccxt.WithCancelOrderSymbol("BTC/USDT"))
all, err := exchange.CancelAllOrders(ccxt.WithCancelAllOrdersSymbol("BTC/USDT"))
Capabilities, Pagination and Testnet
if exchange.GetHas()["fetchOHLCV"] == true {
// supported
}
features := exchange.GetFeatures() // per market type: which createOrder params, fetch limits, daysBack, ...
fmt.Println(features["spot"])
// Let ccxt page through history for you (respects rate limits)
history, err := exchange.FetchOHLCV("BTC/USDT",
ccxt.WithFetchOHLCVTimeframe("1d"),
ccxt.WithFetchOHLCVSince(1704067200000),
ccxt.WithFetchOHLCVParams(map[string]any{"paginate": true}),
)
WebSocket Operations (Real-time)
Watch* calls block until the next update; call them in a loop. Construct with ccxtpro.New<Exchange> and always defer exchange.Close().
Watching Ticker
exchange := ccxtpro.NewBinance(nil)
defer exchange.Close()
for {
ticker, err := exchange.WatchTicker("BTC/USDT")
if err != nil {
panic(err)
}
fmt.Println(*ticker.Last, *ticker.Timestamp)
}
Watching Order Book
for {
orderbook, err := exchange.WatchOrderBook("BTC/USDT", ccxt.WithWatchOrderBookLimit(10))
if err != nil {
panic(err)
}
fmt.Println("best bid:", orderbook.Bids[0], "best ask:", orderbook.Asks[0])
}
Watching Trades
for {
trades, err := exchange.WatchTrades("BTC/USDT")
if err != nil {
panic(err)
}
for _, t := range trades {
fmt.Println(*t.Price, *t.Amount, *t.Side)
}
}
Watching Your Orders and Balance (auth required)
exchange := ccxtpro.NewBinance(map[string]any{"apiKey": "...", "secret": "..."})
defer exchange.Close()
orders, err := exchange.WatchOrders(ccxt.WithWatchOrdersSymbol("BTC/USDT"))
balance, err := exchange.WatchBalance()
Unsubscribing
if exchange.GetHas()["unWatchTicker"] == true {
_, err := exchange.UnWatchTicker("BTC/USDT") // stop one stream, keep the connection
}
Complete Method Reference
Names below are the canonical camelCase unified names; use your language's casing (fetch_ohlcv in Python/PHP, FetchOHLCV in C#/Go). Arguments are positional in this order — trailing ones are optional and params (exchange-specific extras) is always last and omitted here. Signatures mirror ts/src/base/Exchange.ts. Support varies per exchange: check exchange.has['<method>'] (and exchange.features for finer options) before calling.
Market Data Methods
Tickers & Prices
fetchTicker(symbol)- Fetch ticker for one symbolfetchTickers([symbols])- Fetch multiple tickers at oncefetchBidsAsks([symbols])- Fetch best bid/ask for multiple symbolsfetchLastPrices([symbols])- Fetch last pricesfetchMarkPrice(symbol)- Fetch mark price (derivatives)fetchMarkPrices([symbols])- Fetch mark prices (derivatives)
Order Books
fetchOrderBook(symbol, limit)- Fetch order bookfetchOrderBooks([symbols], limit)- Fetch multiple order booksfetchL2OrderBook(symbol, limit)- Fetch level 2 order bookfetchL3OrderBook(symbol, limit)- Fetch level 3 order book (if supported)
Trades
fetchTrades(symbol, since, limit)- Fetch public tradesfetchMyTrades(symbol, since, limit)- Fetch your trades (auth required)fetchOrderTrades(id, symbol, since, limit)- Fetch trades for specific order
OHLCV (Candlesticks)
fetchOHLCV(symbol, timeframe, since, limit)- Fetch candlestick datafetchIndexOHLCV(symbol, timeframe, since, limit)- Fetch index price OHLCVfetchMarkOHLCV(symbol, timeframe, since, limit)- Fetch mark price OHLCVfetchPremiumIndexOHLCV(symbol, timeframe, since, limit)- Fetch premium index OHLCV
Account & Balance
- `fetchBalanc
Content truncated.
When not to use it
- →When working with non-crypto financial markets
- →When low-latency requirements exceed WebSocket capabilities
Prerequisites
Limitations
- →Rate limits vary by exchange
- →Requires careful handling of WebSocket connections
- →Symbol formats must follow CCXT conventions
How it compares
It provides a unified, standardized API for multiple exchanges, eliminating the need to write custom integration code for each platform.
Compared to similar skills
ccxt-go side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| ccxt-go (this skill) | 1 | 9mo | Review | Intermediate |
| templ-htmx | 3 | 10mo | No flags | Intermediate |
| generating-grpc-services | 1 | 4mo | Review | Advanced |
| higress-wasm-go-plugin | 1 | 9mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by ccxt
View all by ccxt →You might also like
templ-htmx
Xe
Build interactive hypermedia-driven applications with templ and HTMX. Use when creating dynamic UIs, real-time updates, AJAX interactions, mentions 'HTMX', 'dynamic content', or 'interactive templ app'.
generating-grpc-services
jeremylongshore
Generate gRPC service definitions, stubs, and implementations from Protocol Buffers. Use when creating high-performance gRPC services. Trigger with phrases like "generate gRPC service", "create gRPC API", or "build gRPC server".
higress-wasm-go-plugin
alibaba
Develop Higress WASM plugins using Go 1.24+. Use when creating, modifying, or debugging Higress gateway plugins for HTTP request/response processing, external service calls, Redis integration, or custom gateway logic.
api-server
HoangNguyen0403
Standards for building HTTP services, REST APIs, and middleware in Golang.
API service
TheBearIsOne
Use this skill when: - adding HTTP endpoints; - defining request and response models; - wiring document generation into an API surface; - shaping controller, route, or handler behavior.
senior-backend
Cor-Incorporated
Guides backend system development with Node.js, Express, Go, Python, PostgreSQL, GraphQL, and REST APIs. Use when the user says: 'design an API', 'optimize database queries', 'implement authentication', 'set up backend', 'create API endpoint', 'database migration', 'fix N+1 query', 'add rate limitin