diff --git a/docs/BITGET_SDK_QUICKSTART_GUIDE.md b/docs/BITGET_SDK_QUICKSTART_GUIDE.md index 93cbd63..faf6475 100644 --- a/docs/BITGET_SDK_QUICKSTART_GUIDE.md +++ b/docs/BITGET_SDK_QUICKSTART_GUIDE.md @@ -1,7 +1,217 @@ + # Bitget API JavaScript Tutorial for Node.js and TypeScript + > [!TIP] > This tutorial is available in a more readable format on our website: [Bitget JavaScript Tutorial](https://siebly.io/sdk/bitget/javascript/tutorial) + This guide shows how to connect to Bitget with our [`bitget-api`](https://www.npmjs.com/package/bitget-api) package - the Bitget Node.js, JavaScript, and TypeScript SDK by Siebly.io. You'll cover REST, WebSocket streams, and the WebSocket API. @@ -21,6 +231,7 @@ The SDK handles signing, routing, reconnects, and resubscribes so you don't have --- + ## Why use the SDK Bitget has several API surfaces, and they don't all work the same way: @@ -48,6 +259,7 @@ For new UTA work, start with `RestClientV3`, `WebsocketClientV3`, and `Websocket --- + ## Installation & API Keys Install the SDK with npm: @@ -81,6 +293,7 @@ When creating API keys, grant the minimum permissions you need. Dashboards usual --- + ## Bitget concepts in this guide Bitget has a few naming differences across their API: @@ -106,6 +319,7 @@ Order option casing can differ by surface. V3 REST order requests use `reduceOnl --- + ## Start building: first REST API calls Want the quickest path to something working? Start here. @@ -114,6 +328,7 @@ Want the quickest path to something working? Start here. Public REST calls work without credentials. + ```typescript import { RestClientV3 } from 'bitget-api'; @@ -162,6 +377,7 @@ See also: [V3 public REST examples](../examples/V3%20-%20UTA/Rest) Private REST uses the same `RestClientV3` with credentials - the SDK signs requests for you. + ```typescript import { RestClientV3 } from 'bitget-api'; @@ -204,6 +420,7 @@ See also: [V3 private REST examples](../examples/V3%20-%20UTA/Rest) `WebsocketClientV3` handles V3/UTA streams. Public ones don't need credentials. + ```typescript import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; @@ -260,6 +477,7 @@ See also: [V3 public WebSocket example](../examples/V3%20-%20UTA/Websocket/ws-pu Private streams are where trading systems usually watch account and order changes instead of polling constantly. + ```typescript import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api'; @@ -323,6 +541,7 @@ Test with demo keys before going live. Demo uses separate Bitget API keys. The snippet below sets `demoTrading: true` - leave it on while testing. A successful response means Bitget accepted the order, not that it filled. + ```typescript import { RestClientV3 } from 'bitget-api'; @@ -390,6 +609,7 @@ The WebSocket API sends order commands over a persistent connection and waits fo This example uses `demoTrading: true` with demo API keys. + ```typescript import { WebsocketAPIClient } from 'bitget-api'; @@ -455,6 +675,7 @@ See also: [V3 WebSocket API client example](../examples/V3%20-%20UTA/WS-API/ws-a --- + ## V3 REST API `RestClientV3` is the client for current Bitget UTA REST endpoints. @@ -643,6 +864,7 @@ await client.submitNewOrder({ --- + ## V3 WebSocket streams For live market or account updates, use `WebsocketClientV3`. @@ -746,6 +968,7 @@ The SDK remembers subscriptions per connection and resubscribes after reconnects --- + ## V3 WebSocket API `WebsocketAPIClient` sends V3 order commands over WebSocket and returns a promise for each response. @@ -813,6 +1036,7 @@ await wsApi.submitNewOrder('usdt-futures', { --- + ## V2/Classic APIs Reach for V2/Classic clients only when the account or workflow still uses Classic APIs. Don't mix V2 and V3 assumptions - category names, topics, request fields, and account modes all differ. @@ -875,6 +1099,7 @@ See also: [V2 WebSocket examples](../examples/V2%20-%20Classic/Websocket) --- + ## Production notes ### 1. Roll out in layers @@ -907,6 +1132,7 @@ Separate live and demo keys. Read-only keys for dashboards. Trading permissions --- + ## FAQ ### Do I need API keys for public market data? @@ -951,11 +1177,12 @@ More in the repo: - [V3/UTA examples](../examples/V3%20-%20UTA) - [V2/Classic examples](../examples/V2%20-%20Classic) -- [Auth examples](../examples/auth) +- [Auth examples](../examples/Auth) - [Bitget JavaScript Endpoint Reference](./endpointFunctionList.md) --- + ## Next steps - [Bitget JavaScript SDK page](https://siebly.io/sdk/bitget/javascript)