coinbase-api 1.1.1 → 1.1.3

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.
Files changed (3) hide show
  1. package/README.md +66 -14
  2. package/llms.txt +581 -529
  3. package/package.json +3 -3
package/llms.txt CHANGED
@@ -1286,42 +1286,6 @@ File: tsconfig.esm.json
1286
1286
  "include": ["src/**/*.*"]
1287
1287
  }
1288
1288
 
1289
- ================
1290
- File: tsconfig.json
1291
- ================
1292
- {
1293
- "compilerOptions": {
1294
- "allowSyntheticDefaultImports": true,
1295
- "baseUrl": "src",
1296
- "noEmitOnError": true,
1297
- "declaration": true,
1298
- "esModuleInterop": true,
1299
- "forceConsistentCasingInFileNames": false,
1300
- "inlineSourceMap": false,
1301
- "lib": ["esnext"],
1302
- "listEmittedFiles": false,
1303
- "listFiles": false,
1304
- "moduleResolution": "node",
1305
- "noFallthroughCasesInSwitch": true,
1306
- "noImplicitAny": true,
1307
- "noUnusedParameters": true,
1308
- "pretty": true,
1309
- "removeComments": false,
1310
- "resolveJsonModule": true,
1311
- "skipLibCheck": false,
1312
- "sourceMap": true,
1313
- "strict": true,
1314
- "strictNullChecks": true,
1315
- "types": ["node", "jest"],
1316
- "module": "commonjs",
1317
- "outDir": "dist/cjs",
1318
- "target": "esnext"
1319
- },
1320
- "compileOnSave": true,
1321
- "exclude": ["node_modules", "dist"],
1322
- "include": ["src/**/*.*", "test/**/*.*", ".eslintrc.cjs"]
1323
- }
1324
-
1325
1289
  ================
1326
1290
  File: tsconfig.linting.json
1327
1291
  ================
@@ -3150,6 +3114,106 @@ export interface AdvTradeApiKeyPermissions {
3150
3114
  portfolio_type: string;
3151
3115
  }
3152
3116
 
3117
+ ================
3118
+ File: src/types/websockets/requests.ts
3119
+ ================
3120
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3121
+ export type WsOperation = 'subscribe' | 'unsubscribe';
3122
+ ⋮----
3123
+ /**
3124
+ * This is the format used for commands sent upstream for this websocket connection.
3125
+ *
3126
+ * Docs:
3127
+ * - Adv Trade: https://docs.cdp.coinbase.com/advanced-trade/docs/ws-auth#subscribing
3128
+ */
3129
+ export interface WsAdvTradeRequestOperation<TWSTopic extends string = string> {
3130
+ type: WsOperation;
3131
+ channel: TWSTopic;
3132
+ product_ids?: string[];
3133
+ jwt?: string;
3134
+ }
3135
+ ⋮----
3136
+ export interface WsExchangeChannelWithParams<TWSTopic extends string = string> {
3137
+ name: TWSTopic;
3138
+ product_ids: string[];
3139
+ }
3140
+ ⋮----
3141
+ /**
3142
+ * Public subscribe/unsubscribe requests for the Coinbase Exchange product group
3143
+ */
3144
+ export interface WsExchangeRequestOperation<TWSTopic extends string = string> {
3145
+ type: WsOperation;
3146
+ channels: (TWSTopic | WsExchangeChannelWithParams)[];
3147
+ product_ids?: string[];
3148
+ }
3149
+ ⋮----
3150
+ /**
3151
+ * Private (authenticated) subscribe/unsubscribe requests for the Coinbase Exchange product group
3152
+ * https://docs.cdp.coinbase.com/exchange/docs/websocket-auth
3153
+ */
3154
+ export type WsExchangeAuthenticatedRequestOperation<
3155
+ TWSTopic extends string = string,
3156
+ > = WsExchangeRequestOperation<TWSTopic> & {
3157
+ signature: string;
3158
+ key: string;
3159
+ passphrase: string;
3160
+ timestamp: string;
3161
+ };
3162
+ ⋮----
3163
+ /**
3164
+ * Public subscribe/unsubscribe requests for the Coinbase International product group
3165
+ */
3166
+ export interface WsInternationalRequestOperation<
3167
+ TWSTopic extends string = string,
3168
+ > {
3169
+ type: Uppercase<WsOperation>;
3170
+ channels: TWSTopic[];
3171
+ product_ids?: string[];
3172
+ }
3173
+ ⋮----
3174
+ /**
3175
+ * Private (authenticated) subscribe/unsubscribe requests for the Coinbase International product group
3176
+ * https://docs.cdp.coinbase.com/intx/docs/websocket-auth
3177
+ */
3178
+ export type WsInternationalAuthenticatedRequestOperation<
3179
+ TWSTopic extends string = string,
3180
+ > = WsInternationalRequestOperation<TWSTopic> & {
3181
+ time: string;
3182
+ key: string;
3183
+ passphrase: string;
3184
+ signature: string;
3185
+ };
3186
+ ⋮----
3187
+ /**
3188
+ * Public subscribe/unsubscribe requests for the Coinbase Prime product group
3189
+ */
3190
+ export interface WsPrimeRequestOperation<TWSTopic extends string = string> {
3191
+ type: WsOperation;
3192
+ channel: TWSTopic;
3193
+ // these should be provided as a payload with the request, else auth will fail
3194
+ svcAccountId: string;
3195
+ portfolio_id: string;
3196
+ product_ids: string[];
3197
+ }
3198
+ ⋮----
3199
+ // these should be provided as a payload with the request, else auth will fail
3200
+ ⋮----
3201
+ /**
3202
+ * Private (authenticated) subscribe/unsubscribe requests for the Coinbase Prime product group
3203
+ *
3204
+ * - https://docs.cdp.coinbase.com/prime/docs/websocket-feed#signing-messages
3205
+ * - https://docs.cdp.coinbase.com/prime/docs/websocket-channels
3206
+ */
3207
+ export type WsPrimeAuthenticatedRequestOperation<
3208
+ TWSTopic extends string = string,
3209
+ > = WsPrimeRequestOperation<TWSTopic> & {
3210
+ access_key: string;
3211
+ api_key_id: string;
3212
+ passphrase: string;
3213
+ signature: string;
3214
+ timestamp: string;
3215
+ };
3216
+
3153
3217
  ================
3154
3218
  File: src/CBExchangeClient.ts
3155
3219
  ================
@@ -4093,6 +4157,42 @@ verbose: true, // report individual test
4093
4157
  // Whether to use watchman for file crawling
4094
4158
  // watchman: true,
4095
4159
 
4160
+ ================
4161
+ File: tsconfig.json
4162
+ ================
4163
+ {
4164
+ "compilerOptions": {
4165
+ "allowSyntheticDefaultImports": true,
4166
+ "baseUrl": ".",
4167
+ "noEmitOnError": true,
4168
+ "declaration": true,
4169
+ "esModuleInterop": true,
4170
+ "forceConsistentCasingInFileNames": false,
4171
+ "inlineSourceMap": false,
4172
+ "lib": ["esnext"],
4173
+ "listEmittedFiles": false,
4174
+ "listFiles": false,
4175
+ "moduleResolution": "node",
4176
+ "noFallthroughCasesInSwitch": true,
4177
+ "noImplicitAny": true,
4178
+ "noUnusedParameters": true,
4179
+ "pretty": true,
4180
+ "removeComments": false,
4181
+ "resolveJsonModule": true,
4182
+ "skipLibCheck": false,
4183
+ "sourceMap": true,
4184
+ "strict": true,
4185
+ "strictNullChecks": true,
4186
+ "types": ["node", "jest"],
4187
+ "module": "commonjs",
4188
+ "outDir": "dist/cjs",
4189
+ "target": "esnext"
4190
+ },
4191
+ "compileOnSave": true,
4192
+ "exclude": ["node_modules", "dist"],
4193
+ "include": ["src/**/*.*", "test/**/*.*", ".eslintrc.cjs"]
4194
+ }
4195
+
4096
4196
  ================
