Built into AlgoGP Pro
BrokerMarket dataCrypto API key

Bybit API guide

Bybit’s v5 API puts spot, linear perpetuals, inverse contracts and options behind one set of endpoints, switched by a category parameter. Its Demo Trading service runs on real mainnet prices with virtual funds, which makes it a practical exchange for testing crypto bots end to end.

Last verified

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 Trading https://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.basePrecision from /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"
  }
}
In-app backtests always use AlgoGP’s normalized history so results stay comparable; this choice decides what backtest.py and live.py connect to when you run the exported code.
KeyWhat it is
BYBIT_API_KEYBybit API key (system-generated, HMAC). Sandbox mode needs a key created in Demo Trading.
BYBIT_API_SECRETBybit API secret; shown once when the key is created.
Names the generated code reads. Add values under Keys & secrets or in a local .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 once LIVE_TRADING_ACKNOWLEDGED=yes is 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

Independent guide. AlgoGP is not affiliated with Bybit. Limits, prices and availability change; confirm them in the official documentation. Nothing here is investment advice.