--- name: ccxt-go description: 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. --- # CCXT for Go A comprehensive guide to using CCXT in Go projects for cryptocurrency exchange integration. ## Installation ```bash 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 ```go 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 ```go 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** pass `nil` placeholders. - 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. - T
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 Оригинален текст · няма потвърден превод на български
Освен тази библиотека Level 8 прави сайтове и онлайн магазини за фирми от цяла България, а цените са публични. Ако вече имате сайт, безплатната проверка показва за под минута колко е бърз на телефон и дали е защитен.