4097
4197
  File: examples/AdvancedTrade/Private/closePosition.ts
4098
4198
  ================
@@ -5151,140 +5251,40 @@ export interface GetPrimePortfolioWithdrawalPowerRequest {
5151
5251
  }
5152
5252
 
5153
5253
  ================
5154
- File: src/types/websockets/requests.ts
5254
+ File: src/types/shared.types.ts
5155
5255
  ================
5156
- /* eslint-disable @typescript-eslint/no-unused-vars */
5157
- export type WsOperation = 'subscribe' | 'unsubscribe';
5256
+ // Order configuration types
5257
+ interface MarketMarketIOC {
5258
+ quote_size?: string;
5259
+ base_size?: string;
5260
+ }
5158
5261
  ⋮----
5159
- /**
5160
- * This is the format used for commands sent upstream for this websocket connection.
5161
- *
5162
- * Docs:
5163
- * - Adv Trade: https://docs.cdp.coinbase.com/advanced-trade/docs/ws-auth#subscribing
5164
- */
5165
- export interface WsAdvTradeRequestOperation<TWSTopic extends string = string> {
5166
- type: WsOperation;
5167
- channel: TWSTopic;
5168
- product_ids?: string[];
5169
- jwt?: string;
5262
+ interface SORLimitIOC {
5263
+ base_size: string;
5264
+ limit_price: string;
5170
5265
  }
5171
5266
  ⋮----
5172
- export interface WsExchangeChannelWithParams<TWSTopic extends string = string> {
5173
- name: TWSTopic;
5174
- product_ids: string[];
5267
+ interface LimitLimitGTC {
5268
+ base_size: string;
5269
+ quote_size?: string;
5270
+ limit_price: string;
5271
+ post_only?: boolean;
5175
5272
  }
5176
5273
  ⋮----
5177
- /**
5178
- * Public subscribe/unsubscribe requests for the Coinbase Exchange product group
5179
- */
5180
- export interface WsExchangeRequestOperation<TWSTopic extends string = string> {
5181
- type: WsOperation;
5182
- channels: (TWSTopic | WsExchangeChannelWithParams)[];
5183
- product_ids?: string[];
5274
+ interface LimitLimitGTD {
5275
+ base_size: string;
5276
+ quote_size?: string;
5277
+ limit_price: string;
5278
+ end_time: string; // RFC3339 Timestamp
5279
+ post_only?: boolean;
5184
5280
  }
5185
5281
  ⋮----
5186
- /**
5187
- * Private (authenticated) subscribe/unsubscribe requests for the Coinbase Exchange product group
5188
- * https://docs.cdp.coinbase.com/exchange/docs/websocket-auth
5189
- */
5190
- export type WsExchangeAuthenticatedRequestOperation<
5191
- TWSTopic extends string = string,
5192
- > = WsExchangeRequestOperation<TWSTopic> & {
5193
- signature: string;
5194
- key: string;
5195
- passphrase: string;
5196
- timestamp: string;
5197
- };
5282
+ end_time: string; // RFC3339 Timestamp
5198
5283
  ⋮----
5199
- /**
5200
- * Public subscribe/unsubscribe requests for the Coinbase International product group
5201
- */
5202
- export interface WsInternationalRequestOperation<
5203
- TWSTopic extends string = string,
5204
- > {
5205
- type: Uppercase<WsOperation>;
5206
- channels: TWSTopic[];
5207
- product_ids?: string[];
5208
- }
5209
- ⋮----
5210
- /**
5211
- * Private (authenticated) subscribe/unsubscribe requests for the Coinbase International product group
5212
- * https://docs.cdp.coinbase.com/intx/docs/websocket-auth
5213
- */
5214
- export type WsInternationalAuthenticatedRequestOperation<
5215
- TWSTopic extends string = string,
5216
- > = WsInternationalRequestOperation<TWSTopic> & {
5217
- time: string;
5218
- key: string;
5219
- passphrase: string;
5220
- signature: string;
5221
- };
5222
- ⋮----
5223
- /**
5224
- * Public subscribe/unsubscribe requests for the Coinbase Prime product group
5225
- */
5226
- export interface WsPrimeRequestOperation<TWSTopic extends string = string> {
5227
- type: WsOperation;
5228
- channel: TWSTopic;
5229
- // these should be provided as a payload with the request, else auth will fail
5230
- svcAccountId: string;
5231
- portfolio_id: string;
5232
- product_ids: string[];
5233
- }
5234
- ⋮----
5235
- // these should be provided as a payload with the request, else auth will fail
5236
- ⋮----
5237
- /**
5238
- * Private (authenticated) subscribe/unsubscribe requests for the Coinbase Prime product group
5239
- *
5240
- * - https://docs.cdp.coinbase.com/prime/docs/websocket-feed#signing-messages
5241
- * - https://docs.cdp.coinbase.com/prime/docs/websocket-channels
5242
- */
5243
- export type WsPrimeAuthenticatedRequestOperation<
5244
- TWSTopic extends string = string,
5245
- > = WsPrimeRequestOperation<TWSTopic> & {
5246
- access_key: string;
5247
- api_key_id: string;
5248
- passphrase: string;
5249
- signature: string;
5250
- timestamp: string;
5251
- };
5252
-
5253
- ================
5254
- File: src/types/shared.types.ts
5255
- ================
5256
- // Order configuration types
5257
- interface MarketMarketIOC {
5258
- quote_size?: string;
5259
- base_size?: string;
5260
- }
5261
- ⋮----
5262
- interface SORLimitIOC {
5263
- base_size: string;
5264
- limit_price: string;
5265
- }
5266
- ⋮----
5267
- interface LimitLimitGTC {
5268
- base_size: string;
5269
- quote_size?: string;
5270
- limit_price: string;
5271
- post_only?: boolean;
5272
- }
5273
- ⋮----
5274
- interface LimitLimitGTD {
5275
- base_size: string;
5276
- quote_size?: string;
5277
- limit_price: string;
5278
- end_time: string; // RFC3339 Timestamp
5279
- post_only?: boolean;
5280
- }
5281
- ⋮----
5282
- end_time: string; // RFC3339 Timestamp
5283
- ⋮----
5284
- interface LimitLimitFOK {
5285
- quote_size?: string;
5286
- base_size: string;
5287
- limit_price: string;
5284
+ interface LimitLimitFOK {
5285
+ quote_size?: string;
5286
+ base_size: string;
5287
+ limit_price: string;
5288
5288
  }
5289
5289
  ⋮----
5290
5290
  interface StopLimitStopLimitGTC {
@@ -8138,33 +8138,6 @@ getSpotPrice(params:
8138
8138
  */
8139
8139
  getCurrentTime(): Promise<
8140
8140
 
8141
- ================
8142
- File: .gitignore
8143
- ================
8144
- examples/futures-private-test.ts
8145
- examples/spot-private-test.ts
8146
- node_modules
8147
-
8148
- rest-spot-private-ts-test.ts
8149
-
8150
- localtest.sh
8151
- testfile.ts
8152
- dist
8153
- cbtests.sh
8154
-
8155
- coverage
8156
- ts-adv-trade-test-private.ts
8157
- examples/ts-app-priv.ts
8158
- examples/ts-commerce.ts
8159
- ts-exchange-priv.ts
8160
- testfile-cbexch.ts
8161
- restClientRegex.ts
8162
- privaterepotracker.txt
8163
- examples/_TiagoTests
8164
- testfile.ts
8165
- cbapidocs.txt
8166
- repomix.sh
8167
-
8168
8141
  ================
8169
8142
  File: src/types/request/coinbase-international.ts
8170
8143
  ================
@@ -8370,97 +8343,380 @@ export interface INTXWithdrawToCounterpartyIdRequest {
8370
8343
  */
8371
8344
 
8372
8345
  ================
8373
- File: src/CBInternationalClient.ts
8346
+ File: .gitignore
8374
8347
  ================
8375
- import { AxiosRequestConfig } from 'axios';
8376
- ⋮----
8377
- import { BaseRestClient } from './lib/BaseRestClient.js';
8348
+ examples/futures-private-test.ts
8349
+ examples/spot-private-test.ts
8350
+ node_modules
8351
+
8352
+ rest-spot-private-ts-test.ts
8353
+
8354
+ localtest.sh
8355
+ testfile.ts
8356
+ dist
8357
+ cbtests.sh
8358
+
8359
+ coverage
8360
+ ts-adv-trade-test-private.ts
8361
+ examples/ts-app-priv.ts
8362
+ examples/ts-commerce.ts
8363
+ ts-exchange-priv.ts
8364
+ testfile-cbexch.ts
8365
+ restClientRegex.ts
8366
+ privaterepotracker.txt
8367
+ examples/_TiagoTests
8368
+ testfile.ts
8369
+ cbapidocs.txt
8370
+ repomix.sh
8371
+
8372
+ ================
8373
+ File: src/WebsocketClient.ts
8374
+ ================
8375
+ import { BaseWebsocketClient, EmittableEvent } from './lib/BaseWSClient.js';
8376
+ import { signWSJWT } from './lib/jwtNode.js';
8377
+ import { neverGuard } from './lib/misc-util.js';
8378
8378
  import {
8379
- REST_CLIENT_TYPE_ENUM,
8380
- RestClientOptions,
8381
- RestClientType,
8382
- } from './lib/requestUtils.js';
8379
+ isCBAdvancedTradeErrorEvent,
8380
+ isCBAdvancedTradeWSEvent,
8381
+ isCBExchangeWSEvent,
8382
+ isCBExchangeWSRequestOperation,
8383
+ isCBINTXWSRequestOperation,
8384
+ isCBPrimeWSRequestOperation,
8385
+ } from './lib/websocket/typeGuards.js';
8383
8386
  import {
8384
- CancelINTXOrdersRequest,
8385
- GetINTXAggregatedCandlesData,
8386
- GetINTXDailyTradingVolumes,
8387
- GetINTXFillsByPortfoliosRequest,
8388
- GetINTXIndexCandlesRequest,
8389
- GetINTXIndexCompositionHistory,
8390
- GetINTXMatchingTransfersRequest,
8391
- GetINTXOpenOrdersRequest,
8392
- GetINTXPortfolioFillsRequest,
8393
- INTXWithdrawToCounterpartyIdRequest,
8394
- INTXWithdrawToCryptoAddressRequest,
8395
- SubmitINTXOrderRequest,
8396
- TransferINTXFundsBetweenPortfoliosRequest,
8397
- TransferINTXPositionsBetweenPortfoliosRequest,
8398
- UpdateINTXOpenOrderRequest,
8399
- UpdateINTXPortfolioParametersRequest,
8400
- } from './types/request/coinbase-international.js';
8387
+ getCBExchangeWSSign,
8388
+ getCBInternationalWSSign,
8389
+ getCBPrimeWSSign,
8390
+ getMergedCBExchangeWSRequestOperations,
8391
+ MessageEventLike,
8392
+ WS_KEY_MAP,
8393
+ WS_URL_MAP,
8394
+ WsKey,
8395
+ WsTopicRequest,
8396
+ } from './lib/websocket/websocket-util.js';
8397
+ import { WSConnectedResult } from './lib/websocket/WsStore.types.js';
8398
+ import { WsMarket } from './types/websockets/client.js';
8399
+ import {
8400
+ WsAdvTradeRequestOperation,
8401
+ WsExchangeAuthenticatedRequestOperation,
8402
+ WsExchangeRequestOperation,
8403
+ WsInternationalAuthenticatedRequestOperation,
8404
+ WsInternationalRequestOperation,
8405
+ WsOperation,
8406
+ WsPrimeAuthenticatedRequestOperation,
8407
+ WsPrimeRequestOperation,
8408
+ } from './types/websockets/requests.js';
8409
+ import {
8410
+ WsAPITopicRequestParamMap,
8411
+ WsAPITopicResponseMap,
8412
+ WsAPIWsKeyTopicMap,
8413
+ } from './types/websockets/wsAPI.js';
8401
8414
  ⋮----
8402
8415
  /**
8403
- * REST client for Coinbase's Institutional International Exchange API:
8404
- * https://docs.cdp.coinbase.com/intx/docs/welcome
8416
+ * Any WS keys in this list will trigger automatic auth as required, if credentials are available
8405
8417
  */
8406
- export class CBInternationalClient extends BaseRestClient
8407
8418
  ⋮----
8408
- constructor(
8409
- restClientOptions: RestClientOptions = {},
8410
- requestOptions: AxiosRequestConfig = {},
8411
- )
8419
+ // Account data (fills), requires auth.
8412
8420
  ⋮----
8413
- getClientType(): RestClientType
8421
+ // Coinbase Direct Market Data has direct access to Coinbase Exchange servers and requires auth.
8414
8422
  ⋮----
8415
- /**
8416
- *
8417
- * Assets Endpoints
8418
- *
8419
- */
8423
+ // The INTX feed always requires auth.
8424
+ ⋮----
8425
+ // The Prime feed always requires auth.
8420
8426
  ⋮----
8421
8427
  /**
8422
- * List assets
8423
- *
8424
- * Returns a list of all supported assets.
8425
- */
8426
- getAssets(): Promise<any>
8428
+ * Any WS keys in this list will ALWAYS skip the authentication process, even if credentials are available
8429
+ */
8427
8430
  ⋮----
8428
8431
  /**
8429
- * Get asset details
8430
- *
8431
- * Retrieves information for a specific asset.
8432
- */
8433
- getAssetDetails(params:
8432
+ * WS topics are always a string for this exchange. Some exchanges use complex objects.
8433
+ */
8434
+ type WsTopic = string;
8435
+ ⋮----
8436
+ export class WebsocketClient extends BaseWebsocketClient<WsKey>
8434
8437
  ⋮----
8435
8438
  /**
8436
- * Get supported networks per asset
8437
- *
8438
- * Returns a list of supported networks and network information for a specific asset.
8439
+ * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
8439
8440
  */
8440
- getSupportedNetworksPerAsset(params:
8441
+ public connectAll(): Promise<(WSConnectedResult | undefined)[]>
8441
8442
  ⋮----
8442
8443
  /**
8444
+ * Request subscription to one or more topics. Pass topics as either an array of strings, or array of objects (if the topic has parameters).
8445
+ * Objects should be formatted as {topic: string, params: object}.
8443
8446
  *
8444
- * Index Endpoints
8447
+ * - Subscriptions are automatically routed to the correct websocket connection.
8448
+ * - Authentication/connection is automatic.
8449
+ * - Resubscribe after network issues is automatic.
8445
8450
  *
8451
+ * Call `unsubscribe(topics)` to remove topics
8446
8452
  */
8453
+ public subscribe(
8454
+ requests:
8455
+ | (WsTopicRequest<WsTopic> | WsTopic)
8456
+ | (WsTopicRequest<WsTopic> | WsTopic)[],
8457
+ wsKey: WsKey,
8458
+ )
8447
8459
  ⋮----
8448
8460
  /**
8449
- * Get index composition
8461
+ * Unsubscribe from one or more topics. Similar to subscribe() but in reverse.
8450
8462
  *
8451
- * Retrieves the latest index composition (metadata) with an ordered set of constituents.
8463
+ * - Requests are automatically routed to the correct websocket connection.
8464
+ * - These topics will be removed from the topic cache, so they won't be subscribed to again.
8452
8465
  */
8453
- getIndexComposition(params:
8466
+ public unsubscribe(
8467
+ requests:
8468
+ | (WsTopicRequest<WsTopic> | WsTopic)
8469
+ | (WsTopicRequest<WsTopic> | WsTopic)[],
8470
+ wsKey: WsKey,
8471
+ )
8454
8472
  ⋮----
8455
8473
  /**
8456
- * Get index composition history
8457
- *
8458
- * Retrieves a history of index composition records in a descending time order.
8459
- * The results are an array of index composition data recorded at different "timestamps".
8474
+ * Not supported by this exchange, do not use
8460
8475
  */
8461
- getIndexCompositionHistory(
8462
- params: GetINTXIndexCompositionHistory,
8463
- ): Promise<any>
8476
+ ⋮----
8477
+ // This overload allows the caller to omit the 3rd param, if it isn't required (e.g. for the login call)
8478
+ async sendWSAPIRequest<
8479
+ TWSKey extends keyof WsAPIWsKeyTopicMap,
8480
+ TWSChannel extends WsAPIWsKeyTopicMap[TWSKey] = WsAPIWsKeyTopicMap[TWSKey],
8481
+ TWSParams extends
8482
+ WsAPITopicRequestParamMap[TWSChannel] = WsAPITopicRequestParamMap[TWSChannel],
8483
+ TWSAPIResponse extends
8484
+ | WsAPITopicResponseMap[TWSChannel]
8485
+ | object = WsAPITopicResponseMap[TWSChannel],
8486
+ >(
8487
+ wsKey: TWSKey,
8488
+ channel: TWSChannel,
8489
+ ...params: TWSParams extends undefined ? [] : [TWSParams]
8490
+ ): Promise<TWSAPIResponse>;
8491
+ ⋮----
8492
+ async sendWSAPIRequest<
8493
+ TWSKey extends keyof WsAPIWsKeyTopicMap = keyof WsAPIWsKeyTopicMap,
8494
+ TWSChannel extends WsAPIWsKeyTopicMap[TWSKey] = WsAPIWsKeyTopicMap[TWSKey],
8495
+ TWSParams extends
8496
+ WsAPITopicRequestParamMap[TWSChannel] = WsAPITopicRequestParamMap[TWSChannel],
8497
+ >(
8498
+ wsKey: TWSKey,
8499
+ channel: TWSChannel,
8500
+ params?: TWSParams,
8501
+ ): Promise<undefined>
8502
+ ⋮----
8503
+ /**
8504
+ *
8505
+ * Internal methods
8506
+ *
8507
+ */
8508
+ ⋮----
8509
+ /**
8510
+ * Return a websocket URL, which is connected to as-is.
8511
+ * If a token or anything else is needed in the URL, this is a good place to add it.
8512
+ */
8513
+ protected async getWsUrl(wsKey: WsKey): Promise<string>
8514
+ ⋮----
8515
+ protected sendPingEvent(wsKey: WsKey)
8516
+ ⋮----
8517
+ protected sendPongEvent(wsKey: WsKey)
8518
+ ⋮----
8519
+ // Send a protocol layer pong
8520
+ ⋮----
8521
+ protected isWsPing(msg: any): boolean
8522
+ ⋮----
8523
+ protected isWsPong(msg: any): boolean
8524
+ ⋮----
8525
+ // this.logger.info(`Not a pong: `, msg);
8526
+ ⋮----
8527
+ protected resolveEmittableEvents(
8528
+ wsKey: WsKey,
8529
+ event: MessageEventLike,
8530
+ ): EmittableEvent[]
8531
+ ⋮----
8532
+ // E.g. {"type":"error","message":"rate limit exceeded","wsKey":"advTradeMarketData"}
8533
+ ⋮----
8534
+ // Parse Advanced Trade WS events (update & response)
8535
+ ⋮----
8536
+ // These are request/reply pattern events (e.g. after subscribing to topics or authenticating)
8537
+ ⋮----
8538
+ // Generic data for a channel
8539
+ ⋮----
8540
+ // Parse CB Exchange WS events
8541
+ ⋮----
8542
+ // Generic data for a channel
8543
+ ⋮----
8544
+ /**
8545
+ * Determines if a topic is for a private channel, using a hardcoded list of strings
8546
+ */
8547
+ protected isPrivateTopicRequest(
8548
+ request: WsTopicRequest<string>,
8549
+ wsKey: WsKey,
8550
+ ): boolean
8551
+ ⋮----
8552
+ protected getWsKeyForMarket(market: WsMarket, isPrivate: boolean): WsKey
8553
+ ⋮----
8554
+ protected getWsMarketForWsKey(wsKey: WsKey): WsMarket
8555
+ ⋮----
8556
+ protected getPrivateWSKeys(): WsKey[]
8557
+ ⋮----
8558
+ /** Force subscription requests to be sent in smaller batches, if a number is returned */
8559
+ protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null
8560
+ ⋮----
8561
+ // Technically, INTX supports request batching but not with nested parameters, so we'll send one at a time
8562
+ ⋮----
8563
+ // Exchange supports request batching, no known limit to max topics per request
8564
+ ⋮----
8565
+ /**
8566
+ * Map one or more topics into fully prepared "subscribe request" events (already stringified and ready to send)
8567
+ */
8568
+ protected async getWsOperationEventsForTopics(
8569
+ topicRequests: WsTopicRequest<string>[],
8570
+ wsKey: WsKey,
8571
+ operation: WsOperation,
8572
+ ): Promise<string[]>
8573
+ ⋮----
8574
+ /**
8575
+ * Operations need to be structured in a way that this exchange understands.
8576
+ * Parse the internal format into the format expected by the exchange. One request per operation.
8577
+ */
8578
+ ⋮----
8579
+ // In case there's ever more operation types than "subscribe" and "unsubscribe"
8580
+ ⋮----
8581
+ // As of Sep 2024, parameters (such as product_id[]) cannot be nested with the channels array
8582
+ ⋮----
8583
+ // This merges parametrs (such as product_id[]) into the top level request object
8584
+ ⋮----
8585
+ /**
8586
+ * - Merge commands into one if the exchange supports batch requests,
8587
+ * - Apply auth/sign, if needed,
8588
+ * - Apply any final formatting to return a string array, ready to be sent upstream.
8589
+ */
8590
+ ⋮----
8591
+ // Events that are ready to send (usually stringified JSON)
8592
+ // ADV trade only supports sending one at a time, so we don't try to merge them
8593
+ // These are already signed, if needed.
8594
+ ⋮----
8595
+ /**
8596
+ * No batching is supported for this product group, so we can already
8597
+ * handle sign here and return it as is
8598
+ */
8599
+ ⋮----
8600
+ // Don't expect this to ever happen, but just to please typescript...
8601
+ ⋮----
8602
+ // We're under the max topics per request limit.
8603
+ // Send operation requests as one merged request
8604
+ ⋮----
8605
+ // We're over the max topics per request limit. Break into batches.
8606
+ ⋮----
8607
+ // Don't expect this to ever happen, but just to please typescript...
8608
+ ⋮----
8609
+ // We're over the max topics per request limit. Break into batches.
8610
+ ⋮----
8611
+ // throw new Error(
8612
+ // 'CB INTX is not fully implemented yet - awaiting test environment... if you need this, please get in touch.',
8613
+ // );
8614
+ ⋮----
8615
+ // Don't expect this to ever happen, but just to please typescript...
8616
+ ⋮----
8617
+ // throw new Error(
8618
+ // 'CB Prime is not fully implemented yet - awaiting test environment... if you need this, please get in touch.',
8619
+ // );
8620
+ ⋮----
8621
+ // throw new Error(`Not implemented for "${wsKey}" yet`);
8622
+ ⋮----
8623
+ /**
8624
+ * Events are signed per-request, so this function isn't needed for Coinbase.
8625
+ */
8626
+ protected async getWsAuthRequestEvent(wsKey: WsKey): Promise<object>
8627
+
8628
+ ================
8629
+ File: src/CBInternationalClient.ts
8630
+ ================
8631
+ import { AxiosRequestConfig } from 'axios';
8632
+ ⋮----
8633
+ import { BaseRestClient } from './lib/BaseRestClient.js';
8634
+ import {
8635
+ REST_CLIENT_TYPE_ENUM,
8636
+ RestClientOptions,
8637
+ RestClientType,
8638
+ } from './lib/requestUtils.js';
8639
+ import {
8640
+ CancelINTXOrdersRequest,
8641
+ GetINTXAggregatedCandlesData,
8642
+ GetINTXDailyTradingVolumes,
8643
+ GetINTXFillsByPortfoliosRequest,
8644
+ GetINTXIndexCandlesRequest,
8645
+ GetINTXIndexCompositionHistory,
8646
+ GetINTXMatchingTransfersRequest,
8647
+ GetINTXOpenOrdersRequest,
8648
+ GetINTXPortfolioFillsRequest,
8649
+ INTXWithdrawToCounterpartyIdRequest,
8650
+ INTXWithdrawToCryptoAddressRequest,
8651
+ SubmitINTXOrderRequest,
8652
+ TransferINTXFundsBetweenPortfoliosRequest,
8653
+ TransferINTXPositionsBetweenPortfoliosRequest,
8654
+ UpdateINTXOpenOrderRequest,
8655
+ UpdateINTXPortfolioParametersRequest,
8656
+ } from './types/request/coinbase-international.js';
8657
+ ⋮----
8658
+ /**
8659
+ * REST client for Coinbase's Institutional International Exchange API:
8660
+ * https://docs.cdp.coinbase.com/intx/docs/welcome
8661
+ */
8662
+ export class CBInternationalClient extends BaseRestClient
8663
+ ⋮----
8664
+ constructor(
8665
+ restClientOptions: RestClientOptions = {},
8666
+ requestOptions: AxiosRequestConfig = {},
8667
+ )
8668
+ ⋮----
8669
+ getClientType(): RestClientType
8670
+ ⋮----
8671
+ /**
8672
+ *
8673
+ * Assets Endpoints
8674
+ *
8675
+ */
8676
+ ⋮----
8677
+ /**
8678
+ * List assets
8679
+ *
8680
+ * Returns a list of all supported assets.
8681
+ */
8682
+ getAssets(): Promise<any>
8683
+ ⋮----
8684
+ /**
8685
+ * Get asset details
8686
+ *
8687
+ * Retrieves information for a specific asset.
8688
+ */
8689
+ getAssetDetails(params:
8690
+ ⋮----
8691
+ /**
8692
+ * Get supported networks per asset
8693
+ *
8694
+ * Returns a list of supported networks and network information for a specific asset.
8695
+ */
8696
+ getSupportedNetworksPerAsset(params:
8697
+ ⋮----
8698
+ /**
8699
+ *
8700
+ * Index Endpoints
8701
+ *
8702
+ */
8703
+ ⋮----
8704
+ /**
8705
+ * Get index composition
8706
+ *
8707
+ * Retrieves the latest index composition (metadata) with an ordered set of constituents.
8708
+ */
8709
+ getIndexComposition(params:
8710
+ ⋮----
8711
+ /**
8712
+ * Get index composition history
8713
+ *
8714
+ * Retrieves a history of index composition records in a descending time order.
8715
+ * The results are an array of index composition data recorded at different "timestamps".
8716
+ */
8717
+ getIndexCompositionHistory(
8718
+ params: GetINTXIndexCompositionHistory,
8719
+ ): Promise<any>
8464
8720
  ⋮----
8465
8721
  /**
8466
8722
  * Get index price
@@ -8940,262 +9196,6 @@ withdrawToCounterpartyId(
8940
9196
  */
8941
9197
  getFeeRateTiers(): Promise<any>
8942
9198
 
8943
- ================
8944
- File: src/WebsocketClient.ts
8945
- ================
8946
- import { BaseWebsocketClient, EmittableEvent } from './lib/BaseWSClient.js';
8947
- import { signWSJWT } from './lib/jwtNode.js';
8948
- import { neverGuard } from './lib/misc-util.js';
8949
- import {
8950
- isCBAdvancedTradeErrorEvent,
8951
- isCBAdvancedTradeWSEvent,
8952
- isCBExchangeWSEvent,
8953
- isCBExchangeWSRequestOperation,
8954
- isCBINTXWSRequestOperation,
8955
- isCBPrimeWSRequestOperation,
8956
- } from './lib/websocket/typeGuards.js';
8957
- import {
8958
- getCBExchangeWSSign,
8959
- getCBInternationalWSSign,
8960
- getCBPrimeWSSign,
8961
- getMergedCBExchangeWSRequestOperations,
8962
- MessageEventLike,
8963
- WS_KEY_MAP,
8964
- WS_URL_MAP,
8965
- WsKey,
8966
- WsTopicRequest,
8967
- } from './lib/websocket/websocket-util.js';
8968
- import { WSConnectedResult } from './lib/websocket/WsStore.types.js';
8969
- import { WsMarket } from './types/websockets/client.js';
8970
- import {
8971
- WsAdvTradeRequestOperation,
8972
- WsExchangeAuthenticatedRequestOperation,
8973
- WsExchangeRequestOperation,
8974
- WsInternationalAuthenticatedRequestOperation,
8975
- WsInternationalRequestOperation,
8976
- WsOperation,
8977
- WsPrimeAuthenticatedRequestOperation,
8978
- WsPrimeRequestOperation,
8979
- } from './types/websockets/requests.js';
8980
- import {
8981
- WsAPITopicRequestParamMap,
8982
- WsAPITopicResponseMap,
8983
- WsAPIWsKeyTopicMap,
8984
- } from './types/websockets/wsAPI.js';
8985
- ⋮----
8986
- /**
8987
- * Any WS keys in this list will trigger automatic auth as required, if credentials are available
8988
- */
8989
- ⋮----
8990
- // Account data (fills), requires auth.
8991
- ⋮----
8992
- // Coinbase Direct Market Data has direct access to Coinbase Exchange servers and requires auth.
8993
- ⋮----
8994
- // The INTX feed always requires auth.
8995
- ⋮----
8996
- // The Prime feed always requires auth.
8997
- ⋮----
8998
- /**
8999
- * Any WS keys in this list will ALWAYS skip the authentication process, even if credentials are available
9000
- */
9001
- ⋮----
9002
- /**
9003
- * WS topics are always a string for this exchange. Some exchanges use complex objects.
9004
- */
9005
- type WsTopic = string;
9006
- ⋮----
9007
- export class WebsocketClient extends BaseWebsocketClient<WsKey>
9008
- ⋮----
9009
- /**
9010
- * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
9011
- */
9012
- public connectAll(): Promise<(WSConnectedResult | undefined)[]>
9013
- ⋮----
9014
- /**
9015
- * Request subscription to one or more topics. Pass topics as either an array of strings, or array of objects (if the topic has parameters).
9016
- * Objects should be formatted as {topic: string, params: object}.
9017
- *
9018
- * - Subscriptions are automatically routed to the correct websocket connection.
9019
- * - Authentication/connection is automatic.
9020
- * - Resubscribe after network issues is automatic.
9021
- *
9022
- * Call `unsubscribe(topics)` to remove topics
9023
- */
9024
- public subscribe(
9025
- requests:
9026
- | (WsTopicRequest<WsTopic> | WsTopic)
9027
- | (WsTopicRequest<WsTopic> | WsTopic)[],
9028
- wsKey: WsKey,
9029
- )
9030
- ⋮----
9031
- /**
9032
- * Unsubscribe from one or more topics. Similar to subscribe() but in reverse.
9033
- *
9034
- * - Requests are automatically routed to the correct websocket connection.
9035
- * - These topics will be removed from the topic cache, so they won't be subscribed to again.
9036
- */
9037
- public unsubscribe(
9038
- requests:
9039
- | (WsTopicRequest<WsTopic> | WsTopic)
9040
- | (WsTopicRequest<WsTopic> | WsTopic)[],
9041
- wsKey: WsKey,
9042
- )
9043
- ⋮----
9044
- /**
9045
- * Not supported by this exchange, do not use
9046
- */
9047
- ⋮----
9048
- // This overload allows the caller to omit the 3rd param, if it isn't required (e.g. for the login call)
9049
- async sendWSAPIRequest<
9050
- TWSKey extends keyof WsAPIWsKeyTopicMap,
9051
- TWSChannel extends WsAPIWsKeyTopicMap[TWSKey] = WsAPIWsKeyTopicMap[TWSKey],
9052
- TWSParams extends
9053
- WsAPITopicRequestParamMap[TWSChannel] = WsAPITopicRequestParamMap[TWSChannel],
9054
- TWSAPIResponse extends
9055
- | WsAPITopicResponseMap[TWSChannel]
9056
- | object = WsAPITopicResponseMap[TWSChannel],
9057
- >(
9058
- wsKey: TWSKey,
9059
- channel: TWSChannel,
9060
- ...params: TWSParams extends undefined ? [] : [TWSParams]
9061
- ): Promise<TWSAPIResponse>;
9062
- ⋮----
9063
- async sendWSAPIRequest<
9064
- TWSKey extends keyof WsAPIWsKeyTopicMap = keyof WsAPIWsKeyTopicMap,
9065
- TWSChannel extends WsAPIWsKeyTopicMap[TWSKey] = WsAPIWsKeyTopicMap[TWSKey],
9066
- TWSParams extends
9067
- WsAPITopicRequestParamMap[TWSChannel] = WsAPITopicRequestParamMap[TWSChannel],
9068
- >(
9069
- wsKey: TWSKey,
9070
- channel: TWSChannel,
9071
- params?: TWSParams,
9072
- ): Promise<undefined>
9073
- ⋮----
9074
- /**
9075
- *
9076
- * Internal methods
9077
- *
9078
- */
9079
- ⋮----
9080
- /**
9081
- * Return a websocket URL, which is connected to as-is.
9082
- * If a token or anything else is needed in the URL, this is a good place to add it.
9083
- */
9084
- protected async getWsUrl(wsKey: WsKey): Promise<string>
9085
- ⋮----
9086
- protected sendPingEvent(wsKey: WsKey)
9087
- ⋮----
9088
- protected sendPongEvent(wsKey: WsKey)
9089
- ⋮----
9090
- // Send a protocol layer pong
9091
- ⋮----
9092
- protected isWsPing(msg: any): boolean
9093
- ⋮----
9094
- protected isWsPong(msg: any): boolean
9095
- ⋮----
9096
- // this.logger.info(`Not a pong: `, msg);
9097
- ⋮----
9098
- protected resolveEmittableEvents(
9099
- wsKey: WsKey,
9100
- event: MessageEventLike,
9101
- ): EmittableEvent[]
9102
- ⋮----
9103
- // E.g. {"type":"error","message":"rate limit exceeded","wsKey":"advTradeMarketData"}
9104
- ⋮----
9105
- // Parse Advanced Trade WS events (update & response)
9106
- ⋮----
9107
- // These are request/reply pattern events (e.g. after subscribing to topics or authenticating)
9108
- ⋮----
9109
- // Generic data for a channel
9110
- ⋮----
9111
- // Parse CB Exchange WS events
9112
- ⋮----
9113
- // Generic data for a channel
9114
- ⋮----
9115
- /**
9116
- * Determines if a topic is for a private channel, using a hardcoded list of strings
9117
- */
9118
- protected isPrivateTopicRequest(
9119
- request: WsTopicRequest<string>,
9120
- wsKey: WsKey,
9121
- ): boolean
9122
- ⋮----
9123
- protected getWsKeyForMarket(market: WsMarket, isPrivate: boolean): WsKey
9124
- ⋮----
9125
- protected getWsMarketForWsKey(wsKey: WsKey): WsMarket
9126
- ⋮----
9127
- protected getPrivateWSKeys(): WsKey[]
9128
- ⋮----
9129
- /** Force subscription requests to be sent in smaller batches, if a number is returned */
9130
- protected getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null
9131
- ⋮----
9132
- // Technically, INTX supports request batching but not with nested parameters, so we'll send one at a time
9133
- ⋮----
9134
- // Exchange supports request batching, no known limit to max topics per request
9135
- ⋮----
9136
- /**
9137
- * Map one or more topics into fully prepared "subscribe request" events (already stringified and ready to send)
9138
- */
9139
- protected async getWsOperationEventsForTopics(
9140
- topicRequests: WsTopicRequest<string>[],
9141
- wsKey: WsKey,
9142
- operation: WsOperation,
9143
- ): Promise<string[]>
9144
- ⋮----
9145
- /**
9146
- * Operations need to be structured in a way that this exchange understands.
9147
- * Parse the internal format into the format expected by the exchange. One request per operation.
9148
- */
9149
- ⋮----
9150
- // In case there's ever more operation types than "subscribe" and "unsubscribe"
9151
- ⋮----
9152
- // As of Sep 2024, parameters (such as product_id[]) cannot be nested with the channels array
9153
- ⋮----
9154
- // This merges parametrs (such as product_id[]) into the top level request object
9155
- ⋮----
9156
- /**
9157
- * - Merge commands into one if the exchange supports batch requests,
9158
- * - Apply auth/sign, if needed,
9159
- * - Apply any final formatting to return a string array, ready to be sent upstream.
9160
- */
9161
- ⋮----
9162
- // Events that are ready to send (usually stringified JSON)
9163
- // ADV trade only supports sending one at a time, so we don't try to merge them
9164
- // These are already signed, if needed.
9165
- ⋮----
9166
- /**
9167
- * No batching is supported for this product group, so we can already
9168
- * handle sign here and return it as is
9169
- */
9170
- ⋮----
9171
- // Don't expect this to ever happen, but just to please typescript...
9172
- ⋮----
9173
- // We're under the max topics per request limit.
9174
- // Send operation requests as one merged request
9175
- ⋮----
9176
- // We're over the max topics per request limit. Break into batches.
9177
- ⋮----
9178
- // Don't expect this to ever happen, but just to please typescript...
9179
- ⋮----
9180
- // We're over the max topics per request limit. Break into batches.
9181
- ⋮----
9182
- // throw new Error(
9183
- // 'CB INTX is not fully implemented yet - awaiting test environment... if you need this, please get in touch.',
9184
- // );
9185
- ⋮----
9186
- // Don't expect this to ever happen, but just to please typescript...
9187
- ⋮----
9188
- // throw new Error(
9189
- // 'CB Prime is not fully implemented yet - awaiting test environment... if you need this, please get in touch.',
9190
- // );
9191
- ⋮----
9192
- // throw new Error(`Not implemented for "${wsKey}" yet`);
9193
- ⋮----
9194
- /**
9195
- * Events are signed per-request, so this function isn't needed for Coinbase.
9196
- */
9197
- protected async getWsAuthRequestEvent(wsKey: WsKey): Promise<object>
9198
-
9199
9199
  ================
9200
9200
  File: README.md
9201
9201
  ================
@@ -9221,26 +9221,62 @@ File: README.md
9221
9221
 
9222
9222
  Updated & performant JavaScript & Node.js SDK for the Coinbase REST APIs and WebSockets:
9223
9223
 
9224
- - Supports both retail and institutional REST clients and Websockets:
9225
- - [Coinbase Advanced Trade](https://docs.cdp.coinbase.com/advanced-trade/docs/welcome)
9226
- - [Coinbase App](https://docs.cdp.coinbase.com/coinbase-app/docs/welcome)
9227
- - [Coinbase Exchange](https://docs.cdp.coinbase.com/exchange/docs/welcome)
9228
- - [Coinbase International Exchange](https://docs.cdp.coinbase.com/intx/docs/welcome)
9229
- - [Coinbase Prime](https://docs.cdp.coinbase.com/prime/docs/welcome)
9230
- - [Coinbase Commerce](https://docs.cdp.coinbase.com/commerce-onchain/docs/welcome)
9231
- - Complete integration with all REST APIs and WebSockets.
9224
+ - Professional, robust & performant Coinbase SDK with extensive production use in live trading environments.
9225
+ - Complete integration with all Coinbase APIs - supports both retail and institutional REST clients and WebSockets:
9226
+ - [Coinbase Advanced Trade](https://docs.cdp.coinbase.com/advanced-trade/docs/welcome) - Modern trading platform
9227
+ - [Coinbase App](https://docs.cdp.coinbase.com/coinbase-app/docs/welcome) - Consumer mobile/web application
9228
+ - [Coinbase Exchange](https://docs.cdp.coinbase.com/exchange/docs/welcome) - Professional trading platform
9229
+ - [Coinbase International Exchange](https://docs.cdp.coinbase.com/intx/docs/welcome) - International institutional trading
9230
+ - [Coinbase Prime](https://docs.cdp.coinbase.com/prime/docs/welcome) - Institutional custody and trading
9231
+ - [Coinbase Commerce](https://docs.cdp.coinbase.com/commerce-onchain/docs/welcome) - Payments and commerce solutions
9232
+ - Complete TypeScript support (with type declarations for most API requests & responses).
9233
+ - Strongly typed requests and responses.
9234
+ - Automated end-to-end tests ensuring reliability.
9235
+ - Actively maintained with a modern, promise-driven interface.
9232
9236
  - Supports both ECDSA and ED25519 API keys with automatic key type detection.
9233
- - TypeScript support (with type declarations for most API requests & responses)
9234
9237
  - Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
9238
+ - Event driven messaging.
9239
+ - Smart WebSocket persistence with automatic reconnection handling.
9240
+ - Emit `reconnected` event when dropped connection is restored.
9241
+ - Support for both public and private WebSocket streams across all platforms.
9235
9242
  - Automatically supports both ESM and CJS projects.
9236
9243
  - Proxy support via axios integration.
9244
+ - Heavy automated end-to-end testing with real API calls.
9237
9245
  - Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders).
9238
9246
  - Extensive examples for interacting with the Coinbase API offering in Node.js/JavaScript/TypeScript: [/examples/](./examples).
9239
9247
 
9248
+ ## Table of Contents
9249
+
9250
+ - [Installation](#installation)
9251
+ - [Examples](#examples)
9252
+ - [Issues & Discussion](#issues--discussion)
9253
+ - [Related Projects](#related-projects)
9254
+ - [Documentation](#documentation)
9255
+ - [Structure](#structure)
9256
+ - [Usage](#usage)
9257
+ - [REST API Clients](#rest-api)
9258
+ - [CBAdvancedTradeClient](#cbadvancedtradeclient)
9259
+ - [CBAppClient](#cbappclient)
9260
+ - [CBExchangeClient](#cbexchangeclient)
9261
+ - [CBInternationalClient](#cbinternationalclient)
9262
+ - [CBPrimeClient](#cbprimeclient)
9263
+ - [CBCommerceClient](#cbcommerceclient)
9264
+ - [WebSocket Client](#websockets)
9265
+ - [Public WebSocket Streams](#public-websocket)
9266
+ - [Private WebSocket Streams](#private-websocket)
9267
+ - [WebSocket Event Handling](#listening-and-subscribing-to-websocket-events)
9268
+ - [Customise Logging](#customise-logging)
9269
+ - [LLMs & AI](#use-with-llms--ai)
9270
+ - [Contributions & Thanks](#contributions--thanks)
9271
+
9240
9272
  ## Installation
9241
9273
 
9242
9274
  `npm install --save coinbase-api`
9243
9275
 
9276
+ ## Examples
9277
+
9278
+ Refer to the [examples](./examples) folder for implementation examples.
9279
+
9244
9280
  ## Issues & Discussion
9245
9281
 
9246
9282
  - Issues? Check the [issues tab](https://github.com/tiagosiebler/coinbase-api/issues).
@@ -9271,11 +9307,18 @@ Check out my related JavaScript/TypeScript/Node.js projects:
9271
9307
 
9272
9308
  ## Documentation
9273
9309
 
9274
- Most methods accept JS objects. These can be populated using parameters specified by Coinbase's API documentation.
9310
+ Most methods accept JS objects. These can be populated using parameters specified by Coinbase's API documentation, or check the type definition in each class within this repository.
9311
+
9312
+ ### API Documentation Links
9275
9313
 
9276
- - [Coinbase API Documentation](https://docs.cdp.coinbase.com/product-apis/docs/welcome)
9314
+ - [Coinbase Developer Platform - Product APIs](https://docs.cdp.coinbase.com/product-apis/docs/welcome)
9315
+ - [Advanced Trade API](https://docs.cdp.coinbase.com/advanced-trade/docs/welcome)
9316
+ - [Coinbase App API](https://docs.cdp.coinbase.com/coinbase-app/docs/welcome)
9317
+ - [Exchange API](https://docs.cdp.coinbase.com/exchange/docs/welcome)
9318
+ - [International Exchange API](https://docs.cdp.coinbase.com/intx/docs/welcome)
9319
+ - [Prime API](https://docs.cdp.coinbase.com/prime/docs/welcome)
9320
+ - [Commerce API](https://docs.cdp.coinbase.com/commerce-onchain/docs/welcome)
9277
9321
  - [REST Endpoint Function List](./docs/endpointFunctionList.md)
9278
- <!-- - [TSDoc Documentation (autogenerated using typedoc)](https://tsdocs.dev/docs/coinbase-api) -->
9279
9322
 
9280
9323
  ## Structure
9281
9324
 
@@ -9288,11 +9331,13 @@ This project uses typescript. Resources are stored in 2 key structures:
9288
9331
 
9289
9332
  # Usage
9290
9333
 
9291
- Create API credentials
9334
+ Create API credentials on Coinbase's website:
9292
9335
 
9293
9336
  - [Coinbase API Key Management](https://www.coinbase.com/settings/api)
9294
9337
 
9295
- ### REST API
9338
+ ## REST API
9339
+
9340
+ The SDK provides dedicated REST clients for each of Coinbase's API groups. Each client is designed for specific use cases and user types:
9296
9341
 
9297
9342
  To use any of Coinbase's REST APIs in JavaScript/TypeScript/Node.js, import (or require) the client you want to use. We currently support the following clients:
9298
9343
 
@@ -9320,7 +9365,7 @@ const advancedTradeCdpAPIKey = {
9320
9365
  '-----BEGIN EC PRIVATE KEY-----\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+oAoGCCqGSM49\nAwEHoUQDQgAEhtAep/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+bzduY3iYXEmj/KtCk\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj\n-----END EC PRIVATE KEY-----\n',
9321
9366
  };
9322
9367
 
9323
- /*
9368
+ /*
9324
9369
  * You can add ECDSA keys like the example above, or ED25519 keys like the example below.
9325
9370
  * Client will recognize both types of keys automatically.
9326
9371
  * ED25519:
@@ -9328,7 +9373,7 @@ const advancedTradeCdpAPIKey = {
9328
9373
  * name: 'your-api-key-id',
9329
9374
  * privateKey: 'yourExampleApiSecretEd25519Version==',
9330
9375
  * }
9331
- */
9376
+ */
9332
9377
 
9333
9378
  const client = new CBAdvancedTradeClient({
9334
9379
  // Either pass the full JSON object that can be downloaded when creating your API keys
@@ -9369,7 +9414,7 @@ const CBAppKeys = {
9369
9414
  '-----BEGIN EC PRIVATE KEY-----\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+oAoGCCqGSM49\nAwEHoUQDQgAEhtAep/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+bzduY3iYXEmj/KtCk\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj\n-----END EC PRIVATE KEY-----\n',
9370
9415
  };
9371
9416
 
9372
- /*
9417
+ /*
9373
9418
  * You can add ECDSA keys like the example above, or ED25519 keys like the example below.
9374
9419
  * Client will recognize both types of keys automatically.
9375
9420
  * ED25519:
@@ -9377,7 +9422,7 @@ const CBAppKeys = {
9377
9422
  * name: 'your-api-key-id',
9378
9423
  * privateKey: 'yourExampleApiSecretEd25519Version==',
9379
9424
  * }
9380
- */
9425
+ */
9381
9426
 
9382
9427
  const client = new CBAppClient({
9383
9428
  // Either pass the full JSON object that can be downloaded when creating your API keys
@@ -9521,7 +9566,7 @@ const advancedTradeCdpAPIKey = {
9521
9566
  '-----BEGIN EC PRIVATE KEY-----\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+oAoGCCqGSM49\nAwEHoUQDQgAEhtAep/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+bzduY3iYXEmj/KtCk\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj\n-----END EC PRIVATE KEY-----\n',
9522
9567
  };
9523
9568
 
9524
- /*
9569
+ /*
9525
9570
  * You can add ECDSA keys like the example above, or ED25519 keys like the example below.
9526
9571
  * Client will recognize both types of keys automatically.
9527
9572
  * ED25519:
@@ -9529,7 +9574,7 @@ const advancedTradeCdpAPIKey = {
9529
9574
  * name: 'your-api-key-id',
9530
9575
  * privateKey: 'yourExampleApiSecretEd25519Version==',
9531
9576
  * }
9532
- */
9577
+ */
9533
9578
 
9534
9579
  const client = new WebsocketClient({
9535
9580
  // Either pass the full JSON object that can be downloaded when creating your API keys
@@ -9697,6 +9742,12 @@ const ws = new WebsocketClient(
9697
9742
  );
9698
9743
  ```
9699
9744
 
9745
+ ## Use with LLMs & AI
9746
+
9747
+ This SDK includes a bundled `llms.txt` file in the root of the repository. If you're developing with LLMs, use the included `llms.txt` with your LLM - it will significantly improve the LLMs understanding of how to correctly use this SDK.
9748
+
9749
+ This file contains AI optimised structure of all the functions in this package, and their parameters for easier use with any learning models or artificial intelligence.
9750
+
9700
9751
  ---
9701
9752
 
9702
9753
  <!-- template_contributions -->
@@ -10006,7 +10057,7 @@ File: package.json
10006
10057
  ================
10007
10058
  {
10008
10059
  "name": "coinbase-api",
10009
- "version": "1.1.0",
10060
+ "version": "1.1.1",
10010
10061
  "description": "Node.js SDK for Coinbase's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
10011
10062
  "scripts": {
10012
10063
  "clean": "rm -rf dist",
@@ -10030,7 +10081,8 @@ File: package.json
10030
10081
  },
10031
10082
  "type": "module",
10032
10083
  "files": [
10033
- "dist/*"
10084
+ "dist/*",
10085
+ "llms.txt"
10034
10086
  ],
10035
10087
  "author": "Tiago Siebler (https://github.com/tiagosiebler)",
10036
10088
  "contributors": [