Quick answer
Bybit’s V5 API covers spot, linear and inverse derivatives and options through one set of REST and WebSocket endpoints selected by a category parameter. Requests are signed with HMAC-SHA256 over timestamp + key + recv_window + payload. Demo Trading uses api-demo.bybit.com with a key created in demo mode; the broad IP limit is 600 HTTP requests per 5 seconds. Bybit does not serve US residents.
Bybit API at a glance
- Pricing
- Free API; trading fees apply
- Availability
- Global; not available to US residents
- Paper trading
- Demo Trading account (api-demo.bybit.com)
- Integration type
- REST + API key
- In AlgoGP
- Built in: broker and data adapter (Pro)
- REST base
https://api.bybit.com(Demo Tradinghttps://api-demo.bybit.com)- Auth
X-BAPI-API-KEY,X-BAPI-TIMESTAMP,X-BAPI-RECV-WINDOW,X-BAPI-SIGN- Candles
GET /v5/market/kline?category=spot, up to 1,000 bars- Availability
- Not offered to US residents and some other jurisdictions
One API, several markets
Every market endpoint takes category: spot, linear (USDT/USDC perpetuals and futures), inverse or option. AlgoGP’s long/flat strategies trade spot. Klines come from /v5/market/kline?category=spot&symbol=BTCUSDT&interval=D&limit=1000 as [startTime, open, high, low, close, volume, turnover], newest first. Intervals are minutes (1, 3, 5, 15, 30, 60, 120, 240, 360, 720) or D, W, M.
How requests are signed
For HMAC keys, sign timestamp + api_key + recv_window + payload with HMAC-SHA256 and send the hex digest as X-BAPI-SIGN. For a GET the payload is the query string; for a POST it is the exact JSON body. The timestamp must be within recv_window (5,000 ms by default) of Bybit’s clock.
- Spot market orders use
marketUnit: "baseCoin"to size in coins rather than quote currency. - Quantities must respect
lotSizeFilter.basePrecisionfrom/v5/market/instruments-info. - Balances live in the Unified Trading Account:
/v5/account/wallet-balance?accountType=UNIFIED.
Demo Trading (and the older testnet)
Switch your Bybit account to Demo Trading, create a separate API key there, and send requests to https://api-demo.bybit.com (private WebSocket stream-demo.bybit.com). Public market data still comes from mainnet, demo orders are kept for seven days, and a few APIs (such as WebSocket order entry) are not available in demo. The older testnet at testnet.bybit.com still exists but has thin order books. AlgoGP’s sandbox mode uses Demo Trading.
Use Bybit in AlgoGP
Open a project, go to the APIs & keys tab and, under Platforms, pick Bybit as the market data source (market_data.py) and the broker (brokers.py). The choice is saved to config.json as a new strategy version:
{
"platforms": {
"data": "bybit",
"broker": "bybit"
}
}backtest.py and live.py connect to when you run the exported code.| Key | What it is |
|---|---|
BYBIT_API_KEY | Bybit API key (system-generated, HMAC). Sandbox mode needs a key created in Demo Trading. |
BYBIT_API_SECRET | Bybit API secret; shown once when the key is created. |
.env.TRADING_MODE=paper(default): simulated fills on your machine; the broker is never contacted.TRADING_MODE=sandbox: orders go to Bybit’s demo trading account (api-demo.bybit.com).TRADING_MODE=live: real orders, and only onceLIVE_TRADING_ACKNOWLEDGED=yesis set.
New to Bybit? Follow the step-by-step Bybit API key guide.
Bybit API: frequently asked questions
Can I use Bybit from the United States?
No. Bybit does not serve US residents, and it restricts several other jurisdictions. Use Kraken, Alpaca or Binance.US instead.
Why did my Bybit API key stop working?
Read-write keys that are not bound to an IP address expire after three months. Bind the key to your server’s IP to keep it from expiring.
Is Bybit kline data free?
Yes. Market endpoints are public and need no key.
Build a Bybit trading bot in minutes
Describe the strategy in plain English, backtest it on years of data, then export Python that already talks to Bybit: paper, sandbox and live modes, keys handled for you.
- Generated adapter for Bybit orders and balances
- Backtests with costs, slippage and walk-forward checks
- Paper first; live trading only after you opt in
Free plan, no card required. Bybit is included with Pro.
Bybit alternatives
- OKX API Built into AlgoGPMajor crypto exchange with a V5 REST and WebSocket API for spot, perpetuals, futures and options, plus demo trading.
- Binance API Built into AlgoGPThe largest crypto exchange by volume, with a deep public market-data API and a free spot testnet.
- Kraken API Built into AlgoGPLong-running, US-available crypto exchange with granular API key permissions and public OHLC data.
- Hyperliquid API GuideOn-chain perpetuals and spot exchange with a REST and WebSocket API; trading actions are signed with a wallet key.
Independent guide. AlgoGP is not affiliated with Bybit. Limits, prices and availability change; confirm them in the official documentation. Nothing here is investment advice.