{"id":17774088,"url":"https://github.com/tiagosiebler/coinbase-api","last_synced_at":"2026-02-09T18:01:09.563Z","repository":{"id":257805354,"uuid":"809091760","full_name":"tiagosiebler/coinbase-api","owner":"tiagosiebler","description":"Node.js SDK for the Coinbase APIs and WebSockets, with TypeScript \u0026 browser support.","archived":false,"fork":false,"pushed_at":"2026-01-30T11:21:22.000Z","size":1042,"stargazers_count":23,"open_issues_count":3,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-31T04:04:17.788Z","etag":null,"topics":["coinbase","coinbase-api","coinbase-pro","coinbase-pro-api","coinbase-wallet","coinbasepro","javascript","node","node-js","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/coinbase-api","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tiagosiebler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["tiagosiebler","JJ-Cro"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2024-06-01T16:56:50.000Z","updated_at":"2026-01-30T11:21:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8ca728b-b322-42bb-a25d-c8b9d6b04b42","html_url":"https://github.com/tiagosiebler/coinbase-api","commit_stats":null,"previous_names":["tiagosiebler/coinbase-api"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tiagosiebler/coinbase-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagosiebler%2Fcoinbase-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagosiebler%2Fcoinbase-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagosiebler%2Fcoinbase-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagosiebler%2Fcoinbase-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiagosiebler","download_url":"https://codeload.github.com/tiagosiebler/coinbase-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiagosiebler%2Fcoinbase-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29274724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T17:15:22.002Z","status":"ssl_error","status_checked_at":"2026-02-09T17:14:42.395Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coinbase","coinbase-api","coinbase-pro","coinbase-pro-api","coinbase-wallet","coinbasepro","javascript","node","node-js","nodejs","typescript"],"created_at":"2024-10-26T21:49:41.319Z","updated_at":"2026-02-09T18:01:09.549Z","avatar_url":"https://github.com/tiagosiebler.png","language":"TypeScript","funding_links":["https://github.com/sponsors/tiagosiebler","https://github.com/sponsors/JJ-Cro"],"categories":[],"sub_categories":[],"readme":"# Node.js \u0026 JavaScript SDK for Coinbase's Advanced Trade, App, Exchange, International, Prime \u0026 Commerce REST APIs and WebSockets\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/coinbase-api\"\u003e\n    \u003cpicture\u003e\n      \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/tiagosiebler/coinbase-api/blob/master/docs/images/logoDarkMode2.svg?raw=true#gh-dark-mode-only\"\u003e\n      \u003cimg alt=\"SDK Logo\" src=\"https://github.com/tiagosiebler/coinbase-api/blob/master/docs/images/logoBrightMode2.svg?raw=true#gh-light-mode-only\"\u003e\n    \u003c/picture\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n[![npm version](https://img.shields.io/npm/v/coinbase-api)][1]\n[![npm size](https://img.shields.io/bundlephobia/min/coinbase-api/latest)][1]\n[![npm downloads](https://img.shields.io/npm/dt/coinbase-api)][1]\n[![Build \u0026 Test](https://github.com/tiagosiebler/coinbase-api/actions/workflows/e2etest.yml/badge.svg?branch=master)](https://github.com/tiagosiebler/coinbase-api/actions/workflows/e2etest.yml)\n[![last commit](https://img.shields.io/github/last-commit/tiagosiebler/coinbase-api)][1]\n[![Telegram](https://img.shields.io/badge/chat-on%20telegram-blue.svg)](https://t.me/nodetraders)\n\n[1]: https://www.npmjs.com/package/coinbase-api\n\n\u003e [!TIP]\n\u003e Upcoming change: As part of the [Siebly.io](https://siebly.io/?ref=ghcoinbase) brand, this SDK will soon be hosted under the [Siebly.io GitHub organisation](https://github.com/sieblyio). The migration is seamless and requires no user changes.\n\nUpdated \u0026 performant JavaScript \u0026 Node.js SDK for Coinbase's Advanced Trade, App, Exchange, International, Prime \u0026 Commerce REST APIs and WebSockets:\n\n- Professional, robust \u0026 performant Coinbase SDK with extensive production use in live trading environments.\n- Complete integration with all Coinbase APIs - supports both retail and institutional REST clients and WebSockets:\n  - [Coinbase Advanced Trade](https://docs.cdp.coinbase.com/advanced-trade/docs/welcome) - Modern trading platform\n  - [Coinbase App](https://docs.cdp.coinbase.com/coinbase-app/docs/welcome) - Consumer mobile/web application\n  - [Coinbase Exchange](https://docs.cdp.coinbase.com/exchange/docs/welcome) - Professional trading platform\n  - [Coinbase International Exchange](https://docs.cdp.coinbase.com/intx/docs/welcome) - International institutional trading\n  - [Coinbase Prime](https://docs.cdp.coinbase.com/prime/docs/welcome) - Institutional custody and trading\n  - [Coinbase Commerce](https://docs.cdp.coinbase.com/commerce-onchain/docs/welcome) - Payments and commerce solutions\n- Complete TypeScript support (with type declarations for most API requests \u0026 responses).\n  - Strongly typed requests and responses.\n  - Automated end-to-end tests ensuring reliability.\n- Actively maintained with a modern, promise-driven interface.\n- Supports both ECDSA and ED25519 API keys with automatic key type detection.\n- Robust WebSocket integration with configurable connection heartbeats \u0026 automatic reconnect then resubscribe workflows.\n  - Event driven messaging.\n  - Smart WebSocket persistence with automatic reconnection handling.\n  - Emit `reconnected` event when dropped connection is restored.\n  - Support for both public and private WebSocket streams across all platforms.\n- Automatically supports both ESM and CJS projects.\n- Proxy support via axios integration.\n- Heavy automated end-to-end testing with real API calls.\n- Active community support \u0026 collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders).\n- Extensive examples for interacting with the Coinbase API offering in Node.js/JavaScript/TypeScript: [/examples/](./examples).\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Examples](#examples)\n- [Issues \u0026 Discussion](#issues--discussion)\n- [Related Projects](#related-projects)\n- [Documentation](#documentation)\n- [Structure](#structure)\n- [Usage](#usage)\n  - [REST API Clients](#rest-api)\n    - [CBAdvancedTradeClient](#cbadvancedtradeclient)\n    - [CBAppClient](#cbappclient)\n    - [CBExchangeClient](#cbexchangeclient)\n    - [CBInternationalClient](#cbinternationalclient)\n    - [CBPrimeClient](#cbprimeclient)\n    - [CBCommerceClient](#cbcommerceclient)\n  - [WebSocket Client](#websockets)\n    - [Public WebSocket Streams](#public-websocket)\n    - [Private WebSocket Streams](#private-websocket)\n    - [WebSocket Event Handling](#listening-and-subscribing-to-websocket-events)\n- [Customise Logging](#customise-logging)\n- [Browser/Frontend Usage](#browserfrontend-usage)\n  - [Webpack](#webpack)\n- [LLMs \u0026 AI](#use-with-llms--ai)\n- [Used By](#used-by)\n- [Contributions \u0026 Thanks](#contributions--thanks)\n\n## Installation\n\n`npm install --save coinbase-api`\n\n## Examples\n\nRefer to the [examples](./examples) folder for implementation examples.\n\n## Issues \u0026 Discussion\n\n- Issues? Check the [issues tab](https://github.com/tiagosiebler/coinbase-api/issues).\n- Discuss \u0026 collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram.\n- Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/sieblyio)\n\n\u003c!-- template_related_projects --\u003e\n\n## Related Projects\n\nCheck out our JavaScript/TypeScript/Node.js SDKs \u0026 Projects:\n\n- Visit our website: [https://Siebly.io](https://siebly.io/?ref=gh)\n- Try our REST API \u0026 WebSocket SDKs published on npmjs:\n  - [Bybit Node.js SDK: bybit-api](https://www.npmjs.com/package/bybit-api)\n  - [Kraken Node.js SDK: @siebly/kraken-api](https://www.npmjs.com/package/@siebly/kraken-api)\n  - [OKX Node.js SDK: okx-api](https://www.npmjs.com/package/okx-api)\n  - [Binance Node.js SDK: binance](https://www.npmjs.com/package/binance)\n  - [Gate (gate.com) Node.js SDK: gateio-api](https://www.npmjs.com/package/gateio-api)\n  - [Bitget Node.js SDK: bitget-api](https://www.npmjs.com/package/bitget-api)\n  - [Kucoin Node.js SDK: kucoin-api](https://www.npmjs.com/package/kucoin-api)\n  - [Coinbase Node.js SDK: coinbase-api](https://www.npmjs.com/package/coinbase-api)\n  - [Bitmart Node.js SDK: bitmart-api](https://www.npmjs.com/package/bitmart-api)\n- Try my misc utilities:\n  - [OrderBooks Node.js: orderbooks](https://www.npmjs.com/package/orderbooks)\n  - [Crypto Exchange Account State Cache: accountstate](https://www.npmjs.com/package/accountstate)\n- Check out my examples:\n  - [awesome-crypto-examples Node.js](https://github.com/tiagosiebler/awesome-crypto-examples)\n  \u003c!-- template_related_projects_end --\u003e\n\n## Documentation\n\nMost 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.\n\n### API Documentation Links\n\n- [Coinbase Developer Platform - Product APIs](https://docs.cdp.coinbase.com/product-apis/docs/welcome)\n  - [Advanced Trade API](https://docs.cdp.coinbase.com/advanced-trade/docs/welcome)\n  - [Coinbase App API](https://docs.cdp.coinbase.com/coinbase-app/docs/welcome)\n  - [Exchange API](https://docs.cdp.coinbase.com/exchange/docs/welcome)\n  - [International Exchange API](https://docs.cdp.coinbase.com/intx/docs/welcome)\n  - [Prime API](https://docs.cdp.coinbase.com/prime/docs/welcome)\n  - [Commerce API](https://docs.cdp.coinbase.com/commerce-onchain/docs/welcome)\n- [REST Endpoint Function List](./docs/endpointFunctionList.md)\n\n## Structure\n\nThis project uses typescript. Resources are stored in 2 key structures:\n\n- [src](./src) - the whole connector written in typescript\n- [examples](./examples) - some implementation examples \u0026 demonstrations. Contributions are welcome!\n\n---\n\n# Usage\n\nCreate API credentials on Coinbase's website:\n\n- [Coinbase API Key Management](https://www.coinbase.com/settings/api)\n\n## REST API\n\nThe SDK provides dedicated REST clients for each of Coinbase's API groups. Each client is designed for specific use cases and user types:\n\nTo 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:\n\n- [CBAdvancedTradeClient](./src/CBAdvancedTradeClient.ts)\n- [CBAppClient](./src/CBAppClient.ts)\n- [CBExchangeClient](./src/CBExchangeClient.ts)\n- [CBInternationalClient](./src/CBInternationalClient.ts)\n- [CBPrimeClient](./src/CBPrimeClient.ts)\n- [CBCommerceClient](./src/CBCommerceClient.ts)\n\n#### CBAdvancedTradeClient\n\n```javascript\nconst { CBAdvancedTradeClient } = require('coinbase-api');\n/**\n * Or, with import:\n * import { CBAdvancedTradeClient } from 'coinbase-api';\n */\n\n// insert your API key details here from Coinbase API Key Management\nconst advancedTradeCdpAPIKey = {\n  // dummy example keys to understand the structure\n  name: 'organizations/13232211d-d7e2-d7e2-d7e2-d7e2d7e2d7e2/apiKeys/d7e2d7e2-d7e2-d7e2-d7e2-d7e2d7e2d7e2',\n  privateKey:\n    '-----BEGIN EC PRIVATE KEY-----\\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+oAoGCCqGSM49\\nAwEHoUQDQgAEhtAep/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+bzduY3iYXEmj/KtCk\\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj\\n-----END EC PRIVATE KEY-----\\n',\n};\n\n/*\n * You can add ECDSA keys like the example above, or ED25519 keys like the example below.\n * Client will recognize both types of keys automatically.\n * ED25519:\n * {\n *   name: 'your-api-key-id',\n *   privateKey: 'yourExampleApiSecretEd25519Version==',\n * }\n */\n\nconst client = new CBAdvancedTradeClient({\n  // Either pass the full JSON object that can be downloaded when creating your API keys\n  // cdpApiKey: advancedTradeCdpAPIKey,\n\n  // Or use the key name as \"apiKey\" and private key (WITH the \"begin/end EC PRIVATE KEY\" comment) as \"apiSecret\"\n  apiKey: advancedTradeCdpAPIKey.name,\n  apiSecret: advancedTradeCdpAPIKey.privateKey,\n});\n\nasync function doAPICall() {\n  // Example usage of the CBAdvancedTradeClient\n  try {\n    const accounts = await client.getAccounts();\n    console.log('Get accounts result: ', accounts);\n  } catch (e) {\n    console.error('Exception: ', JSON.stringify(e));\n  }\n}\n\ndoAPICall();\n```\n\n#### CBAppClient\n\n```javascript\nconst { CBAppClient } = require('coinbase-api');\n/**\n * Or, with import:\n * import { CBAppClient } from 'coinbase-api';\n */\n\n// insert your API key details here from Coinbase API Key Management\nconst CBAppKeys = {\n  // dummy example keys to understand the structure\n  name: 'organizations/13232211d-d7e2-d7e2-d7e2-d7e2d7e2d7e2/apiKeys/d7e2d7e2-d7e2-d7e2-d7e2-d7e2d7e2d7e2',\n  privateKey:\n    '-----BEGIN EC PRIVATE KEY-----\\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+oAoGCCqGSM49\\nAwEHoUQDQgAEhtAep/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+bzduY3iYXEmj/KtCk\\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj\\n-----END EC PRIVATE KEY-----\\n',\n};\n\n/*\n * You can add ECDSA keys like the example above, or ED25519 keys like the example below.\n * Client will recognize both types of keys automatically.\n * ED25519:\n * {\n *   name: 'your-api-key-id',\n *   privateKey: 'yourExampleApiSecretEd25519Version==',\n * }\n */\n\nconst client = new CBAppClient({\n  // Either pass the full JSON object that can be downloaded when creating your API keys\n  // cdpApiKey: CBAppCdpAPIKey,\n\n  // Or use the key name as \"apiKey\" and private key (WITH the \"begin/end EC PRIVATE KEY\" comment) as \"apiSecret\"\n  apiKey: CBAppKeys.name,\n  apiSecret: CBAppKeys.privateKey,\n});\n\nasync function doAPICall() {\n  try {\n    // Transfer money between your own accounts\n    const transferMoneyResult = await client.transferMoney({\n      account_id: 'your_source_account_id',\n      type: 'transfer',\n      to: 'your_destination_account_id',\n      amount: '0.01',\n      currency: 'BTC',\n    });\n    console.log('Transfer Money Result: ', transferMoneyResult);\n  } catch (e) {\n    console.error('Error: ', e);\n  }\n}\n\ndoAPICall();\n```\n\n#### CBInternationalClient\n\n```javascript\nconst { CBInternationalClient } = require('coinbase-api');\n/**\n * Or, with import:\n * import { CBInternationalClient } from 'coinbase-api';\n */\n\n// insert your API key details here from Coinbase API Key Management\nconst client = new CBInternationalClient({\n  apiKey: 'insert_api_key_here',\n  apiSecret: 'insert_api_secret_here',\n  apiPassphrase: 'insert_api_passphrase_here',\n  // Set \"useSandbox\" to use the CoinBase International API sandbox environment\n  // useSandbox: true,\n});\n\nasync function doAPICall() {\n  try {\n    // Get asset details\n    const assetDetails = await client.getAssetDetails({ asset: 'BTC' });\n    console.log('Asset Details: ', assetDetails);\n  } catch (e) {\n    console.error('Exception: ', JSON.stringify(e, null, 2));\n  }\n}\n\ndoAPICall();\n```\n\n#### CBExchangeClient\n\n```javascript\nconst { CBExchangeClient } = require('coinbase-api');\n/**\n * Or, with import:\n * import { CBExchangeClient } from 'coinbase-api';\n */\n\n// insert your API key details here from Coinbase API Key Management\nconst client = new CBExchangeClient({\n  apiKey: 'insert_api_key_here',\n  apiSecret: 'insert_api_secret_here',\n  apiPassphrase: 'insert_api_passphrase_here',\n  // Set \"useSandbox\" to use the CoinBase International API sandbox environment\n  // useSandbox: true,\n});\n\nasync function doAPICall() {\n  try {\n    // Get a single currency by id\n    const currency = await client.getCurrency('BTC');\n    console.log('Currency: ', currency);\n  } catch (e) {\n    console.error('Exception: ', JSON.stringify(e, null, 2));\n  }\n}\n\ndoAPICall();\n```\n\nSee all clients [here](./src/) for more information on all the functions or the [examples](./examples/) for lots of usage examples. You can also check the endpoint function list [here](./docs/endpointFunctionList.md) to find all available functions!\n\n## WebSockets\n\nAll available WebSockets can be used via a shared `WebsocketClient`. The WebSocket client will automatically open/track/manage connections as needed. Each unique connection (one per server URL) is tracked using a WsKey (each WsKey is a string - see [WS_KEY_MAP](src/lib/websocket/websocket-util.ts) for a list of supported values - `WS_KEY_MAP` can also be used like an enum).\n\nAny subscribe/unsubscribe events will need to include a WsKey, so the WebSocket client understands which connection the event should be routed to. See examples below or in the [examples](./examples/) folder on GitHub.\n\nData events are emitted from the WebsocketClient via the `update` event, see example below:\n\n#### Public Websocket\n\n```javascript\nconst { WebsocketClient } = require('coinbase-api');\n/**\n * Or, with import:\n * import { WebsocketClient } from 'coinbase-api';\n */\n\n// public ws client, doesnt need any api keys to run\nconst client = new WebsocketClient();\n\n// The WS Key (last parameter) dictates which WS feed this request goes to (aka if auth is required).\n// As long as the WS feed doesn't require auth, you should be able to subscribe to channels without api credentials.\nclient.subscribe(\n  {\n    topic: 'status',\n    payload: {\n      product_ids: ['XRP-USD'],\n    },\n  },\n  'advTradeMarketData',\n);\n```\n\n#### Private Websocket\n\n```javascript\nconst { WebsocketClient } = require('coinbase-api');\n/**\n * Or, with import:\n * import { WebsocketClient } from 'coinbase-api';\n */\n\n// key name \u0026 private key, as returned by coinbase when creating your API keys.\n// Note: the below example is a dummy key and won't actually work\nconst advancedTradeCdpAPIKey = {\n  name: 'organizations/13232211d-d7e2-d7e2-d7e2-d7e2d7e2d7e2/apiKeys/d7e2d7e2-d7e2-d7e2-d7e2-d7e2d7e2d7e2',\n  privateKey:\n    '-----BEGIN EC PRIVATE KEY-----\\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+oAoGCCqGSM49\\nAwEHoUQDQgAEhtAep/ADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj+bzduY3iYXEmj/KtCk\\nADFGHmkgnjdfg16k165kuu1kdtyudtyjdtyjytj\\n-----END EC PRIVATE KEY-----\\n',\n};\n\n/*\n * You can add ECDSA keys like the example above, or ED25519 keys like the example below.\n * Client will recognize both types of keys automatically.\n * ED25519:\n * {\n *   name: 'your-api-key-id',\n *   privateKey: 'yourExampleApiSecretEd25519Version==',\n * }\n */\n\nconst client = new WebsocketClient({\n  // Either pass the full JSON object that can be downloaded when creating your API keys\n  // cdpApiKey: advancedTradeCdpAPIKey,\n\n  // Or use the key name as \"apiKey\" and private key (WITH the \"begin/end EC PRIVATE KEY\" comment) as \"apiSecret\"\n  apiKey: advancedTradeCdpAPIKey.name,\n  apiSecret: advancedTradeCdpAPIKey.privateKey,\n});\n```\n\n#### Listening and subscribing to Websocket events\n\n```javascript\n// add event listeners for websocket clients\n\nclient.on('open', (data) =\u003e {\n  console.log('open: ', data?.wsKey);\n});\n\n// Data received\nclient.on('update', (data) =\u003e {\n  console.info(new Date(), 'data received: ', JSON.stringify(data));\n});\n\n// Something happened, attempting to reconenct\nclient.on('reconnect', (data) =\u003e {\n  console.log('reconnect: ', data);\n});\n\n// Reconnect successful\nclient.on('reconnected', (data) =\u003e {\n  console.log('reconnected: ', data);\n});\n\n// Connection closed. If unexpected, expect reconnect -\u003e reconnected.\nclient.on('close', (data) =\u003e {\n  console.error('close: ', data);\n});\n\n// Reply to a request, e.g. \"subscribe\"/\"unsubscribe\"/\"authenticate\"\nclient.on('response', (data) =\u003e {\n  console.info('response: ', JSON.stringify(data, null, 2));\n  // throw new Error('res?');\n});\n\nclient.on('exception', (data) =\u003e {\n  console.error('exception: ', data);\n});\n\n/**\n * Use the client subscribe(topic, market) pattern to subscribe to any websocket topic.\n *\n * You can subscribe to topics one at a time or many in one request.\n *\n * Topics can be sent as simple strings, if no parameters are required:\n */\n\n// market data\nclient.subscribe('heartbeats', 'advTradeMarketData');\n// This is the same as above, but using WS_KEY_MAP like an enum to reduce any uncertainty on what value to use:\n// client.subscribe('heartbeats', WS_KEY_MAP.advTradeMarketData);\n\n// user data\nclient.subscribe('futures_balance_summary', 'advTradeUserData');\nclient.subscribe('user', 'advTradeUserData');\n\n/**\n * Or send a more structured object with parameters, e.g. if parameters are required\n */\nconst tickerSubscribeRequest = {\n  topic: 'ticker',\n  /**\n   * Anything in the payload will be merged into the subscribe \"request\",\n   * allowing you to send misc parameters supported by the exchange (such as `product_ids: string[]`)\n   */\n  payload: {\n    product_ids: ['ETH-USD', 'BTC-USD'],\n  },\n};\nclient.subscribe(tickerSubscribeRequest, 'advTradeMarketData');\n\n/**\n * Other adv trade public websocket topics:\n */\nclient.subscribe(\n  [\n    {\n      topic: 'candles',\n      payload: {\n        product_ids: ['ETH-USD'],\n      },\n    },\n    {\n      topic: 'market_trades',\n      payload: {\n        product_ids: ['ETH-USD', 'BTC-USD'],\n      },\n    },\n    {\n      topic: 'ticker',\n      payload: {\n        product_ids: ['ETH-USD', 'BTC-USD'],\n      },\n    },\n    {\n      topic: 'ticker_batch',\n      payload: {\n        product_ids: ['ETH-USD', 'BTC-USD'],\n      },\n    },\n    {\n      topic: 'level2',\n      payload: {\n        product_ids: ['ETH-USD', 'BTC-USD'],\n      },\n    },\n  ],\n  'advTradeMarketData',\n);\n```\n\nSee [WebsocketClient](./src/WebsocketClient.ts) for further information and make sure to check the [examples](./examples/) folder for much more usage examples, especially [publicWs.ts](./examples/AdvancedTrade/WebSockets/publicWs.ts) and [privateWs.ts](./examples/AdvancedTrade/WebSockets/privateWs.ts), which explains a lot of small details.\n\n---\n\n## Customise Logging\n\nPass a custom logger which supports the log methods `trace`, `info` and `error`, or override methods from the default logger as desired.\n\n```javascript\nconst { WebsocketClient, DefaultLogger } = require('coinbase-api');\n/**\n * Or, with import:\n * import { WebsocketClient, DefaultLogger } from 'coinbase-api';\n */\n\n// E.g. customise logging for only the trace level:\nconst logger = {\n  // Inherit existing logger methods, using an object spread\n  ...DefaultLogger,\n  // Define a custom trace function to override only that function\n  trace: (...params) =\u003e {\n    if (\n      [\n        'Sending ping',\n        'Sending upstream ws message: ',\n        'Received pong, clearing pong timer',\n        'Received ping, sending pong frame',\n      ].includes(params[0])\n    ) {\n      return;\n    }\n    console.log('trace', params);\n  },\n};\n\nconst ws = new WebsocketClient(\n  {\n    apiKey: 'apiKeyHere',\n    apiSecret: 'apiSecretHere',\n    apiPassphrase: 'apiPassPhraseHere',\n  },\n  logger,\n);\n```\n\n## Browser/Frontend Usage\n\n### Webpack\n\nBuild a bundle using webpack:\n\n- `npm install`\n- `npm run build`\n- `npm run pack`\n\nThe bundle can be found in `dist/`. Altough usage should be largely consistent, smaller differences will exist. Documentation is still TODO.\n\n## Use with LLMs \u0026 AI\n\nThis 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.\n\nThis 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.\n\n---\n\n## Used By\n\n[![Repository Users Preview Image](https://dependents.info/tiagosiebler/coinbase-api/image)](https://github.com/tiagosiebler/coinbase-api/network/dependents)\n\n---\n\n\u003c!-- template_contributions --\u003e\n\n### Contributions \u0026 Thanks\n\nHave my projects helped you? Share the love, there are many ways you can show your thanks:\n\n- Star \u0026 share my projects.\n- Are my projects useful? Sponsor me on Github and support my effort to maintain \u0026 improve them: https://github.com/sponsors/tiagosiebler\n- Have an interesting project? Get in touch \u0026 invite me to it.\n- Or buy me all the coffee:\n  - ETH(ERC20): `0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C` \u003c!-- metamask --\u003e\n- Sign up with my referral links:\n  - OKX (receive a 20% fee discount!): https://www.okx.com/join/42013004\n  - Binance (receive a 20% fee discount!): https://accounts.binance.com/register?ref=OKFFGIJJ\n  - HyperLiquid (receive a 4% fee discount!): https://app.hyperliquid.xyz/join/SDK\n  - Gate: https://www.gate.io/signup/NODESDKS?ref_type=103\n\n\u003c!---\nold ones:\n  - BTC: `1C6GWZL1XW3jrjpPTS863XtZiXL1aTK7Jk`\n  - BTC(SegWit): `bc1ql64wr9z3khp2gy7dqlmqw7cp6h0lcusz0zjtls`\n  - ETH(ERC20): `0xe0bbbc805e0e83341fadc210d6202f4022e50992`\n  - USDT(TRC20): `TA18VUywcNEM9ahh3TTWF3sFpt9rkLnnQa\n  - gate: https://www.gate.io/signup/AVNNU1WK?ref_type=103\n\n--\u003e\n\u003c!-- template_contributions_end --\u003e\n\n### Contributions \u0026 Pull Requests\n\nContributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.\n\n\u003c!-- template_star_history --\u003e\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/bybit-api,tiagosiebler/okx-api,tiagosiebler/binance,tiagosiebler/bitget-api,tiagosiebler/bitmart-api,tiagosiebler/gateio-api,tiagosiebler/kucoin-api,tiagosiebler/coinbase-api,tiagosiebler/orderbooks,tiagosiebler/accountstate,tiagosiebler/awesome-crypto-examples\u0026type=Date)](https://star-history.com/#tiagosiebler/bybit-api\u0026tiagosiebler/okx-api\u0026tiagosiebler/binance\u0026tiagosiebler/bitget-api\u0026tiagosiebler/bitmart-api\u0026tiagosiebler/gateio-api\u0026tiagosiebler/kucoin-api\u0026tiagosiebler/coinbase-api\u0026tiagosiebler/orderbooks\u0026tiagosiebler/accountstate\u0026tiagosiebler/awesome-crypto-examples\u0026Date)\n\n\u003c!-- template_star_history_end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiagosiebler%2Fcoinbase-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiagosiebler%2Fcoinbase-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiagosiebler%2Fcoinbase-api/lists"}