{"id":13583483,"url":"https://github.com/aloysius-pgast/crypto-exchanges-gateway","last_synced_at":"2025-04-06T21:32:08.306Z","repository":{"id":25299865,"uuid":"103654252","full_name":"aloysius-pgast/crypto-exchanges-gateway","owner":"aloysius-pgast","description":"Your gateway to the world of crypto !","archived":false,"fork":false,"pushed_at":"2024-07-29T17:24:18.000Z","size":3327,"stargazers_count":586,"open_issues_count":6,"forks_count":154,"subscribers_count":46,"default_branch":"master","last_synced_at":"2024-08-02T15:53:25.400Z","etag":null,"topics":["api","binance","bittrex","cryptocurrency","exchanges","kucoin","okex","poloniex","trading"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aloysius-pgast.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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}},"created_at":"2017-09-15T12:25:00.000Z","updated_at":"2024-07-30T15:17:03.000Z","dependencies_parsed_at":"2023-11-11T19:25:03.351Z","dependency_job_id":"25abc706-396c-4340-a90e-ad9d87d4dcf8","html_url":"https://github.com/aloysius-pgast/crypto-exchanges-gateway","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloysius-pgast%2Fcrypto-exchanges-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloysius-pgast%2Fcrypto-exchanges-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloysius-pgast%2Fcrypto-exchanges-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloysius-pgast%2Fcrypto-exchanges-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aloysius-pgast","download_url":"https://codeload.github.com/aloysius-pgast/crypto-exchanges-gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223264832,"owners_count":17116218,"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":["api","binance","bittrex","cryptocurrency","exchanges","kucoin","okex","poloniex","trading"],"created_at":"2024-08-01T15:03:30.724Z","updated_at":"2024-11-06T00:30:19.850Z","avatar_url":"https://github.com/aloysius-pgast.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Market data libraries"],"sub_categories":[],"readme":"# crypto-exchanges-gateway\n\nYour gateway to the world of crypto !\n\nNB: this project won't build unless you use node 14.x (check Nix for that). It's unlikely to be updated since I don't really have time to work on it anymore :)\n\n## Disclaimer\n\nThis project cannot be considered in any way as trading advice.\n\nUse it at your own risks and be careful with your money ;)\n\n## Faq\n\n* Does it support real-time data ?\n\nYes, gateway provides a WS endpoint. See [video](https://youtu.be/_LfLLT693AM) explaining how to create custom WS streams\n\n* What about _ccxt_ ?\n\n_ccxt_ is a very nice project which provides a library to connect to multiple exchanges (_php_,_js_,_python_). When I started, I wasn't aware of the project. While _ccxt_ aims at providing a library, I want to offer an http gateway as an independant service to be used by any REST client (so virtually any language).\n\nBtw, _ccxt_ library is now used to interface with some exchanges ;)\n\n* What is the monthly fee for the service ?\n\nThere is no monthly fee. It's free since you will be the one running the service on your own server\n\n* Where is your service hosted ?\n\nThis is a self-hosted service. You need to install it on your own server\n\n* I saw you are accepting donations. What extra service will I get for a donation ?\n\nBesides the privilege to go to bed, knowing that you did the right thing ? Not much\n\n## What it does\n\n* Provides a unified REST API to various exchanges (can be used to automate trading or build bots)\n* Handles authentication so that on client side you can concentrate on what really matters\n* Implements rate limiting when forwarding requests to remote exchanges\n* Provides a REST API to send push notifications using [PushOver](https://pushover.net/api)\n* Provides a basic UI which implements most API calls (see [documentation in _doc_ directory](doc/ui/index.adoc))\n* Provides WS access for real-time data (tickers, order books \u0026 trades, see [documentation in _doc_ directory](doc/ws/index.adoc) and [video](https://youtu.be/_LfLLT693AM) explaining how to create custom WS streams to multiplex data from multiple exchanges)\n* Access to a portfolio portfolio overview across all exchanges with estimated value in USD\n* Advanced alerting system\n\n\u003cimg src=\"doc/ui/img/tickers.png\" width=\"400\"/\u003e\n\nSee a live demo at https://mpe-demo.crazyme.net/ui/\n\nOf course, above demo **does not use any valid _user/token_**. This means the following :\n\n* everything related to _price_ \u0026 _order book_ is **populated with real data**\n* the list of _open/completed orders_ is **filled with random data**\n* the list of _balances_ is **filled with random data**\n* _new orders_ **won't be actually executed** ;)\n\nIn order to have a full experience, just follow [installation steps](#installation)\n\n## How to use it\n\n[Install](#installation) it wherever you want and start sending requests from your own program\n\n* it can be hosted on a VM in the cloud\n* it can be installed at home, on a [Raspberry Pi](https://www.raspberrypi.org/products/raspberry-pi-zero-w/)\n\nJust use you favorite language (_python_, _javascript_, _ruby_, _bash_, ...) to send request to the gateway. Your own service, your own rules !\n\nA _Node.js_ client is available [here](https://github.com/aloysius-pgast/crypto-exchanges-rest-client-nodejs) or as a [npm package](https://www.npmjs.com/package/crypto-exchanges-rest-client)\n\n## Available Exchanges\n\nCurrently supports for following exchanges :\n\n* [Binance](https://www.binance.com/) (used to be my favorite)\n* [Bittrex](https://www.bittrex.com/)\n* [Kucoin](https://www.kucoin.com) (optional KYC)\n* [OKEx](https://www.okex.com) (optional KYC)\n* [Poloniex](https://www.poloniex.com) ([**worst support**](https://www.reddit.com/r/PoloniexForum/) ever)\n* More to come...\n\nFollowing API are currently supported :\n\n* Retrieve pairs\n* Retrieve tickers\n* Retrieve order book\n* Retrieve last executed trades\n* Retrieve klines (charts data)\n* List open orders\n* List closed orders\n* Retrieve a single order\n* Test an order (to ensure quantity and price match exchange filters)\n* Create an order\n* Retrieve balances\n\nSee [documentation in _doc_ directory](doc/exchanges/index.adoc) for an overview of each REST API\n\nSee [documentation in _doc_ directory](doc/ws/index.adoc) for a description of the supported _websocket protocol_ (similar to _JSON-RPC_)\n\nSee [documentation in _doc_ directory](doc/unitTests.adoc) for informations regarding unit tests\n\n## Alerts\n\nHave you ever wanted to receive an alert in case ALL of the following conditions are met :\n* NEO-USDT price in range [120, 135] on Binance\n* NEO-BTC price on Bittrex \u003c 0.010\n* NEO price in MarketCap module \u003e 125$\n\nProbably not ;) Anyway, you will now be able to define this kind of custom alerts. See [documentation in _doc_ directory](doc/tickerMonitor/index.adoc)\n\nIt comes with built-in support for [PushOver](https://pushover.net/) but any other notification system can be easily implemented (through third party applications) since all alert changes are emitted over a websocket endpoint (see [documentation in _doc_ directory](doc/ws/notifications.adoc#tickermonitor-notifications))\n\n## Limitations\n\n* Margin trading is not supported (and is unlikely to be)\n* Withdrawal is not supported (and is unlikely to be)\n* _Stop loss_ \u0026 _trailing stop loss_ are not supported for the moment (although it might be supported at some point)\n\n## Other services\n\n### MarketCap\n\nMarketCap module supports :\n\n* Tickers\n\nSee [documentation in _doc_ directory](doc/marketCap/index.adoc) for an overview of each API\n\n### Push Over\n\n[PushOver](https://pushover.net/) module supports :\n\n* Push notifications\n\nSee [documentation in _doc_ directory](doc/pushover/index.adoc) for an overview of each API)\n\n## Rate limiting\n\nRate limiting is implemented when required by exchange thanks to [Bottleneck](https://www.npmjs.com/package/bottleneck)\n\n## Installation\n\n* Install dependencies\n\n```\nnpm install\n```\n\n* Copy sample config\n\n```\ncp config/config.sample.json config/config.json\n```\n\nCheck [documentation in _doc_ directory](doc/config.adoc) for detailed information on each config section\n\n* Start gateway\n\n```\nnode gateway.js\n```\n\n* Build UI\n\nIf you want to use the UI, follow these steps to build the UI before starting the gateway:\n\n```\ncd ui\nnpm install \u0026\u0026 ./rebuild-ui\n```\n\n* Check which exchanges are enabled\n\nOpen http://127.0.0.1:8000/exchanges/ in your browser. You should see JSON content such as below :\n\n```javascript\n[\"binance\",\"bittrex\",\"poloniex\",\"kucoin\"]\n```\n\nBy default, only public API will be enabled. In order to access trading/private API, you need to update _config.json_ with appropriate _user_ and _secret_ provided by exchange (check [documentation in _doc_ directory](doc/config.adoc) )\n\n* Check BTC \u0026 ETH prices using _MarketCap_ module\n\nOpen http://127.0.0.1:8000/marketCap/tickers?symbols=BTC,ETH in your browser. You should see JSON content such as below :\n\n```javascript\n[\n    {\n        \"symbol\":\"BTC\",\n        \"name\":\"Bitcoin\",\n        \"circulating_supply\":17372012,\n        \"price_usd\":6406.1049,\n        \"percent_change_1h\":-0.08,\n        \"percent_change_1d\":-0.08,\n        \"percent_change_7d\":-0.15,\n        \"volume_24h_usd\":3120534126.1266,\n        \"lastUpdated\":1542009997,\n        \"market_cap_usd\":111286930723.4185,\n        \"rank\":1,\n        \"price_btc\":1\n    },\n    {\n        \"symbol\":\"ETH\",\n        \"name\":\"Ethereum\",\n        \"circulating_supply\":103150460,\n        \"price_usd\":210.4854,\n        \"percent_change_1h\":-0.39,\n        \"percent_change_1d\":-0.39,\n        \"percent_change_7d\":-0.8,\n        \"volume_24h_usd\":1294093048.2094,\n        \"lastUpdated\":1542009997,\n        \"market_cap_usd\":21711669585.6914,\n        \"rank\":2,\n        \"price_btc\":0.032857\n    }\n]\n```\n\n* Place an order to buy 1 NEO at 0.0040BTC on Bittrex (assuming you have enough funds)\n\nExecute the following in a terminal :\n\n```\ncurl -X POST 'http://127.0.0.1:8000/exchanges/bittrex/openOrders?pair=BTC-NEO\u0026quantity=1\u0026targetRate=0.0040'\n```\n\nYou should see JSON content such as below :\n\n```javascript\n{\"orderNumber\":\"8bc49a59-1056-4c20-90f2-893fff2be279\"}\n```\n\n* Cancel above order (assuming order still exists)\n\nExecute the following in a terminal :\n\n```\ncurl -X DELETE 'http://127.0.0.1:8000/exchanges/bittrex/openOrders/8bc49a59-1056-4c20-90f2-893fff2be279'\n```\n\nYou should see JSON content such as below in case order is valid :\n\n```javascript\n{}\n```\n\n## Docker\n\nSee this [video](https://youtu.be/SQf3diruc8w) to know how to be ready to trade in less then 3 minutes using Docker \u0026 Kitematic\n\nA docker image is available at https://hub.docker.com/r/apendergast/crypto-exchanges-gateway/\n\n* Pull image\n\n```\ndocker pull apendergast/crypto-exchanges-gateway\n```\n\n* Run image\n\n```\ndocker run --rm -p 8000:8000 -p 8001:8001 --name ceg apendergast/crypto-exchanges-gateway\n```\n\nYou should then be able to access service on http://127.0.0.1:8000\n\nWS endpoint will be available on _ws://127.0.0.1:8001_\n\n* Check which exchanges are enabled\n\nOpen http://127.0.0.1:8000/exchanges/ in your browser. You should see JSON content such as below :\n\n```javascript\n[\"binance\",\"bittrex\",\"kucoin\",\"okex\",\"poloniex\"]\n```\n\nBy default, only public API will be enabled. In order to access trading/private API, you need to pass environment when creating container. Following environment variables are available :\n\n* cfg.logLevel : log level\n* cfg.listen.externalEndpoint : used to indicates the external endpoint used to reach http socket, in case gateway is running behing a proxy\n* cfg.listenWs.externalEndpoint : used to indicates the external endpoint used to reach ws socket, in case gateway is running behing a proxy\n* cfg.sessions.maxSubscriptions : maximum number of subscriptions allowed for a given session (optional, default = _0_, no maximum)\n* cfg.sessions.maxDuration : maximum duration in second for a given session (optional, default = _0_, no maximum)\n* cfg.sessions.hideIpaddr : whether or not ip addresses should be hidden when listing sessions through REST api (optional, default = _0_)\n* cfg.auth.apikey : API Key used to protect access\n* cfg.ui.enabled : enable/disable UI (value should be set to _1_ to enable UI, _0_ to disable UI)\n* cfg.tickerMonitor.enabled : enable/disable Ticker Monitor module (value should be set to _1_ to enable Ticker Monitor, _0_ to disable Ticker Monitor) (default = _1_)\n* cfg.marketCap.enabled : enable/disable MarketCap module (value should be set to _1_ to enable MarketCap module, _0_ to disable MarketCap module) (default = _1_)\n* cfg.pushover.user : PushOver user key\n* cfg.pushover.token : PushOver token\n* cfg.exchanges.poloniex.enabled : value should be set to _1_ to enable exchange, _0_ to disable exchange (default = _1_)\n* cfg.exchanges.poloniex.key : Poloniex user key\n* cfg.exchanges.poloniex.secret : Poloniex secret\n* cfg.exchanges.bittrex.enabled : value should be set to _1_ to enable exchange, _0_ to disable exchange (default = _1_)\n* cfg.exchanges.bittrex.key : Bittrex user key\n* cfg.exchanges.bittrex.secret : Bittrex secret\n* cfg.exchanges.binance.enabled : value should be set to _1_ to enable exchange, _0_ to disable exchange (default = _1_)\n* cfg.exchanges.binance.requirePair : value should be set to _0_ to allow retrieving tickers/orders for all pairs at once, _1_ to require pair for such operations (default = _0_)\n* cfg.exchanges.binance.key : Binance user key\n* cfg.exchanges.binance.secret : Binance secret\n* cfg.exchanges.kucoin.enabled : value should be set to _1_ to enable exchange, _0_ to disable exchange (default = _1_)\n* cfg.exchanges.kucoin.requirePair : value should be set to _0_ to allow retrieving tickers/orders for all pairs at once, _1_ to require pair for such operations (default = _0_)\n* cfg.exchanges.kucoin.key : Kucoin user key\n* cfg.exchanges.kucoin.secret : Kucoin secret\n* cfg.exchanges.kucoin.password : Kucoin API password\n* cfg.exchanges.okex.enabled : value should be set to _1_ to enable exchange, _0_ to disable exchange (default = _1_)\n* cfg.exchanges.okex.requirePair : value should be set to _0_ to allow retrieving tickers/orders for all pairs at once, _1_ to require pair for such operations (default = _0_)\n* cfg.exchanges.okex.key : OKEx user key\n* cfg.exchanges.okex.secret : OKEx secret\n* cfg.exchanges.okex.password : OKEx password\n\nIf you don't want to use environment variables or want to customize config for a running container, you can create and edit *custom_config/config.json*\n\n_Examples_ :\n\nRun container with Bittrex user/key environment variables\n\n```\ndocker run --rm -p 8000:8000 -p 8001:8001 --name ceg -e cfg.exchanges.bittrex.key='abcdefghijkl' -e cfg.exchanges.bittrex.secret='123456789' apendergast/crypto-exchanges-gateway\n```\n\n## Dependencies\n\nThis project was made possible thanks to following projects :\n\n* [big.js](https://www.npmjs.com/package/big.js)\n* [binance](https://www.npmjs.com/package/binance)\n* [body-parser](https://www.npmjs.com/package/body-parser)\n* [bottleneck](https://www.npmjs.com/package/bottleneck) (for rate limiting)\n* [ccxt](https://www.npmjs.com/package/ccxt) (used to interface with some exchanges)\n* [chump](https://www.npmjs.com/package/chump) (for PushOver)\n* [css-select](https://www.npmjs.com/package/css-select) (for HTML parsing)\n* [express](https://www.npmjs.com/package/express)\n* [express-ws](https://www.npmjs.com/package/express-ws)\n* [htmlparser2](https://www.npmjs.com/package/htmlparser2) (for HTML parsing)\n* [joi](https://www.npmjs.com/package/joi) (for JSON schema validation)\n* [lodash](https://www.npmjs.com/package/lodash)\n* [mocha](https://www.npmjs.com/package/mocha) (for unit tests)\n* [node-bittrex-api](https://www.npmjs.com/package/node-bittrex-api)\n* [poloniex-api-node](https://www.npmjs.com/package/poloniex-api-node)\n* [retry](https://www.npmjs.com/package/retry) (for custom retry strategies upon network failure)\n* [request](https://www.npmjs.com/package/request)\n* [sqlite3](https://www.npmjs.com/package/sqlite3) (for data storage)\n* [uuid](https://www.npmjs.com/package/uuid)\n* [winston](https://www.npmjs.com/package/winston) (for logging)\n* [ws](https://www.npmjs.com/package/ws)\n* [yargs](https://www.npmjs.com/package/yargs) (for CLI commands)\n\n## Donate\n\nThis project is a work in progress. If you find it useful, you might consider a little donation ;)\n\nBTC: `163Bu8qMSDoHc1sCatcnyZcpm38Z6PWf6E`\n\nETH: `0xDEBBEEB9624449D7f2c87497F21722b1731D42a8`\n\nNEO/GAS: `NXbbNQ2wSuavGRRffxFQrKLvSysEewzSHZ`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faloysius-pgast%2Fcrypto-exchanges-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faloysius-pgast%2Fcrypto-exchanges-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faloysius-pgast%2Fcrypto-exchanges-gateway/lists"}