{"id":2446,"date":"2025-07-11T11:13:54","date_gmt":"2025-07-11T15:13:54","guid":{"rendered":"https:\/\/vezgo.com\/blog\/?p=2446"},"modified":"2025-07-11T11:13:57","modified_gmt":"2025-07-11T15:13:57","slug":"bybit-api-cheat-sheet-for-developers","status":"publish","type":"post","link":"https:\/\/vezgo.com\/blog\/bybit-api-cheat-sheet-for-developers\/","title":{"rendered":"Bybit API Cheat Sheet: A Detailed Developer\u2019s Guide"},"content":{"rendered":"<div class=\"initial-letter\">\n<p>The digital asset space continues to grow at an extraordinary pace. Every new day brings another protocol, another layer, and another opportunity for you to build tools that matter. If you are developing a trading platform, a crypto portfolio manager, or an automated bot, chances are you need programmatic access to exchanges. One of the key exchanges offering a rich and robust API interface is Bybit. This guide provides an overall and accessible breakdown of the most common and practical Bybit API commands, so you don&#8217;t have to dig through extensive documentation. We\u2019ll walk you through each API category, providing examples, a brief description, and helpful tips to ensure a smooth integration.<\/p>\n\n\n\n<p>Before diving into specific commands, let\u2019s start with an overview of what makes Bybit\u2019s API so worthwhile and developer-friendly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to the Bybit API Cheat Sheet<\/h2>\n\n\n\n<p>The Bybit API is a set of RESTful and WebSocket interfaces that provide access to a wide range of exchange functionalities. You can query market data, place and cancel orders, fetch account balances, manage positions, and subscribe to real-time data streams. Bybit supports both linear and inverse contracts, as well as spot trading. The API has a rate limit in place, but it\u2019s generous enough for most applications, especially if you handle retries and throttling properly.<\/p>\n\n\n\n<p>You will find three major types of API endpoints here: public endpoints for market data that do not require authentication, private endpoints for account-level interactions, and WebSocket streams for real-time updates. You can <a href=\"https:\/\/vezgo.com\/status\/bybit-api\">integrate with the Bybit API<\/a> using either your API key and secret pair or OAuth credentials, depending on the use case.<\/p>\n\n\n\n<p>Authentication uses HMAC SHA256 signatures and requires precise timestamping. Keeping your <a href=\"https:\/\/vezgo.com\/blog\/private-key-vs-seed-phrase\/\">private keys and seed phrases<\/a> secure when making authenticated calls is critical. For every request, especially those involving asset transfers or order placement, it\u2019s essential to implement safeguards on the client side.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Section 1: Public Market Data Endpoints<\/h2>\n\n\n\n<p>You do not need any API key to use these endpoints. They help fetch trading pairs, order books, tickers, and historical candles. These endpoints are critical for building charts, dashboards, and analytics interfaces.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get Symbol List<\/h3>\n\n\n\n<p>Returns the list of active trading pairs (both spot and derivatives).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/market\/instruments-info<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Get Order Book<\/h3>\n\n\n\n<p>Use this to retrieve the current state of the order book for a given symbol.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/market\/orderbook<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>category = spot, linear, inverse<br><\/li>\n\n\n\n<li>symbol = Trading pair like BTCUSDT<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Get Ticker Price<\/h3>\n\n\n\n<p>Returns the latest trade price and 24-hour stats.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/market\/tickers<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>category = spot or contract<br><\/li>\n\n\n\n<li>symbol = Optional, if omitted will return all<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Get Kline Candlestick Data<\/h3>\n\n\n\n<p>Retrieve OHLCV data for chart plotting.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/market\/kline<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>category<br><\/li>\n\n\n\n<li>symbol<br><\/li>\n\n\n\n<li>interval<br><\/li>\n\n\n\n<li>start and end<br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Section 2: Account and Wallet Endpoints<\/h2>\n\n\n\n<p>This section requires authentication. These endpoints let you view balances, wallet activity, and margin status. You will need to sign requests using your API key and secret.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get Wallet Balance<\/h3>\n\n\n\n<p>Fetches wallet balances for your account.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/account\/wallet-balance<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>accountType = UNIFIED, CONTRACT, SPOT<br><\/li>\n<\/ul>\n\n\n\n<p>This is where many developers start when trying to build a tracker. It&#8217;s also an area that should be explored in <a href=\"https:\/\/vezgo.com\/blog\/crypto-wallet-apis-developers-businesses\/\">our comprehensive guide to Crypto Wallet APIs for developers and businesses<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get Coin Information<\/h3>\n\n\n\n<p>Displays your coin-specific wallet statistics, including available and used margin.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/account\/coin-greeks<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Query Transaction History<\/h3>\n\n\n\n<p>Gives deposit, withdrawal, and transfer history.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/account\/transaction-log<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>category<br><\/li>\n\n\n\n<li>type<br><\/li>\n\n\n\n<li>start and end<br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Section 3: Orders and Trade Management (Write APIs)<\/h2>\n\n\n\n<p>This section contains write APIs, allowing you to execute trades, cancel them, or replace them. It&#8217;s essential to understand what differentiates these from read APIs, which only retrieve data. The distinction is crucial when <a href=\"https:\/\/vezgo.com\/blog\/read-api-vs-write-api\/\">comparing read APIs with write APIs<\/a> in terms of performance and risk control.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Place Order<\/h3>\n\n\n\n<p>Places a new order on spot or contract markets.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST \/v5\/order\/create<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>category<br><\/li>\n\n\n\n<li>symbol<br><\/li>\n\n\n\n<li>side (Buy or Sell)<br><\/li>\n\n\n\n<li>orderType (Limit or Market)<br><\/li>\n\n\n\n<li>qty, price, etc.<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Cancel Order<\/h3>\n\n\n\n<p>Cancel a previously placed order.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST \/v5\/order\/cancel<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>orderId or orderLinkId<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Get Active Orders<\/h3>\n\n\n\n<p>Returns currently open orders.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/order\/realtime<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>symbol<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Get Order History<\/h3>\n\n\n\n<p>Retrieves a full history of order activity.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/order\/history<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Section 4: Position Management Endpoints<\/h2>\n\n\n\n<p>For derivatives, understanding positions is vital. These endpoints enable you to query and manage your open positions, including leverage, margin mode, and other settings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get Open Positions<\/h3>\n\n\n\n<p>Fetches currently open positions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/position\/list<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>category<br><\/li>\n\n\n\n<li>symbol (optional)<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Switch Margin Mode<\/h3>\n\n\n\n<p>Change between ISOLATED and CROSS margin modes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST \/v5\/position\/switch-isolated<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Set Leverage<\/h3>\n\n\n\n<p>Update leverage for a specific symbol.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST \/v5\/position\/set-leverage<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>buyLeverage and sellLeverage<br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Section 5: Trade History and Executions<\/h2>\n\n\n\n<p>You will often want to get a list of past trades, either for reconciliation or reporting purposes. This section helps you access those granular details.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get Trade History<\/h3>\n\n\n\n<p>Returns past executed orders.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/execution\/list<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>category<br><\/li>\n\n\n\n<li>symbol<br><\/li>\n\n\n\n<li>orderId (optional)<br><\/li>\n\n\n\n<li>start and end (optional)<br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Section 6: Transfer and Asset Movement<\/h2>\n\n\n\n<p>If you manage multiple subaccounts or automate fund transfers, these endpoints are crucial.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Internal Transfer<\/h3>\n\n\n\n<p>Transfer assets between spot, derivatives, and unified accounts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST \/v5\/asset\/transfer\/inter-transfer<\/code><\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>fromAccountType<br><\/li>\n\n\n\n<li>toAccountType<br><\/li>\n\n\n\n<li>coin, amount<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Get Transfer History<\/h3>\n\n\n\n<p>Monitor all past transfer events.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/v5\/asset\/transfer\/query-inter-transfer-list<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Section 7: WebSocket for Real-Time Streaming<\/h2>\n\n\n\n<p>For high-frequency trading or applications that need instant updates, WebSocket is a better choice than REST. You can subscribe to receive updates on order book changes, tickers, user trades, and wallet changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Public Topics (No Auth)<\/h3>\n\n\n\n<p>Connect to WebSocket and subscribe to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>OrderBook (orderbook.1.BTCUSDT)<br><\/li>\n\n\n\n<li>Ticker (tickers.BTCUSDT)<br><\/li>\n\n\n\n<li>Kline (kline.1.BTCUSDT)<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Private Topics (Auth Required)<\/h3>\n\n\n\n<p>Subscribe to user-centric data:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Positions<br><\/li>\n\n\n\n<li>Executions<br><\/li>\n\n\n\n<li>Orders<br><\/li>\n\n\n\n<li>Wallet updates<br><\/li>\n<\/ul>\n\n\n\n<p>WebSocket URLs:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Public: wss:\/\/stream.bybit.com\/v5\/public<br><\/li>\n\n\n\n<li>Private: wss:\/\/stream.bybit.com\/v5\/private<br><\/li>\n<\/ul>\n\n\n\n<p>Authentication over WebSocket requires a signed message using your API credentials.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Rate Limits and Best Practices<\/h2>\n\n\n\n<p>Bybit applies per-endpoint rate limits and general account-wide restrictions. Use the X-RateLimit-Reset and Retry-After headers to manage throttling. Try not to poll high-frequency endpoints needlessly. Use WebSocket where you can.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">General Rate Limit Info<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>REST API: Typically 20 requests per second<br><\/li>\n\n\n\n<li>WebSocket: Use pings to maintain session<br><\/li>\n\n\n\n<li>Burst requests are discouraged<br><\/li>\n<\/ul>\n\n\n\n<p>Always implement exponential backoff on failed requests. Never store your private keys and seed phrases in plain text. Use environment variables and encrypted storage. Bybit also supports IP whitelisting and granular API key permissions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Authentication and Signature Walkthrough<\/h2>\n\n\n\n<p>To make authenticated requests, you must include these headers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>X-BAPI-API-KEY\n\nX-BAPI-TIMESTAMP\n\nX-BAPI-SIGN\n\nX-BAPI-RECV-WINDOW<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Signature Format<\/h3>\n\n\n\n<p>You\u2019ll need to hash your request using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scss\n\nHMAC_SHA256(secret, timestamp + apiKey + recvWindow + body)<\/code><\/pre>\n\n\n\n<p>The recvWindow should typically be 5000 (5 seconds), and the timestamp must be in milliseconds.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Error Handling<\/h2>\n\n\n\n<p>Bybit returns standard HTTP response codes and a retCode inside the JSON body. Here are common ones:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>0: Success<br><\/li>\n\n\n\n<li>10001: Parameter error<br><\/li>\n\n\n\n<li>10006: Invalid signature<br><\/li>\n\n\n\n<li>10016: Rate limit<br><\/li>\n<\/ul>\n\n\n\n<p>Your integration should gracefully handle timeouts and retries. Always verify the contents of responses, especially for fund transfers and order placements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary and Final Thoughts<\/h2>\n\n\n\n<p>The Bybit API is one of the most complete trading APIs available to developers. With both REST and WebSocket capabilities, support for spot and derivatives, and high-level controls for account and trade management, it is well-suited for a wide range of applications. As you proceed to integrate with the Bybit API, always monitor your usage, handle errors properly, and store sensitive data securely.<\/p>\n\n\n\n<p>This guide aims to surface the most useful and frequently used endpoints in one place. Instead of spending time scouring the official docs for each call, you now have a complete cheat sheet to move faster. From market data to real-time updates, you can now create, monitor, and manage your crypto trading infrastructure with Bybit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Vezgo: The Crypto API<\/h2>\n\n\n\n<p>As you explore ways to expand your application beyond Bybit and unify crypto data across multiple platforms, <a href=\"http:\/\/vezgo.com\">Vezgo stands out as the all-in-one solution<\/a> tailored for developers and businesses alike. Vezgo is a universal crypto API designed to simplify integration by aggregating balances, positions, and transactions across hundreds of exchanges, wallets, and blockchains. With just one secure connection, your users can link their entire portfolio, from centralized exchanges like Binance and Bybit to decentralized wallets and even NFT holdings, without any manual input. The <a href=\"https:\/\/vezgo.com\/features\/connect-flow-widget\/\">Vezgo Connect Flow<\/a> provides a seamless onboarding experience, allowing users to authenticate and link their crypto accounts with just a few clicks, thereby eliminating the need to build multiple custom integrations from scratch.<\/p>\n\n\n\n<p>When it comes to data, Vezgo gives you robust and reliable access to the information that matters most. Through a single API call, you can retrieve comprehensive <a href=\"https:\/\/vezgo.com\/features\/balances\/\">balances and positions<\/a>, including token holdings in native and fiat values. Vezgo also provides full <a href=\"https:\/\/vezgo.com\/features\/wallet-transaction-history\/\">transaction history<\/a> across CEXs, blockchains, and wallets, allowing you to track user activity with accuracy and consistency. The API ensures standardized outputs regardless of the source, which simplifies your backend processing and improves data quality across your platform. From token swaps on Ethereum to wallet transfers on Solana, the Vezgo API delivers clean and normalized data without added complexity.<\/p>\n\n\n\n<p>Security is deeply embedded in Vezgo\u2019s infrastructure. The platform is <a href=\"https:\/\/vezgo.com\/security\/\">SOC 2 Type II compliant and uses industry-grade encryption protocols like AES 256 and TLS 1.2<\/a> to safeguard all data in transit and at rest. Developers benefit from clean, well-structured <a href=\"https:\/\/vezgo.com\/docs\/\">API documentation<\/a> that makes integration intuitive and fast, even for complex use cases. Additionally, Vezgo provides hands-on <a href=\"https:\/\/vezgo.com\/contact\/\">support<\/a> to help you troubleshoot, scale, and deploy your integrations with confidence. You may be building a crypto portfolio tracker, accounting software, or a tax platform. Vezgo equips you with the foundation to grow securely and efficiently, saving you time and development overhead while ensuring your users receive the most accurate and up-to-date insights across all their crypto assets.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<p><\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The digital asset space continues to grow at an extraordinary pace. Every new day brings another protocol, another layer, and another opportunity for you to build tools that matter. If you are developing a trading platform, a crypto portfolio manager, or an automated bot, chances are you need programmatic access to exchanges. One of the [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":2465,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-2446","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge"],"_links":{"self":[{"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/posts\/2446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/comments?post=2446"}],"version-history":[{"count":1,"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/posts\/2446\/revisions"}],"predecessor-version":[{"id":2457,"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/posts\/2446\/revisions\/2457"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/media\/2465"}],"wp:attachment":[{"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/media?parent=2446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/categories?post=2446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vezgo.com\/blog\/wp-json\/wp\/v2\/tags?post=2446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}