{"id":13779119,"url":"https://github.com/saytoken/ccew","last_synced_at":"2025-05-11T12:32:48.847Z","repository":{"id":138046339,"uuid":"139133405","full_name":"saytoken/ccew","owner":"saytoken","description":"CryptoCurrency Exchange Trade WebSocket Api","archived":false,"fork":false,"pushed_at":"2019-04-16T13:25:20.000Z","size":125,"stargazers_count":15,"open_issues_count":1,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T02:35:27.695Z","etag":null,"topics":["bitcoin","blockchain","ccxt","cryptocurrency","eos","ethereum","exchange"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/saytoken.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-06-29T10:00:11.000Z","updated_at":"2024-06-29T06:04:55.000Z","dependencies_parsed_at":"2024-01-07T23:58:20.711Z","dependency_job_id":null,"html_url":"https://github.com/saytoken/ccew","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saytoken%2Fccew","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saytoken%2Fccew/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saytoken%2Fccew/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saytoken%2Fccew/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saytoken","download_url":"https://codeload.github.com/saytoken/ccew/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253567295,"owners_count":21928809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bitcoin","blockchain","ccxt","cryptocurrency","eos","ethereum","exchange"],"created_at":"2024-08-03T18:01:01.310Z","updated_at":"2025-05-11T12:32:48.518Z","avatar_url":"https://github.com/saytoken.png","language":"JavaScript","funding_links":[],"categories":["Other"],"sub_categories":[],"readme":"# CryptoCurrency eXchange WebSockets\n\n[![CircleCI](https://circleci.com/gh/altangent/ccew/tree/master.svg?style=shield)](https://circleci.com/gh/altangent/ccew/tree/master)\n[![Coverage Status](https://coveralls.io/repos/github/altangent/ccew/badge.svg?branch=master)](https://coveralls.io/github/altangent/ccew?branch=master)\n\nA JavaScript library for connecting to realtime public APIs on all cryptocurrency exchanges.\n\nccew can be used by those wishing to use a standardized eventing interface for connection to these public APIs. Currently ccew support trade and orderbook events. Support for tickers and candle events will be added in the future.\n\nThe ccew socket client performs automatic reconnection when there are disconnections. It also has silent reconnection logic to assist when no data has been seen by the client, but the socket remains open.\n\nccew uses similar market structures to those generated by the CCXT library. This allows interoperability between the RESTful interfaces provided by CCXT and the realtime interfaces provided by ccew.\n\n## Getting Started\n\nInstall ccew\n\n```bash\nnpm install ccew\n```\n\nCreate a new client for an exchange. Subscribe to the events that you want to listen to by supplying a market.\n\n```javascript\nconst ccew = require(\"ccew\");\nconst binance = new ccew.Binance();\n\n// market could be from CCXT or genearted by the user\nconst market = {\n  id: \"ADABTC\", // remote_id used by the exchange\n  base: \"ADA\", // standardized base symbol for Cardano\n  quote: \"BTC\", // standardized quote symbol for Bitcoin\n};\n\n// handle trade events\nbinance.on(\"trade\", trade =\u003e console.log(trade));\n\n// handle level2 orderbook snapshots\nbinance.on(\"l2snapshot\", snapshot =\u003e console.log(snapshot));\n\n// subscribe to trades\nbinance.subscribeTrades(market);\n\n// subscribe to level2 orderbook snapshots\nbinance.subscribeLevel2Snapshots(market);\n```\n\n## Exchanges\n\n| Exchange | Class    | Ticker  | Trades  | OB-L2 Snapshot | OB-L2 Updates | OB-L3 Snapshot | OB-L3 Updates |\n| -------- | -------- | ------- | ------- | -------------- | ------------- | -------------- | ------------- |\n| Binance  | binance  | Support | Support | Support        | Support       | -              | -             |\n| Bitfinex | bitfinex | Support | Support | -              | Support\\*     | -              | Support\\*     |\n| bitFlyer | bitflyer | Support | Support | -              | Support       | -              | -             |\n| BitMEX   | bitmex   |         | Support | -              | Support\\*     | -              | -             |\n| Bitstamp | bitstamp | -       | Support | Support        | Support       | -              | Support       |\n| Bittrex  | bittrex  | Support | Support | -              | Support\\*     | -              | -             |\n| GDAX     | gdax     | Support | Support | -              | Support\\*     | -              | Support       |\n| Gemini   | gemini   | -       | Support | -              | Support\\*     | -              | -             |\n| HitBTC   | hitbtc   | Support | Support | -              | Support\\*     | -              | -             |\n| Huobi    | huobi    | Support | Support | Support        | -             | -              | -             |\n| OKEx     | okex     | Support | Support | Support        | Support       | -              | -             |\n| Poloniex | poloniex | Support | Support | -              | Support\\*     | -              | -             |\n\nNotes:\n\n* Support\\*: Broadcasts a snapshot event at startup\n\n## Definitions\n\nTrades - A maker/taker match has been made. Broadcast as an aggregated event.\n\nOrderbook level 2 - has aggregated price points for bids/asks that include the price and total volume at that point. Some exchange may include the number of orders making up the volume at that price point.\n\nOrderbook level 3 - this is the most granual order book information. It has raw order information for bids/asks that can be used to build aggregated volume information for the price points.\n\n## API\n\n### `Market`\n\nMarkets are used as input to many of the client functions. Markets can be generated and stored by you the developer or loaded from the CCXT library.\n\nThe following properties are used by ccew.\n\n* `id: string` - the identifier used by the remote exchange\n* `base: string` - the normalized base symbol for the market\n* `quote: string` - the normalized quote symbol for the market\n\n### `Client`\n\nA websocket client that connects to a specific exchange. There is an implementation of this class for each exchange that governs the specific rules for managing the realtime connections to the exchange. You must instantiate the specific exchanges client to conncet to the exchange.\n\n```javascript\nconst binance = new ccew.Binance();\nconst gdax = new ccew.GDAX();\n```\n\n#### Properties\n\n##### `reconnectIntervalMs: int` - default 90000\n\nProperty that controls silent socket drop checking. This will enable a check at the reconnection interval that looks for ANY broadcast message from the server. If there has not been a message since the last check a reconnection (close, connect) operation is performed. This property must be set before the first subscription (and subsequent connection).\n\n#### Events\n\nSubscribe to events by addding an event handler to the client `.on(\u003cevent\u003e)` method of the client. Multiple event handlers can be added for the same event.\n\nOnce an event handler is attached you can start the stream using the `subscribe\u003cX\u003e` methods.\n\n```javascript\nbinance.on(\"trades\", trade =\u003e console.log(trade));\nbinance.on(\"l2snapshot\", snapshot =\u003e console.log(snapshot));\n```\n\n##### `ticker: Ticker`\n\nFired when a ticker update is received. Returns an instance of `Ticker`.\n\n##### `trade: Trade`\n\nFired when a trade is received. Returns an instance of `Trade`.\n\n##### `l2snapshot: Level2Snapshot`\n\nFired when a orderbook level 2 snapshot is received. Returns an instance of `Level2Snapshot`.\n\nThe level of detail will depend on the specific exchange and may include 5/10/20/50/100/1000 bids and asks.\n\nThis event is also fired when subscribing to the `l2update` event on many exchanges.\n\n##### `l2update: Level2Update`\n\nFired when a orderbook level 2 update is recieved. Returns an instance of `Level2Update`.\n\nSubscribing to this event may trigger an initial `l2snapshot` event for many exchanges.\n\n##### `l3snapshot: Level3Snapshot`\n\nFired when a orderbook level 3 snapshot is received. Returns an instance of `Level3Snapshot`.\n\n##### `l3update: Level3Update` - orderbook level 3 Update\n\nFired when a level 3 update is recieved. Returns an instance of `Level3Update`.\n\n#### Methods\n\n##### `subscribeTicker(market): void`\n\nSubscribes to a ticker feed for a market. This method will cause the client to emit `ticker` events that have a payload of the `Ticker` object.\n\n##### `unsubscribeTicker(market): void`\n\nUnsubscribes from a ticker feed for a market.\n\n##### `subscribeTrades(market): void`\n\nSubscribes to a trade feed for a market. This method will cause the client to emit `trade` events that have a payload of the `Trade` object.\n\n##### `unsubscribeTrades(market): void`\n\nUnsubscribes from a trade feed for a market.\n\n\\*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.\n\n##### `subscribeLevel2Snapshots(market): void`\n\nSubscribes to the orderbook level 2 snapshot feed for a market. This method will cause the client to emit `l2snapshot` events that have a payload of the `Level2Snaphot` object.\n\nThis method is a no-op for exchanges that do not support level 2 snapshot subscriptions.\n\n##### `unsubscribeLevel2Snapshots(market): void`\n\nUnbusbscribes from the orderbook level 2 snapshot for a market.\n\n\\*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.\n\n##### `subscribeLevel2Updates(market): void`\n\nSubscribes to the orderbook level 2 update feed for a market. This method will cause the client to emit `l2update` events that have a payload of the `Level2Update` object.\n\nThis method is a no-op for exchanges that do not support level 2 snapshot subscriptions.\n\n##### `unsubscribeLevel2Updates(market): void`\n\nUnbusbscribes from the orderbook level 2 updates for a market.\n\n\\*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.\n\n##### `subscribeLevel3Snapshots(market): void`\n\nSubscribes to the orderbook level 3 snapshot feed for a market. This method will cause the client to emit `l3snapshot` events that have a payload of the `Level3Snaphot` object.\n\nThis method is a no-op for exchanges that do not support level 2 snapshot subscriptions.\n\n##### `unsubscribeLevel3Snapshots(market): void`\n\nUnbusbscribes from the orderbook level 3 snapshot for a market.\n\n\\*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.\n\n##### `subscribeLevel3Updates(market): void`\n\nSubscribes to the orderbook level 3 update feed for a market. This method will cause the client to emit `l3update` events that have a payload of the `Level3Update` object.\n\nThis method is a no-op for exchanges that do not support level 3 snapshot subscriptions.\n\n##### `unsubscribeLevel3Updates(market): void`\n\nUnbusbscribes from the orderbook level 3 updates for a market.\n\n\\*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.\n\n### `Ticker`\n\nThe ticker class is the result of a `ticker` event.\n\n#### Properties\n\n* `fullId: string` - the normalized market id prefixed with the exchange, ie: `Binance:LTC/BTC`\n* `exchange: string` - the name of the exchange\n* `base: string` - the normalized base symbol for the market\n* `quote: string` - the normalized quote symbol for the market\n* `timestamp: int` - the unix timestamp in milliseconds\n* `last: string` - the last price of a match that caused a tick\n* `open: string` - the price 24 hours ago\n* `low: string` - the highest price in the last 24 hours\n* `high: string` - the lowest price in the last 24 hours\n* `volume: string` - the base volume traded in the last 24 hours\n* `quoteVolume: string` - the quote volume traded in the last 24 hours\n* `change: string` - the price change (last - open)\n* `changePercent: string` - the price change in percent (last - open) / open \\* 100\n* `bid: string` - the best bid price\n* `bidVolume: string` - the volume at the best bid price\n* `ask: string` - the best ask price\n* `askVolume: string` - the volume at the best ask price\n\n### `Trade`\n\nThe trade class is the result of a `trade` event emitted from a client.\n\n#### Properties\n\n* `fullId: string` - the normalized market id prefixed with the exchange, ie: `Binance:LTC/BTC`\n* `exchange: string` - the name of the exchange\n* `base: string` - the normalized base symbol for the market\n* `quote: string` - the normalized quote symbol for the market\n* `tradeId: int` - the unique trade identifer from the exchanges feed\n* `unix: int` - the unix timestamp in milliseconds for when the trade executed\n* `side: string` - whether the buyer `buy` or seller `sell` was the maker for the match\n* `price: string` - the price at which the match executed\n* `amount: string` - the amount executed in the match\n\n### `Level2Point`\n\nRepresents a price point in a level 2 orderbook\n\n#### Properties\n\n* `price: string` - price\n* `size: string` - aggregated volume for all orders at this price point\n* `count: int` - optional number of orders aggregated into the price point\n\n### `Level2Snapshot`\n\nThe level 2 snapshot class is the result of a `l2snapshot` or `l2update` event emitted from the client.\n\n#### Properties\n\n* `fullId: string` - the normalized market id prefixed with the exchange, ie: `Binance:LTC/BTC`\n* `exchange: string` - the name of the exchange\n* `base: string` - the normalized base symbol for the market\n* `quote: string` - the normalized quote symbol for the market\n* `timestampMs: int` - optional timestamp in milliseconds for the snapshot\n* `sequenceId: int` - optional sequence identifier for the snapshot\n* `asks: [Level2Point]` - the ask (seller side) price points\n* `bids: [Level2Point]` - the bid (buyer side) price points\n\n### `Level2Update`\n\nThe level 2 update class is a result of a `l2update` event emitted from the client. It consists of a collection of bids/asks even exchanges broadcast single events at a time.\n\n#### Properties\n\n* `fullId: string` - the normalized market id prefixed with the exchange, ie: `Binance:LTC/BTC`\n* `exchange: string` - the name of the exchange\n* `base: string` - the normalized base symbol for the market\n* `quote: string` - the normalized quote symbol for the market\n* `timestampMs: int` - optional timestamp in milliseconds for the snapshot\n* `sequenceId: int` - optional sequence identifier for the snapshot\n* `asks: [Level2Point]` - the ask (seller side) price points\n* `bids: [Level2Point]` - the bid (buyer side) price points\n\n### `Level3Point`\n\nRepresents a price point in a level 3 orderbook\n\n#### Properties\n\n* `orderId: string` - identifier for the order\n* `price: string` - price\n* `size: string` - volume of the order\n* `meta: object` - optional exchange specific metadata with additional information about the update.\n\n### `Level3Snapshot`\n\nThe level 3 snapshot class is the result of a `l3snapshot` or `l3update` event emitted from the client.\n\n#### Properties\n\n* `fullId: string` - the normalized market id prefixed with the exchange, ie: `Binance:LTC/BTC`\n* `exchange: string` - the name of the exchange\n* `base: string` - the normalized base symbol for the market\n* `quote: string` - the normalized quote symbol for the market\n* `timestampMs: int` - optional timestamp in milliseconds for the snapshot\n* `sequenceId: int` - optional sequence identifier for the snapshot\n* `asks: [Level3Point]` - the ask (seller side) price points\n* `bids: [Level3Point]` - the bid (buyer side) price points\n\n### `Level3Update`\n\nThe level 3 update class is a result of a `l3update` event emitted from the client. It consists of a collection of bids/asks even exchanges broadcast single events at a time.\n\nAdditional metadata is often provided in the `meta` property that has more detailed information that is often required to propertly manage a level 3 orderbook.\n\n#### Properties\n\n* `fullId: string` - the normalized market id prefixed with the exchange, ie: `Binance:LTC/BTC`\n* `exchange: string` - the name of the exchange\n* `base: string` - the normalized base symbol for the market\n* `quote: string` - the normalized quote symbol for the market\n* `timestampMs: int` - optional timestamp in milliseconds for the snapshot\n* `sequenceId: int` - optional sequence identifier for the snapshot\n* `asks: [Level3Point]` - the ask (seller side) price points\n* `bids: [Level3Point]` - the bid (buyer side) price points\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaytoken%2Fccew","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaytoken%2Fccew","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaytoken%2Fccew/lists"}