chub-dev 0.1.0 → 0.1.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/bin/chub-mcp +2 -0
- package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
- package/dist/airtable/docs/database/python/DOC.md +1735 -0
- package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
- package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
- package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
- package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
- package/dist/asana/docs/tasks/DOC.md +1396 -0
- package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
- package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
- package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
- package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
- package/dist/auth0/docs/identity/python/DOC.md +1199 -0
- package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
- package/dist/aws/docs/s3/python/DOC.md +1807 -0
- package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
- package/dist/binance/docs/trading/python/DOC.md +1454 -0
- package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
- package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
- package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
- package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
- package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
- package/dist/clerk/docs/auth/python/DOC.md +274 -0
- package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
- package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
- package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
- package/dist/cohere/docs/llm/DOC.md +1335 -0
- package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
- package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
- package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
- package/dist/deepgram/docs/speech/python/DOC.md +685 -0
- package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
- package/dist/deepl/docs/translation/python/DOC.md +944 -0
- package/dist/deepseek/docs/llm/DOC.md +1220 -0
- package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
- package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
- package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
- package/dist/discord/docs/bot/python/DOC.md +1130 -0
- package/dist/elasticsearch/docs/search/DOC.md +1634 -0
- package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
- package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
- package/dist/firebase/docs/auth/DOC.md +1015 -0
- package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
- package/dist/gemini/docs/genai/python/DOC.md +555 -0
- package/dist/github/docs/octokit/DOC.md +1560 -0
- package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
- package/dist/google/docs/bigquery/python/DOC.md +1503 -0
- package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
- package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
- package/dist/huggingface/docs/transformers/DOC.md +948 -0
- package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
- package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
- package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
- package/dist/jira/docs/issues/python/DOC.md +1492 -0
- package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
- package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
- package/dist/landingai-ade/docs/api/DOC.md +620 -0
- package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
- package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
- package/dist/landingai-ade/skills/SKILL.md +489 -0
- package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
- package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
- package/dist/linear/docs/tracker/DOC.md +1554 -0
- package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
- package/dist/livekit/docs/realtime/python/DOC.md +163 -0
- package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
- package/dist/meilisearch/docs/search/DOC.md +1241 -0
- package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
- package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
- package/dist/mongodb/docs/atlas/DOC.md +2041 -0
- package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
- package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
- package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
- package/dist/okta/docs/identity/python/DOC.md +1401 -0
- package/dist/openai/docs/chat/javascript/DOC.md +407 -0
- package/dist/openai/docs/chat/python/DOC.md +568 -0
- package/dist/paypal/docs/checkout/DOC.md +278 -0
- package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
- package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
- package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
- package/dist/plaid/docs/banking/python/DOC.md +1203 -0
- package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
- package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
- package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
- package/dist/prisma/docs/orm/python/DOC.md +1317 -0
- package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
- package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
- package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
- package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
- package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
- package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
- package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
- package/dist/redis/docs/key-value/python/DOC.md +2054 -0
- package/dist/registry.json +2817 -0
- package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
- package/dist/resend/docs/email/DOC.md +1271 -0
- package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
- package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
- package/dist/search-index.json +1 -0
- package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
- package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
- package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
- package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
- package/dist/shopify/docs/storefront/DOC.md +457 -0
- package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
- package/dist/slack/docs/workspace/python/DOC.md +271 -0
- package/dist/square/docs/payments/javascript/DOC.md +1855 -0
- package/dist/square/docs/payments/python/DOC.md +1728 -0
- package/dist/stripe/docs/api/DOC.md +1727 -0
- package/dist/stripe/docs/payments/DOC.md +1726 -0
- package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
- package/dist/stytch/docs/auth/python/DOC.md +1962 -0
- package/dist/supabase/docs/client/DOC.md +1606 -0
- package/dist/twilio/docs/messaging/python/DOC.md +469 -0
- package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
- package/dist/vercel/docs/platform/DOC.md +1940 -0
- package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
- package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
- package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
- package/dist/zendesk/docs/support/python/DOC.md +2297 -0
- package/package.json +22 -6
- package/skills/get-api-docs/SKILL.md +84 -0
- package/src/commands/annotate.js +83 -0
- package/src/commands/build.js +12 -1
- package/src/commands/feedback.js +150 -0
- package/src/commands/get.js +83 -42
- package/src/commands/search.js +7 -0
- package/src/index.js +43 -17
- package/src/lib/analytics.js +90 -0
- package/src/lib/annotations.js +57 -0
- package/src/lib/bm25.js +170 -0
- package/src/lib/cache.js +69 -6
- package/src/lib/config.js +8 -3
- package/src/lib/identity.js +99 -0
- package/src/lib/registry.js +103 -20
- package/src/lib/telemetry.js +86 -0
- package/src/mcp/server.js +177 -0
- package/src/mcp/tools.js +251 -0
|
@@ -0,0 +1,1315 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trading
|
|
3
|
+
description: "Binance API JavaScript/TypeScript coding guidelines for trading using official libraries and SDKs"
|
|
4
|
+
metadata:
|
|
5
|
+
languages: "javascript"
|
|
6
|
+
versions: "3.6.1"
|
|
7
|
+
updated-on: "2026-03-02"
|
|
8
|
+
source: maintainer
|
|
9
|
+
tags: "binance,trading,crypto,exchange,api"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Binance API JavaScript/TypeScript Coding Guidelines
|
|
13
|
+
|
|
14
|
+
You are a Binance API coding expert. Help me with writing code using the Binance API calling the official libraries and SDKs.
|
|
15
|
+
|
|
16
|
+
You can find the official documentation here:
|
|
17
|
+
https://developers.binance.com/docs/binance-spot-api-docs
|
|
18
|
+
|
|
19
|
+
## Golden Rule: Use the Correct and Current SDK
|
|
20
|
+
|
|
21
|
+
Always use the official Binance Connector for Node.js, which is the standard library for all Binance Spot API interactions. Do not use unofficial or third-party libraries.
|
|
22
|
+
|
|
23
|
+
- **Library Name:** Binance Connector for Node.js
|
|
24
|
+
- **NPM Package:** `@binance/connector`
|
|
25
|
+
- **Alternative Official Packages:** `@binance/spot` (newer modular package), `@binance/futures-connector`, `@binance/pay`
|
|
26
|
+
- **Unofficial Libraries:** `binance-api-node`, `node-binance-api` (not recommended for production)
|
|
27
|
+
|
|
28
|
+
**Installation:**
|
|
29
|
+
|
|
30
|
+
- **Correct:** `npm install @binance/connector`
|
|
31
|
+
- **Alternative:** `npm install @binance/spot` (for newer modular approach)
|
|
32
|
+
|
|
33
|
+
**APIs and Usage:**
|
|
34
|
+
|
|
35
|
+
- **Correct:** `const { Spot } = require('@binance/connector')`
|
|
36
|
+
- **Correct:** `const client = new Spot(apiKey, apiSecret)`
|
|
37
|
+
- **Correct:** `client.account()` for account information
|
|
38
|
+
- **Correct:** `client.newOrder()` for placing orders
|
|
39
|
+
- **Incorrect:** Using unofficial packages like `binance-api-node`
|
|
40
|
+
- **Incorrect:** Direct HTTP requests without using the connector
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Install the official Binance connector for Node.js:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @binance/connector
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For TypeScript projects, the package includes built-in type definitions.
|
|
51
|
+
|
|
52
|
+
**Environment Variables:**
|
|
53
|
+
|
|
54
|
+
Set your API credentials as environment variables:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
export BINANCE_API_KEY='your_api_key_here'
|
|
58
|
+
export BINANCE_API_SECRET='your_api_secret_here'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or create a `.env` file:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
BINANCE_API_KEY=your_api_key_here
|
|
65
|
+
BINANCE_API_SECRET=your_api_secret_here
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Initialization
|
|
69
|
+
|
|
70
|
+
The `@binance/connector` library requires creating a `Spot` instance for all API calls.
|
|
71
|
+
|
|
72
|
+
### Basic Initialization (Public Endpoints)
|
|
73
|
+
|
|
74
|
+
For public market data endpoints that don't require authentication:
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
const { Spot } = require('@binance/connector')
|
|
78
|
+
|
|
79
|
+
// Public endpoints only (no authentication)
|
|
80
|
+
const client = new Spot()
|
|
81
|
+
|
|
82
|
+
// Use client for public data
|
|
83
|
+
client.exchangeInfo()
|
|
84
|
+
.then(response => console.log(response.data))
|
|
85
|
+
.catch(error => console.error(error))
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Authenticated Initialization (HMAC)
|
|
89
|
+
|
|
90
|
+
For trading and account endpoints:
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
const { Spot } = require('@binance/connector')
|
|
94
|
+
|
|
95
|
+
const apiKey = process.env.BINANCE_API_KEY
|
|
96
|
+
const apiSecret = process.env.BINANCE_API_SECRET
|
|
97
|
+
|
|
98
|
+
// Authenticated client with HMAC
|
|
99
|
+
const client = new Spot(apiKey, apiSecret)
|
|
100
|
+
|
|
101
|
+
// Use client for authenticated endpoints
|
|
102
|
+
client.account()
|
|
103
|
+
.then(response => console.log(response.data))
|
|
104
|
+
.catch(error => console.error(error))
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### RSA/ED25519 Authentication
|
|
108
|
+
|
|
109
|
+
For enhanced security using RSA or ED25519 private keys:
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
const { Spot, PrivateKeyAlgo } = require('@binance/connector')
|
|
113
|
+
const fs = require('fs')
|
|
114
|
+
|
|
115
|
+
const apiKey = process.env.BINANCE_API_KEY
|
|
116
|
+
const privateKey = fs.readFileSync('/path/to/private_key.pem', 'utf8')
|
|
117
|
+
const privateKeyPassphrase = 'your_passphrase' // Optional
|
|
118
|
+
const privateKeyAlgo = PrivateKeyAlgo.RSA // or PrivateKeyAlgo.ED25519
|
|
119
|
+
|
|
120
|
+
const client = new Spot(apiKey, '', {
|
|
121
|
+
privateKey,
|
|
122
|
+
privateKeyPassphrase,
|
|
123
|
+
privateKeyAlgo
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Client Configuration Options
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
const { Spot } = require('@binance/connector')
|
|
131
|
+
|
|
132
|
+
const client = new Spot(apiKey, apiSecret, {
|
|
133
|
+
baseURL: 'https://api.binance.com', // Default base URL
|
|
134
|
+
timeout: 10000, // Request timeout in milliseconds (default: 10000)
|
|
135
|
+
recvWindow: 5000, // API timing security (default: 5000)
|
|
136
|
+
logger: console // Custom logger (optional)
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Testnet Configuration
|
|
141
|
+
|
|
142
|
+
For testing without real funds:
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
const { Spot } = require('@binance/connector')
|
|
146
|
+
|
|
147
|
+
const client = new Spot(apiKey, apiSecret, {
|
|
148
|
+
baseURL: 'https://testnet.binance.vision'
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Proxy Configuration
|
|
153
|
+
|
|
154
|
+
For requests through a proxy:
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
const { Spot } = require('@binance/connector')
|
|
158
|
+
|
|
159
|
+
const client = new Spot(apiKey, apiSecret, {
|
|
160
|
+
proxy: {
|
|
161
|
+
protocol: 'https',
|
|
162
|
+
host: '127.0.0.1',
|
|
163
|
+
port: 9000,
|
|
164
|
+
auth: {
|
|
165
|
+
username: 'proxy_user',
|
|
166
|
+
password: 'proxy_password'
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Market Data Endpoints
|
|
173
|
+
|
|
174
|
+
Market data endpoints provide access to public trading information without authentication.
|
|
175
|
+
|
|
176
|
+
### Exchange Information
|
|
177
|
+
|
|
178
|
+
Get exchange trading rules and symbol information:
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
const { Spot } = require('@binance/connector')
|
|
182
|
+
|
|
183
|
+
const client = new Spot()
|
|
184
|
+
|
|
185
|
+
// Get all exchange information
|
|
186
|
+
client.exchangeInfo()
|
|
187
|
+
.then(response => console.log(response.data))
|
|
188
|
+
.catch(error => console.error(error))
|
|
189
|
+
|
|
190
|
+
// Get specific symbol information
|
|
191
|
+
client.exchangeInfo({ symbol: 'BTCUSDT' })
|
|
192
|
+
.then(response => console.log(response.data))
|
|
193
|
+
.catch(error => console.error(error))
|
|
194
|
+
|
|
195
|
+
// Get information for multiple symbols
|
|
196
|
+
client.exchangeInfo({ symbols: ['BTCUSDT', 'ETHUSDT'] })
|
|
197
|
+
.then(response => console.log(response.data))
|
|
198
|
+
.catch(error => console.error(error))
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Order Book (Depth)
|
|
202
|
+
|
|
203
|
+
Get current order book for a symbol:
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
// Get order book with default limit (100)
|
|
207
|
+
client.depth('BTCUSDT')
|
|
208
|
+
.then(response => console.log(response.data))
|
|
209
|
+
.catch(error => console.error(error))
|
|
210
|
+
|
|
211
|
+
// Get order book with specific limit (5, 10, 20, 50, 100, 500, 1000, 5000)
|
|
212
|
+
client.depth('BTCUSDT', { limit: 10 })
|
|
213
|
+
.then(response => console.log(response.data))
|
|
214
|
+
.catch(error => console.error(error))
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Recent Trades
|
|
218
|
+
|
|
219
|
+
Get recent trades for a symbol:
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
// Get recent trades (default limit: 500)
|
|
223
|
+
client.trades('BTCUSDT')
|
|
224
|
+
.then(response => console.log(response.data))
|
|
225
|
+
.catch(error => console.error(error))
|
|
226
|
+
|
|
227
|
+
// Get specific number of recent trades
|
|
228
|
+
client.trades('BTCUSDT', { limit: 100 })
|
|
229
|
+
.then(response => console.log(response.data))
|
|
230
|
+
.catch(error => console.error(error))
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Historical Trades
|
|
234
|
+
|
|
235
|
+
Get older trades (requires API key):
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
const client = new Spot(apiKey, apiSecret)
|
|
239
|
+
|
|
240
|
+
// Get historical trades
|
|
241
|
+
client.historicalTrades('BTCUSDT', { limit: 100 })
|
|
242
|
+
.then(response => console.log(response.data))
|
|
243
|
+
.catch(error => console.error(error))
|
|
244
|
+
|
|
245
|
+
// Get trades from specific ID
|
|
246
|
+
client.historicalTrades('BTCUSDT', { limit: 100, fromId: 28457 })
|
|
247
|
+
.then(response => console.log(response.data))
|
|
248
|
+
.catch(error => console.error(error))
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Aggregate Trades
|
|
252
|
+
|
|
253
|
+
Get compressed, aggregate trades:
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
// Get recent aggregate trades
|
|
257
|
+
client.aggTrades('BTCUSDT')
|
|
258
|
+
.then(response => console.log(response.data))
|
|
259
|
+
.catch(error => console.error(error))
|
|
260
|
+
|
|
261
|
+
// Get aggregate trades with time range
|
|
262
|
+
client.aggTrades('BTCUSDT', {
|
|
263
|
+
startTime: 1609459200000,
|
|
264
|
+
endTime: 1609545600000,
|
|
265
|
+
limit: 1000
|
|
266
|
+
})
|
|
267
|
+
.then(response => console.log(response.data))
|
|
268
|
+
.catch(error => console.error(error))
|
|
269
|
+
|
|
270
|
+
// Get aggregate trades from specific ID
|
|
271
|
+
client.aggTrades('BTCUSDT', { fromId: 28457, limit: 500 })
|
|
272
|
+
.then(response => console.log(response.data))
|
|
273
|
+
.catch(error => console.error(error))
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Candlestick Data (Klines)
|
|
277
|
+
|
|
278
|
+
Get kline/candlestick bars for a symbol:
|
|
279
|
+
|
|
280
|
+
```javascript
|
|
281
|
+
// Get recent klines (default limit: 500)
|
|
282
|
+
client.klines('BTCUSDT', '1h')
|
|
283
|
+
.then(response => console.log(response.data))
|
|
284
|
+
.catch(error => console.error(error))
|
|
285
|
+
|
|
286
|
+
// Get klines with time range
|
|
287
|
+
client.klines('BTCUSDT', '1d', {
|
|
288
|
+
startTime: 1609459200000,
|
|
289
|
+
endTime: 1609545600000,
|
|
290
|
+
limit: 100
|
|
291
|
+
})
|
|
292
|
+
.then(response => console.log(response.data))
|
|
293
|
+
.catch(error => console.error(error))
|
|
294
|
+
|
|
295
|
+
// Available intervals: 1s, 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Current Average Price
|
|
299
|
+
|
|
300
|
+
Get current average price for a symbol:
|
|
301
|
+
|
|
302
|
+
```javascript
|
|
303
|
+
client.avgPrice('BTCUSDT')
|
|
304
|
+
.then(response => console.log(response.data))
|
|
305
|
+
.catch(error => console.error(error))
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### 24hr Ticker Price Change Statistics
|
|
309
|
+
|
|
310
|
+
Get 24-hour rolling window price change statistics:
|
|
311
|
+
|
|
312
|
+
```javascript
|
|
313
|
+
// Get ticker for single symbol
|
|
314
|
+
client.ticker24hr('BTCUSDT')
|
|
315
|
+
.then(response => console.log(response.data))
|
|
316
|
+
.catch(error => console.error(error))
|
|
317
|
+
|
|
318
|
+
// Get ticker for multiple symbols
|
|
319
|
+
client.ticker24hr({ symbols: ['BTCUSDT', 'ETHUSDT'] })
|
|
320
|
+
.then(response => console.log(response.data))
|
|
321
|
+
.catch(error => console.error(error))
|
|
322
|
+
|
|
323
|
+
// Get ticker for all symbols
|
|
324
|
+
client.ticker24hr()
|
|
325
|
+
.then(response => console.log(response.data))
|
|
326
|
+
.catch(error => console.error(error))
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Symbol Price Ticker
|
|
330
|
+
|
|
331
|
+
Get latest price for a symbol:
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
// Get price for single symbol
|
|
335
|
+
client.tickerPrice('BTCUSDT')
|
|
336
|
+
.then(response => console.log(response.data))
|
|
337
|
+
.catch(error => console.error(error))
|
|
338
|
+
|
|
339
|
+
// Get price for multiple symbols
|
|
340
|
+
client.tickerPrice({ symbols: ['BTCUSDT', 'ETHUSDT'] })
|
|
341
|
+
.then(response => console.log(response.data))
|
|
342
|
+
.catch(error => console.error(error))
|
|
343
|
+
|
|
344
|
+
// Get price for all symbols
|
|
345
|
+
client.tickerPrice()
|
|
346
|
+
.then(response => console.log(response.data))
|
|
347
|
+
.catch(error => console.error(error))
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Symbol Order Book Ticker
|
|
351
|
+
|
|
352
|
+
Get best price/quantity on the order book:
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
// Get book ticker for single symbol
|
|
356
|
+
client.bookTicker('BTCUSDT')
|
|
357
|
+
.then(response => console.log(response.data))
|
|
358
|
+
.catch(error => console.error(error))
|
|
359
|
+
|
|
360
|
+
// Get book ticker for multiple symbols
|
|
361
|
+
client.bookTicker({ symbols: ['BTCUSDT', 'ETHUSDT'] })
|
|
362
|
+
.then(response => console.log(response.data))
|
|
363
|
+
.catch(error => console.error(error))
|
|
364
|
+
|
|
365
|
+
// Get book ticker for all symbols
|
|
366
|
+
client.bookTicker()
|
|
367
|
+
.then(response => console.log(response.data))
|
|
368
|
+
.catch(error => console.error(error))
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## Trading Endpoints
|
|
372
|
+
|
|
373
|
+
Trading endpoints require authentication and allow you to place, cancel, and query orders.
|
|
374
|
+
|
|
375
|
+
### New Order
|
|
376
|
+
|
|
377
|
+
Place a new order on the exchange:
|
|
378
|
+
|
|
379
|
+
```javascript
|
|
380
|
+
const { Spot } = require('@binance/connector')
|
|
381
|
+
|
|
382
|
+
const client = new Spot(apiKey, apiSecret)
|
|
383
|
+
|
|
384
|
+
// Market buy order
|
|
385
|
+
client.newOrder('BTCUSDT', 'BUY', 'MARKET', {
|
|
386
|
+
quantity: 0.001
|
|
387
|
+
})
|
|
388
|
+
.then(response => console.log(response.data))
|
|
389
|
+
.catch(error => console.error(error))
|
|
390
|
+
|
|
391
|
+
// Market sell order with quote quantity
|
|
392
|
+
client.newOrder('BTCUSDT', 'SELL', 'MARKET', {
|
|
393
|
+
quoteOrderQty: 100
|
|
394
|
+
})
|
|
395
|
+
.then(response => console.log(response.data))
|
|
396
|
+
.catch(error => console.error(error))
|
|
397
|
+
|
|
398
|
+
// Limit buy order
|
|
399
|
+
client.newOrder('BTCUSDT', 'BUY', 'LIMIT', {
|
|
400
|
+
quantity: 0.001,
|
|
401
|
+
price: 50000,
|
|
402
|
+
timeInForce: 'GTC'
|
|
403
|
+
})
|
|
404
|
+
.then(response => console.log(response.data))
|
|
405
|
+
.catch(error => console.error(error))
|
|
406
|
+
|
|
407
|
+
// Limit sell order
|
|
408
|
+
client.newOrder('BTCUSDT', 'SELL', 'LIMIT', {
|
|
409
|
+
quantity: 0.001,
|
|
410
|
+
price: 60000,
|
|
411
|
+
timeInForce: 'GTC'
|
|
412
|
+
})
|
|
413
|
+
.then(response => console.log(response.data))
|
|
414
|
+
.catch(error => console.error(error))
|
|
415
|
+
|
|
416
|
+
// Stop-loss order
|
|
417
|
+
client.newOrder('BTCUSDT', 'SELL', 'STOP_LOSS_LIMIT', {
|
|
418
|
+
quantity: 0.001,
|
|
419
|
+
price: 48000,
|
|
420
|
+
stopPrice: 49000,
|
|
421
|
+
timeInForce: 'GTC'
|
|
422
|
+
})
|
|
423
|
+
.then(response => console.log(response.data))
|
|
424
|
+
.catch(error => console.error(error))
|
|
425
|
+
|
|
426
|
+
// Take-profit order
|
|
427
|
+
client.newOrder('BTCUSDT', 'SELL', 'TAKE_PROFIT_LIMIT', {
|
|
428
|
+
quantity: 0.001,
|
|
429
|
+
price: 62000,
|
|
430
|
+
stopPrice: 61000,
|
|
431
|
+
timeInForce: 'GTC'
|
|
432
|
+
})
|
|
433
|
+
.then(response => console.log(response.data))
|
|
434
|
+
.catch(error => console.error(error))
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
**Order Types:**
|
|
438
|
+
- `MARKET` - Market order
|
|
439
|
+
- `LIMIT` - Limit order
|
|
440
|
+
- `STOP_LOSS` - Stop-loss order
|
|
441
|
+
- `STOP_LOSS_LIMIT` - Stop-loss limit order
|
|
442
|
+
- `TAKE_PROFIT` - Take-profit order
|
|
443
|
+
- `TAKE_PROFIT_LIMIT` - Take-profit limit order
|
|
444
|
+
- `LIMIT_MAKER` - Limit maker order
|
|
445
|
+
|
|
446
|
+
**Time in Force:**
|
|
447
|
+
- `GTC` - Good Till Cancel
|
|
448
|
+
- `IOC` - Immediate or Cancel
|
|
449
|
+
- `FOK` - Fill or Kill
|
|
450
|
+
|
|
451
|
+
### Test New Order
|
|
452
|
+
|
|
453
|
+
Test order placement without actually placing the order:
|
|
454
|
+
|
|
455
|
+
```javascript
|
|
456
|
+
// Test a limit order
|
|
457
|
+
client.newOrderTest('BTCUSDT', 'BUY', 'LIMIT', {
|
|
458
|
+
quantity: 0.001,
|
|
459
|
+
price: 50000,
|
|
460
|
+
timeInForce: 'GTC'
|
|
461
|
+
})
|
|
462
|
+
.then(response => console.log(response.data))
|
|
463
|
+
.catch(error => console.error(error))
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Query Order
|
|
467
|
+
|
|
468
|
+
Check an order's status:
|
|
469
|
+
|
|
470
|
+
```javascript
|
|
471
|
+
// Query by orderId
|
|
472
|
+
client.getOrder('BTCUSDT', { orderId: 28 })
|
|
473
|
+
.then(response => console.log(response.data))
|
|
474
|
+
.catch(error => console.error(error))
|
|
475
|
+
|
|
476
|
+
// Query by origClientOrderId
|
|
477
|
+
client.getOrder('BTCUSDT', { origClientOrderId: 'myOrder1' })
|
|
478
|
+
.then(response => console.log(response.data))
|
|
479
|
+
.catch(error => console.error(error))
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Cancel Order
|
|
483
|
+
|
|
484
|
+
Cancel an active order:
|
|
485
|
+
|
|
486
|
+
```javascript
|
|
487
|
+
// Cancel by orderId
|
|
488
|
+
client.cancelOrder('BTCUSDT', { orderId: 28 })
|
|
489
|
+
.then(response => console.log(response.data))
|
|
490
|
+
.catch(error => console.error(error))
|
|
491
|
+
|
|
492
|
+
// Cancel by origClientOrderId
|
|
493
|
+
client.cancelOrder('BTCUSDT', { origClientOrderId: 'myOrder1' })
|
|
494
|
+
.then(response => console.log(response.data))
|
|
495
|
+
.catch(error => console.error(error))
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Cancel All Open Orders
|
|
499
|
+
|
|
500
|
+
Cancel all active orders on a symbol:
|
|
501
|
+
|
|
502
|
+
```javascript
|
|
503
|
+
client.cancelOpenOrders('BTCUSDT')
|
|
504
|
+
.then(response => console.log(response.data))
|
|
505
|
+
.catch(error => console.error(error))
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### Cancel and Replace Order
|
|
509
|
+
|
|
510
|
+
Cancel an existing order and place a new order on the same symbol:
|
|
511
|
+
|
|
512
|
+
```javascript
|
|
513
|
+
// Cancel and replace by orderId
|
|
514
|
+
client.cancelReplaceOrder('BTCUSDT', 'BUY', 'LIMIT', 'STOP_ON_FAILURE', {
|
|
515
|
+
cancelOrderId: 28,
|
|
516
|
+
quantity: 0.002,
|
|
517
|
+
price: 51000,
|
|
518
|
+
timeInForce: 'GTC'
|
|
519
|
+
})
|
|
520
|
+
.then(response => console.log(response.data))
|
|
521
|
+
.catch(error => console.error(error))
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### Current Open Orders
|
|
525
|
+
|
|
526
|
+
Get all open orders on a symbol:
|
|
527
|
+
|
|
528
|
+
```javascript
|
|
529
|
+
// Get open orders for specific symbol
|
|
530
|
+
client.openOrders('BTCUSDT')
|
|
531
|
+
.then(response => console.log(response.data))
|
|
532
|
+
.catch(error => console.error(error))
|
|
533
|
+
|
|
534
|
+
// Get all open orders
|
|
535
|
+
client.openOrders()
|
|
536
|
+
.then(response => console.log(response.data))
|
|
537
|
+
.catch(error => console.error(error))
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### All Orders
|
|
541
|
+
|
|
542
|
+
Get all account orders (active, canceled, or filled):
|
|
543
|
+
|
|
544
|
+
```javascript
|
|
545
|
+
// Get all orders for a symbol
|
|
546
|
+
client.allOrders('BTCUSDT')
|
|
547
|
+
.then(response => console.log(response.data))
|
|
548
|
+
.catch(error => console.error(error))
|
|
549
|
+
|
|
550
|
+
// Get orders with time range
|
|
551
|
+
client.allOrders('BTCUSDT', {
|
|
552
|
+
startTime: 1609459200000,
|
|
553
|
+
endTime: 1609545600000,
|
|
554
|
+
limit: 500
|
|
555
|
+
})
|
|
556
|
+
.then(response => console.log(response.data))
|
|
557
|
+
.catch(error => console.error(error))
|
|
558
|
+
|
|
559
|
+
// Get orders from specific orderId
|
|
560
|
+
client.allOrders('BTCUSDT', { orderId: 28, limit: 500 })
|
|
561
|
+
.then(response => console.log(response.data))
|
|
562
|
+
.catch(error => console.error(error))
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### OCO Orders (One-Cancels-the-Other)
|
|
566
|
+
|
|
567
|
+
Place a pair of orders where if one is executed, the other is canceled:
|
|
568
|
+
|
|
569
|
+
```javascript
|
|
570
|
+
// Place OCO order
|
|
571
|
+
client.newOCOOrder('BTCUSDT', 'SELL', 0.001, 62000, 48000, {
|
|
572
|
+
stopLimitPrice: 47500,
|
|
573
|
+
stopLimitTimeInForce: 'GTC'
|
|
574
|
+
})
|
|
575
|
+
.then(response => console.log(response.data))
|
|
576
|
+
.catch(error => console.error(error))
|
|
577
|
+
|
|
578
|
+
// Cancel OCO order
|
|
579
|
+
client.cancelOCOOrder('BTCUSDT', { orderListId: 0 })
|
|
580
|
+
.then(response => console.log(response.data))
|
|
581
|
+
.catch(error => console.error(error))
|
|
582
|
+
|
|
583
|
+
// Query OCO order
|
|
584
|
+
client.getOCOOrder({ orderListId: 0 })
|
|
585
|
+
.then(response => console.log(response.data))
|
|
586
|
+
.catch(error => console.error(error))
|
|
587
|
+
|
|
588
|
+
// Get all OCO orders
|
|
589
|
+
client.getOCOOrders()
|
|
590
|
+
.then(response => console.log(response.data))
|
|
591
|
+
.catch(error => console.error(error))
|
|
592
|
+
|
|
593
|
+
// Get open OCO orders
|
|
594
|
+
client.getOpenOCOOrders()
|
|
595
|
+
.then(response => console.log(response.data))
|
|
596
|
+
.catch(error => console.error(error))
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
## Account Endpoints
|
|
600
|
+
|
|
601
|
+
Account endpoints provide access to account information and require authentication.
|
|
602
|
+
|
|
603
|
+
### Account Information
|
|
604
|
+
|
|
605
|
+
Get current account information:
|
|
606
|
+
|
|
607
|
+
```javascript
|
|
608
|
+
const { Spot } = require('@binance/connector')
|
|
609
|
+
|
|
610
|
+
const client = new Spot(apiKey, apiSecret)
|
|
611
|
+
|
|
612
|
+
client.account()
|
|
613
|
+
.then(response => {
|
|
614
|
+
const data = response.data
|
|
615
|
+
console.log('Account Type:', data.accountType)
|
|
616
|
+
console.log('Can Trade:', data.canTrade)
|
|
617
|
+
console.log('Can Withdraw:', data.canWithdraw)
|
|
618
|
+
console.log('Can Deposit:', data.canDeposit)
|
|
619
|
+
console.log('Balances:', data.balances)
|
|
620
|
+
})
|
|
621
|
+
.catch(error => console.error(error))
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### Account Trade List
|
|
625
|
+
|
|
626
|
+
Get trades for a specific symbol:
|
|
627
|
+
|
|
628
|
+
```javascript
|
|
629
|
+
// Get recent trades
|
|
630
|
+
client.myTrades('BTCUSDT')
|
|
631
|
+
.then(response => console.log(response.data))
|
|
632
|
+
.catch(error => console.error(error))
|
|
633
|
+
|
|
634
|
+
// Get trades with time range
|
|
635
|
+
client.myTrades('BTCUSDT', {
|
|
636
|
+
startTime: 1609459200000,
|
|
637
|
+
endTime: 1609545600000,
|
|
638
|
+
limit: 500
|
|
639
|
+
})
|
|
640
|
+
.then(response => console.log(response.data))
|
|
641
|
+
.catch(error => console.error(error))
|
|
642
|
+
|
|
643
|
+
// Get trades from specific ID
|
|
644
|
+
client.myTrades('BTCUSDT', { fromId: 28457, limit: 500 })
|
|
645
|
+
.then(response => console.log(response.data))
|
|
646
|
+
.catch(error => console.error(error))
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
### Current Order Count Usage
|
|
650
|
+
|
|
651
|
+
Get current order count usage for rate limits:
|
|
652
|
+
|
|
653
|
+
```javascript
|
|
654
|
+
client.rateLimitOrder()
|
|
655
|
+
.then(response => console.log(response.data))
|
|
656
|
+
.catch(error => console.error(error))
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### Query Prevented Matches
|
|
660
|
+
|
|
661
|
+
Get prevented matches from Self-Trade Prevention:
|
|
662
|
+
|
|
663
|
+
```javascript
|
|
664
|
+
client.preventedMatches('BTCUSDT')
|
|
665
|
+
.then(response => console.log(response.data))
|
|
666
|
+
.catch(error => console.error(error))
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
## WebSocket Streams
|
|
670
|
+
|
|
671
|
+
WebSocket streams provide real-time market data with low latency.
|
|
672
|
+
|
|
673
|
+
### WebSocket Stream Client
|
|
674
|
+
|
|
675
|
+
Initialize a WebSocket stream client:
|
|
676
|
+
|
|
677
|
+
```javascript
|
|
678
|
+
const { WebsocketStream } = require('@binance/connector')
|
|
679
|
+
|
|
680
|
+
// Create WebSocket stream client
|
|
681
|
+
const callbacks = {
|
|
682
|
+
open: () => console.log('WebSocket connected'),
|
|
683
|
+
close: () => console.log('WebSocket disconnected'),
|
|
684
|
+
message: data => console.log('Received:', data)
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
### Aggregate Trade Streams
|
|
691
|
+
|
|
692
|
+
Subscribe to aggregate trade updates:
|
|
693
|
+
|
|
694
|
+
```javascript
|
|
695
|
+
const { WebsocketStream } = require('@binance/connector')
|
|
696
|
+
|
|
697
|
+
const callbacks = {
|
|
698
|
+
open: () => console.log('Connected to aggregate trade stream'),
|
|
699
|
+
close: () => console.log('Disconnected from aggregate trade stream'),
|
|
700
|
+
message: data => console.log('Trade:', JSON.parse(data))
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
704
|
+
|
|
705
|
+
// Subscribe to BTCUSDT aggregate trades
|
|
706
|
+
websocketStreamClient.aggTrade('btcusdt')
|
|
707
|
+
|
|
708
|
+
// Unsubscribe
|
|
709
|
+
// websocketStreamClient.unsubscribe('btcusdt@aggTrade')
|
|
710
|
+
|
|
711
|
+
// Disconnect
|
|
712
|
+
// websocketStreamClient.disconnect()
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### Trade Streams
|
|
716
|
+
|
|
717
|
+
Subscribe to raw trade updates:
|
|
718
|
+
|
|
719
|
+
```javascript
|
|
720
|
+
const callbacks = {
|
|
721
|
+
open: () => console.log('Connected to trade stream'),
|
|
722
|
+
close: () => console.log('Disconnected from trade stream'),
|
|
723
|
+
message: data => console.log('Trade:', JSON.parse(data))
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
727
|
+
|
|
728
|
+
// Subscribe to BTCUSDT trades
|
|
729
|
+
websocketStreamClient.trade('btcusdt')
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
### Kline/Candlestick Streams
|
|
733
|
+
|
|
734
|
+
Subscribe to candlestick updates:
|
|
735
|
+
|
|
736
|
+
```javascript
|
|
737
|
+
const callbacks = {
|
|
738
|
+
open: () => console.log('Connected to kline stream'),
|
|
739
|
+
close: () => console.log('Disconnected from kline stream'),
|
|
740
|
+
message: data => console.log('Kline:', JSON.parse(data))
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
744
|
+
|
|
745
|
+
// Subscribe to BTCUSDT 1-minute klines
|
|
746
|
+
websocketStreamClient.kline('btcusdt', '1m')
|
|
747
|
+
|
|
748
|
+
// Available intervals: 1s, 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
### Mini Ticker Streams
|
|
752
|
+
|
|
753
|
+
Subscribe to 24hr mini ticker updates:
|
|
754
|
+
|
|
755
|
+
```javascript
|
|
756
|
+
const callbacks = {
|
|
757
|
+
open: () => console.log('Connected to mini ticker stream'),
|
|
758
|
+
close: () => console.log('Disconnected from mini ticker stream'),
|
|
759
|
+
message: data => console.log('Mini Ticker:', JSON.parse(data))
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
763
|
+
|
|
764
|
+
// Subscribe to BTCUSDT mini ticker
|
|
765
|
+
websocketStreamClient.miniTicker('btcusdt')
|
|
766
|
+
|
|
767
|
+
// Subscribe to all symbols mini ticker
|
|
768
|
+
websocketStreamClient.miniTicker()
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### Ticker Streams
|
|
772
|
+
|
|
773
|
+
Subscribe to 24hr ticker updates:
|
|
774
|
+
|
|
775
|
+
```javascript
|
|
776
|
+
const callbacks = {
|
|
777
|
+
open: () => console.log('Connected to ticker stream'),
|
|
778
|
+
close: () => console.log('Disconnected from ticker stream'),
|
|
779
|
+
message: data => console.log('Ticker:', JSON.parse(data))
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
783
|
+
|
|
784
|
+
// Subscribe to BTCUSDT ticker
|
|
785
|
+
websocketStreamClient.ticker('btcusdt')
|
|
786
|
+
|
|
787
|
+
// Subscribe to all symbols ticker
|
|
788
|
+
websocketStreamClient.ticker()
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
### Individual Symbol Book Ticker Streams
|
|
792
|
+
|
|
793
|
+
Subscribe to best bid/ask updates:
|
|
794
|
+
|
|
795
|
+
```javascript
|
|
796
|
+
const callbacks = {
|
|
797
|
+
open: () => console.log('Connected to book ticker stream'),
|
|
798
|
+
close: () => console.log('Disconnected from book ticker stream'),
|
|
799
|
+
message: data => console.log('Book Ticker:', JSON.parse(data))
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
803
|
+
|
|
804
|
+
// Subscribe to BTCUSDT book ticker
|
|
805
|
+
websocketStreamClient.bookTicker('btcusdt')
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
### Partial Book Depth Streams
|
|
809
|
+
|
|
810
|
+
Subscribe to top bids and asks:
|
|
811
|
+
|
|
812
|
+
```javascript
|
|
813
|
+
const callbacks = {
|
|
814
|
+
open: () => console.log('Connected to partial depth stream'),
|
|
815
|
+
close: () => console.log('Disconnected from partial depth stream'),
|
|
816
|
+
message: data => console.log('Partial Depth:', JSON.parse(data))
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
820
|
+
|
|
821
|
+
// Subscribe to BTCUSDT top 5 levels @ 1000ms
|
|
822
|
+
websocketStreamClient.partialDepth('btcusdt', 5, 1000)
|
|
823
|
+
|
|
824
|
+
// Available levels: 5, 10, 20
|
|
825
|
+
// Available speeds: 1000ms, 100ms
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
### Diff Depth Stream
|
|
829
|
+
|
|
830
|
+
Subscribe to order book price and quantity depth updates:
|
|
831
|
+
|
|
832
|
+
```javascript
|
|
833
|
+
const callbacks = {
|
|
834
|
+
open: () => console.log('Connected to diff depth stream'),
|
|
835
|
+
close: () => console.log('Disconnected from diff depth stream'),
|
|
836
|
+
message: data => console.log('Diff Depth:', JSON.parse(data))
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
840
|
+
|
|
841
|
+
// Subscribe to BTCUSDT depth updates @ 1000ms
|
|
842
|
+
websocketStreamClient.diffDepth('btcusdt', 1000)
|
|
843
|
+
|
|
844
|
+
// Available speeds: 1000ms, 100ms
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
### Combined Streams
|
|
848
|
+
|
|
849
|
+
Subscribe to multiple streams with a single connection:
|
|
850
|
+
|
|
851
|
+
```javascript
|
|
852
|
+
const callbacks = {
|
|
853
|
+
open: () => console.log('Connected to combined stream'),
|
|
854
|
+
close: () => console.log('Disconnected from combined stream'),
|
|
855
|
+
message: data => console.log('Combined:', JSON.parse(data))
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
859
|
+
|
|
860
|
+
// Subscribe to multiple streams
|
|
861
|
+
websocketStreamClient.subscribe([
|
|
862
|
+
'btcusdt@aggTrade',
|
|
863
|
+
'btcusdt@depth',
|
|
864
|
+
'ethusdt@kline_1m',
|
|
865
|
+
'bnbusdt@ticker'
|
|
866
|
+
])
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
## WebSocket API
|
|
870
|
+
|
|
871
|
+
WebSocket API allows bidirectional communication for placing orders, querying data, and more.
|
|
872
|
+
|
|
873
|
+
### WebSocket API Client
|
|
874
|
+
|
|
875
|
+
Initialize a WebSocket API client:
|
|
876
|
+
|
|
877
|
+
```javascript
|
|
878
|
+
const { WebsocketAPI } = require('@binance/connector')
|
|
879
|
+
|
|
880
|
+
const callbacks = {
|
|
881
|
+
open: (client) => console.log('WebSocket API connected'),
|
|
882
|
+
close: () => console.log('WebSocket API disconnected'),
|
|
883
|
+
message: data => console.log('Message:', data)
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
const websocketAPIClient = new WebsocketAPI(apiKey, apiSecret, { callbacks })
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
### Ping/Pong
|
|
890
|
+
|
|
891
|
+
Test connectivity:
|
|
892
|
+
|
|
893
|
+
```javascript
|
|
894
|
+
const { WebsocketAPI } = require('@binance/connector')
|
|
895
|
+
|
|
896
|
+
const callbacks = {
|
|
897
|
+
open: (client) => {
|
|
898
|
+
console.log('WebSocket API connected')
|
|
899
|
+
|
|
900
|
+
// Send ping
|
|
901
|
+
client.ping()
|
|
902
|
+
},
|
|
903
|
+
message: data => {
|
|
904
|
+
console.log('Response:', data)
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
const websocketAPIClient = new WebsocketAPI(apiKey, apiSecret, { callbacks })
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
### Server Time
|
|
912
|
+
|
|
913
|
+
Get server time:
|
|
914
|
+
|
|
915
|
+
```javascript
|
|
916
|
+
const callbacks = {
|
|
917
|
+
open: (client) => {
|
|
918
|
+
console.log('WebSocket API connected')
|
|
919
|
+
|
|
920
|
+
// Get server time
|
|
921
|
+
client.time()
|
|
922
|
+
},
|
|
923
|
+
message: data => {
|
|
924
|
+
console.log('Server Time:', data)
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
const websocketAPIClient = new WebsocketAPI(apiKey, apiSecret, { callbacks })
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
### Order Book via WebSocket API
|
|
932
|
+
|
|
933
|
+
Get order book through WebSocket:
|
|
934
|
+
|
|
935
|
+
```javascript
|
|
936
|
+
const callbacks = {
|
|
937
|
+
open: (client) => {
|
|
938
|
+
console.log('WebSocket API connected')
|
|
939
|
+
|
|
940
|
+
// Get order book
|
|
941
|
+
client.depth('BTCUSDT', { limit: 10 })
|
|
942
|
+
},
|
|
943
|
+
message: data => {
|
|
944
|
+
console.log('Order Book:', data)
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
const websocketAPIClient = new WebsocketAPI(apiKey, apiSecret, { callbacks })
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
### Place Order via WebSocket API
|
|
952
|
+
|
|
953
|
+
Place orders through WebSocket:
|
|
954
|
+
|
|
955
|
+
```javascript
|
|
956
|
+
const callbacks = {
|
|
957
|
+
open: (client) => {
|
|
958
|
+
console.log('WebSocket API connected')
|
|
959
|
+
|
|
960
|
+
// Place market buy order
|
|
961
|
+
client.newOrder('BTCUSDT', 'BUY', 'MARKET', { quantity: 0.001 })
|
|
962
|
+
},
|
|
963
|
+
message: data => {
|
|
964
|
+
console.log('Order Response:', data)
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
const websocketAPIClient = new WebsocketAPI(apiKey, apiSecret, { callbacks })
|
|
969
|
+
```
|
|
970
|
+
|
|
971
|
+
### Account Information via WebSocket API
|
|
972
|
+
|
|
973
|
+
Get account information through WebSocket:
|
|
974
|
+
|
|
975
|
+
```javascript
|
|
976
|
+
const callbacks = {
|
|
977
|
+
open: (client) => {
|
|
978
|
+
console.log('WebSocket API connected')
|
|
979
|
+
|
|
980
|
+
// Get account information
|
|
981
|
+
client.account()
|
|
982
|
+
},
|
|
983
|
+
message: data => {
|
|
984
|
+
console.log('Account Info:', data)
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
const websocketAPIClient = new WebsocketAPI(apiKey, apiSecret, { callbacks })
|
|
989
|
+
```
|
|
990
|
+
|
|
991
|
+
## User Data Streams
|
|
992
|
+
|
|
993
|
+
User Data Streams provide real-time updates about account and order changes.
|
|
994
|
+
|
|
995
|
+
### Start User Data Stream
|
|
996
|
+
|
|
997
|
+
Create a listenKey for user data stream:
|
|
998
|
+
|
|
999
|
+
```javascript
|
|
1000
|
+
const { Spot } = require('@binance/connector')
|
|
1001
|
+
|
|
1002
|
+
const client = new Spot(apiKey, apiSecret)
|
|
1003
|
+
|
|
1004
|
+
// Create listen key
|
|
1005
|
+
client.userDataStream()
|
|
1006
|
+
.then(response => {
|
|
1007
|
+
const listenKey = response.data.listenKey
|
|
1008
|
+
console.log('Listen Key:', listenKey)
|
|
1009
|
+
|
|
1010
|
+
// Use this listenKey with WebSocket
|
|
1011
|
+
subscribeToUserDataStream(listenKey)
|
|
1012
|
+
})
|
|
1013
|
+
.catch(error => console.error(error))
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
### Keep-Alive User Data Stream
|
|
1017
|
+
|
|
1018
|
+
Extend the validity of a listenKey:
|
|
1019
|
+
|
|
1020
|
+
```javascript
|
|
1021
|
+
// Keep alive (extend validity by 60 minutes)
|
|
1022
|
+
client.keepAliveUserDataStream(listenKey)
|
|
1023
|
+
.then(response => console.log('Stream kept alive'))
|
|
1024
|
+
.catch(error => console.error(error))
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
### Close User Data Stream
|
|
1028
|
+
|
|
1029
|
+
Close a user data stream:
|
|
1030
|
+
|
|
1031
|
+
```javascript
|
|
1032
|
+
// Close stream
|
|
1033
|
+
client.closeUserDataStream(listenKey)
|
|
1034
|
+
.then(response => console.log('Stream closed'))
|
|
1035
|
+
.catch(error => console.error(error))
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
### Subscribe to User Data Stream
|
|
1039
|
+
|
|
1040
|
+
Connect to user data stream via WebSocket:
|
|
1041
|
+
|
|
1042
|
+
```javascript
|
|
1043
|
+
const { WebsocketStream } = require('@binance/connector')
|
|
1044
|
+
|
|
1045
|
+
function subscribeToUserDataStream(listenKey) {
|
|
1046
|
+
const callbacks = {
|
|
1047
|
+
open: () => console.log('Connected to user data stream'),
|
|
1048
|
+
close: () => console.log('Disconnected from user data stream'),
|
|
1049
|
+
message: data => {
|
|
1050
|
+
const event = JSON.parse(data)
|
|
1051
|
+
|
|
1052
|
+
if (event.e === 'executionReport') {
|
|
1053
|
+
console.log('Order Update:', event)
|
|
1054
|
+
} else if (event.e === 'outboundAccountPosition') {
|
|
1055
|
+
console.log('Balance Update:', event)
|
|
1056
|
+
} else if (event.e === 'balanceUpdate') {
|
|
1057
|
+
console.log('Balance Update:', event)
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
1063
|
+
websocketStreamClient.userData(listenKey)
|
|
1064
|
+
|
|
1065
|
+
return websocketStreamClient
|
|
1066
|
+
}
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
### Complete User Data Stream Example
|
|
1070
|
+
|
|
1071
|
+
Full example with keep-alive:
|
|
1072
|
+
|
|
1073
|
+
```javascript
|
|
1074
|
+
const { Spot, WebsocketStream } = require('@binance/connector')
|
|
1075
|
+
|
|
1076
|
+
const client = new Spot(apiKey, apiSecret)
|
|
1077
|
+
|
|
1078
|
+
// Create listen key
|
|
1079
|
+
client.userDataStream()
|
|
1080
|
+
.then(response => {
|
|
1081
|
+
const listenKey = response.data.listenKey
|
|
1082
|
+
console.log('Listen Key:', listenKey)
|
|
1083
|
+
|
|
1084
|
+
// Connect to user data stream
|
|
1085
|
+
const callbacks = {
|
|
1086
|
+
open: () => console.log('Connected to user data stream'),
|
|
1087
|
+
close: () => console.log('Disconnected from user data stream'),
|
|
1088
|
+
message: data => {
|
|
1089
|
+
const event = JSON.parse(data)
|
|
1090
|
+
console.log('User Data Event:', event)
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
const websocketStreamClient = new WebsocketStream({ callbacks })
|
|
1095
|
+
websocketStreamClient.userData(listenKey)
|
|
1096
|
+
|
|
1097
|
+
// Keep alive every 30 minutes
|
|
1098
|
+
setInterval(() => {
|
|
1099
|
+
client.keepAliveUserDataStream(listenKey)
|
|
1100
|
+
.then(() => console.log('Stream kept alive'))
|
|
1101
|
+
.catch(error => console.error('Keep alive failed:', error))
|
|
1102
|
+
}, 30 * 60 * 1000)
|
|
1103
|
+
})
|
|
1104
|
+
.catch(error => console.error(error))
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
## Error Handling
|
|
1108
|
+
|
|
1109
|
+
Proper error handling for API requests:
|
|
1110
|
+
|
|
1111
|
+
```javascript
|
|
1112
|
+
const { Spot } = require('@binance/connector')
|
|
1113
|
+
|
|
1114
|
+
const client = new Spot(apiKey, apiSecret)
|
|
1115
|
+
|
|
1116
|
+
client.account()
|
|
1117
|
+
.then(response => {
|
|
1118
|
+
console.log('Success:', response.data)
|
|
1119
|
+
})
|
|
1120
|
+
.catch(error => {
|
|
1121
|
+
if (error.response) {
|
|
1122
|
+
// Server responded with error
|
|
1123
|
+
console.error('Error Status:', error.response.status)
|
|
1124
|
+
console.error('Error Code:', error.response.data.code)
|
|
1125
|
+
console.error('Error Message:', error.response.data.msg)
|
|
1126
|
+
} else if (error.request) {
|
|
1127
|
+
// No response received
|
|
1128
|
+
console.error('No response received:', error.request)
|
|
1129
|
+
} else {
|
|
1130
|
+
// Request setup error
|
|
1131
|
+
console.error('Error:', error.message)
|
|
1132
|
+
}
|
|
1133
|
+
})
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
### Common Error Codes
|
|
1137
|
+
|
|
1138
|
+
| Code | Message | Description |
|
|
1139
|
+
|-------|----------------------------------|------------------------------------------|
|
|
1140
|
+
| -1000 | UNKNOWN | An unknown error occurred |
|
|
1141
|
+
| -1001 | DISCONNECTED | Internal error; unable to process |
|
|
1142
|
+
| -1002 | UNAUTHORIZED | Invalid API key or signature |
|
|
1143
|
+
| -1003 | TOO_MANY_REQUESTS | Too many requests; rate limit exceeded |
|
|
1144
|
+
| -1007 | TIMEOUT | Request timeout |
|
|
1145
|
+
| -1021 | TIMESTAMP_OUTSIDE_RECV_WINDOW | Timestamp outside recvWindow |
|
|
1146
|
+
| -1022 | INVALID_SIGNATURE | Invalid signature |
|
|
1147
|
+
| -1100 | ILLEGAL_CHARS | Illegal characters in parameter |
|
|
1148
|
+
| -1101 | TOO_MANY_PARAMETERS | Too many parameters |
|
|
1149
|
+
| -1102 | MANDATORY_PARAM_EMPTY_OR_MALFORMED | Mandatory parameter missing/malformed |
|
|
1150
|
+
| -1103 | UNKNOWN_PARAM | Unknown parameter |
|
|
1151
|
+
| -1104 | UNREAD_PARAMETERS | Not all parameters were read |
|
|
1152
|
+
| -1111 | BAD_PRECISION | Precision over maximum defined |
|
|
1153
|
+
| -1112 | NO_DEPTH | No orders on book |
|
|
1154
|
+
| -1114 | TIF_NOT_REQUIRED | Time in force not required |
|
|
1155
|
+
| -1115 | INVALID_TIF | Invalid time in force |
|
|
1156
|
+
| -1116 | INVALID_ORDER_TYPE | Invalid order type |
|
|
1157
|
+
| -1117 | INVALID_SIDE | Invalid side |
|
|
1158
|
+
| -1118 | EMPTY_NEW_CL_ORD_ID | New client order ID empty |
|
|
1159
|
+
| -1119 | EMPTY_ORG_CL_ORD_ID | Original client order ID empty |
|
|
1160
|
+
| -1120 | BAD_INTERVAL | Invalid interval |
|
|
1161
|
+
| -1121 | BAD_SYMBOL | Invalid symbol |
|
|
1162
|
+
| -1125 | INVALID_LISTEN_KEY | Invalid listen key |
|
|
1163
|
+
| -1127 | MORE_THAN_XX_HOURS | Lookup interval too large |
|
|
1164
|
+
| -1128 | OPTIONAL_PARAMS_BAD_COMBO | Invalid parameter combination |
|
|
1165
|
+
| -1130 | INVALID_PARAMETER | Invalid parameter |
|
|
1166
|
+
| -2010 | NEW_ORDER_REJECTED | Order rejected |
|
|
1167
|
+
| -2011 | CANCEL_REJECTED | Cancel rejected |
|
|
1168
|
+
| -2013 | NO_SUCH_ORDER | Order does not exist |
|
|
1169
|
+
| -2014 | BAD_API_KEY_FMT | API key format invalid |
|
|
1170
|
+
| -2015 | REJECTED_MBX_KEY | API key rejected |
|
|
1171
|
+
|
|
1172
|
+
## Rate Limits
|
|
1173
|
+
|
|
1174
|
+
Binance implements rate limits to prevent API abuse.
|
|
1175
|
+
|
|
1176
|
+
### Rate Limit Types
|
|
1177
|
+
|
|
1178
|
+
1. **REQUEST_WEIGHT** - Based on the weight of requests
|
|
1179
|
+
2. **ORDERS** - Based on the number of orders
|
|
1180
|
+
3. **RAW_REQUESTS** - Based on the number of requests
|
|
1181
|
+
|
|
1182
|
+
### Rate Limit Headers
|
|
1183
|
+
|
|
1184
|
+
Response headers include rate limit information:
|
|
1185
|
+
|
|
1186
|
+
```javascript
|
|
1187
|
+
client.account()
|
|
1188
|
+
.then(response => {
|
|
1189
|
+
console.log('Used Weight:', response.headers['x-mbx-used-weight-1m'])
|
|
1190
|
+
console.log('Order Count:', response.headers['x-mbx-order-count-10s'])
|
|
1191
|
+
})
|
|
1192
|
+
.catch(error => console.error(error))
|
|
1193
|
+
```
|
|
1194
|
+
|
|
1195
|
+
### Best Practices for Rate Limits
|
|
1196
|
+
|
|
1197
|
+
- Use WebSocket streams for real-time data instead of polling REST API
|
|
1198
|
+
- Batch requests when possible
|
|
1199
|
+
- Monitor rate limit headers
|
|
1200
|
+
- Implement exponential backoff for retries
|
|
1201
|
+
- Use `recvWindow` parameter appropriately
|
|
1202
|
+
|
|
1203
|
+
## Advanced Configuration
|
|
1204
|
+
|
|
1205
|
+
### Timestamp Synchronization
|
|
1206
|
+
|
|
1207
|
+
Configure timing window for requests:
|
|
1208
|
+
|
|
1209
|
+
```javascript
|
|
1210
|
+
const { Spot } = require('@binance/connector')
|
|
1211
|
+
|
|
1212
|
+
const client = new Spot(apiKey, apiSecret, {
|
|
1213
|
+
recvWindow: 10000 // 10 seconds (default: 5000)
|
|
1214
|
+
})
|
|
1215
|
+
```
|
|
1216
|
+
|
|
1217
|
+
### Custom Logger
|
|
1218
|
+
|
|
1219
|
+
Use a custom logger:
|
|
1220
|
+
|
|
1221
|
+
```javascript
|
|
1222
|
+
const winston = require('winston')
|
|
1223
|
+
|
|
1224
|
+
const logger = winston.createLogger({
|
|
1225
|
+
level: 'info',
|
|
1226
|
+
format: winston.format.json(),
|
|
1227
|
+
transports: [
|
|
1228
|
+
new winston.transports.File({ filename: 'binance.log' })
|
|
1229
|
+
]
|
|
1230
|
+
})
|
|
1231
|
+
|
|
1232
|
+
const client = new Spot(apiKey, apiSecret, {
|
|
1233
|
+
logger: logger
|
|
1234
|
+
})
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
### Base URL Selection
|
|
1238
|
+
|
|
1239
|
+
Choose optimal base URL for your region:
|
|
1240
|
+
|
|
1241
|
+
```javascript
|
|
1242
|
+
// Default (most stable)
|
|
1243
|
+
const client1 = new Spot(apiKey, apiSecret, {
|
|
1244
|
+
baseURL: 'https://api.binance.com'
|
|
1245
|
+
})
|
|
1246
|
+
|
|
1247
|
+
// GCP (better for some regions)
|
|
1248
|
+
const client2 = new Spot(apiKey, apiSecret, {
|
|
1249
|
+
baseURL: 'https://api-gcp.binance.com'
|
|
1250
|
+
})
|
|
1251
|
+
|
|
1252
|
+
// Numbered endpoints (better performance, less stability)
|
|
1253
|
+
const client3 = new Spot(apiKey, apiSecret, {
|
|
1254
|
+
baseURL: 'https://api1.binance.com'
|
|
1255
|
+
})
|
|
1256
|
+
|
|
1257
|
+
// Market data only
|
|
1258
|
+
const client4 = new Spot('', '', {
|
|
1259
|
+
baseURL: 'https://data-api.binance.vision'
|
|
1260
|
+
})
|
|
1261
|
+
```
|
|
1262
|
+
|
|
1263
|
+
### Async/Await Pattern
|
|
1264
|
+
|
|
1265
|
+
Use async/await for cleaner code:
|
|
1266
|
+
|
|
1267
|
+
```javascript
|
|
1268
|
+
const { Spot } = require('@binance/connector')
|
|
1269
|
+
|
|
1270
|
+
const client = new Spot(apiKey, apiSecret)
|
|
1271
|
+
|
|
1272
|
+
async function getAccountBalance() {
|
|
1273
|
+
try {
|
|
1274
|
+
const response = await client.account()
|
|
1275
|
+
const balances = response.data.balances.filter(b => parseFloat(b.free) > 0)
|
|
1276
|
+
console.log('Non-zero balances:', balances)
|
|
1277
|
+
return balances
|
|
1278
|
+
} catch (error) {
|
|
1279
|
+
console.error('Error fetching account:', error.response?.data || error.message)
|
|
1280
|
+
throw error
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
async function placeLimitOrder(symbol, side, quantity, price) {
|
|
1285
|
+
try {
|
|
1286
|
+
const response = await client.newOrder(symbol, side, 'LIMIT', {
|
|
1287
|
+
quantity,
|
|
1288
|
+
price,
|
|
1289
|
+
timeInForce: 'GTC'
|
|
1290
|
+
})
|
|
1291
|
+
console.log('Order placed:', response.data)
|
|
1292
|
+
return response.data
|
|
1293
|
+
} catch (error) {
|
|
1294
|
+
console.error('Error placing order:', error.response?.data || error.message)
|
|
1295
|
+
throw error
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// Usage
|
|
1300
|
+
(async () => {
|
|
1301
|
+
await getAccountBalance()
|
|
1302
|
+
await placeLimitOrder('BTCUSDT', 'BUY', 0.001, 50000)
|
|
1303
|
+
})()
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
## Useful Links
|
|
1307
|
+
|
|
1308
|
+
- Official Documentation: https://developers.binance.com/docs/binance-spot-api-docs
|
|
1309
|
+
- REST API Documentation: https://developers.binance.com/docs/binance-spot-api-docs/rest-api
|
|
1310
|
+
- WebSocket Streams: https://developers.binance.com/docs/binance-spot-api-docs/web-socket-streams
|
|
1311
|
+
- WebSocket API: https://developers.binance.com/docs/binance-spot-api-docs/websocket-api
|
|
1312
|
+
- GitHub Repository: https://github.com/binance/binance-connector-node
|
|
1313
|
+
- API Testnet: https://testnet.binance.vision
|
|
1314
|
+
- Get API Key: https://www.binance.com/en/my/settings/api-management
|
|
1315
|
+
- API Documentation (Old): https://binance-docs.github.io/apidocs/spot/en/
|