list of machine-readable crypto exchange OpenAPI AsyncAPI documents and code generators.
Important
generated code is now ready at exchange-collection-rust
Many trading strategies require cross exchange data and execution. There are trading libraries that provides abstraction across exchanges.
library / framework | multi-exchange | primary language | wrapper language |
---|---|---|---|
ccxt | yes | js | python, php, csharp |
hummingbot | yes | python, cpp | n/a |
openlimits | yes | rust | python, js, go |
barter-rs | yes | rust | n/a |
kelp | yes | go | n/a |
These libraries are each good in their way but does not solve the below 4 points at once.
- integration effort: N crypto exchanges, L programming languages, its a better when effort is N + L rather than N * L
- document consistecy and code maintenance: exchanges freqently update API. Without proper pipeline and versioning, code and API inconsistency is common
- opinionated framework: battery-included cross-exchange libraries has complex design, and often fail to meet the actual needs in low latency
- multi-language support: people use python for strategy proof of concept and rust for production.
by gathering OpenAPI / AsyncAPI docuements, we can build a CI pipeline that generate and test versioned clients for different languages solving the above issues.
- gather both OpenAPI / AsyncAPI YAML per exchange
- develop codegen CI for generating REST/WS clients
- deploy CI for generating REST/WS clients
- implement trading traits per generated model
- I have set up trading traits in guilder for generated codes
- or you can still use the this repo for the OpenAPI / AsyncAPI
location | feature |
---|---|
asset | OpenAPI and AsyncAPI YAML |
codegen | code generator script written in rust |
index.html | OpenAPI / AsyncAPI viewer, hosted here |
this repo includes a CI which generates rust client and pushes to exchange-collection-rust
specs | guidelines |
---|---|
OpenAPI format | {exchange}_rest_openapi.yaml , v3.X.Y, convert swagger to OpenAPI here |
AsyncAPI format | {exchange}_ws_asyncapi.yaml , YAML, v3.0.X, codegen topology natively supports V3 now |
codegen | written in Rust |
official codegen output support | rust python (codegen coming soon) |
unofficial support | typescript csharp golang java dart kotlin php cplusplus scala |
below are the list of exchanges planned for integration. Please contact Sho if you want to request exchanges for integration.
Exchange API | KYC | REST (OpenAPI) | WS (AsyncAPI) |
---|---|---|---|
ccxtrest | / | done | / |
hyperliquid | no | done | done |
mexc | no | done | done |
bitwyre | yes | done | done |
bitget | yes | done | done |
binance | yes | done | done |
coinbase | yes | done | done |
coincheck (JP) | yes | done | done |
hashkey (HK) | yes | done | done |
okx | yes | done | done |
krakenfutures | yes | done | done |
gateio | yes | WIP | WIP |
dydx | no | postponed | / |
polkadex | no | postponed | / |
zkex | no | postponed | / |
gmx | no | postponed | / |
coinex | no | WIP | WIP |
bybit | yes | planned | planned |
kucoin | yes | planned | planned |
htx | yes | planned | planned |
bitbank (JP) | yes | postponed | postponed |
bitflyer (JP) | yes | postponed | postponed |
korbit (KR) | yes | postponed | postponed |
bitkub (TH) | yes | postponed | postponed |
- I currently have no plan of supporting FIX protocol due to limited number of supported exchanges. Once the project reaches certain maturity it will be implemented.
- For AMM DEX like Uniswap, I will add support if there is a proper demand. My suggestion is to make use of JSON-RPC clients like ether-rs to connect RPC providers like infura and alchemy.
Document | Language | framework | CI status | code issues |
---|---|---|---|---|
OpenAPI | rust | reqwest | integrated | generated code cannot differentiate fields like "m" and "M" |
AsyncAPI | rust | tokio-tungstenite | integrated | does not parse variables in URL/channel name like "price_{base}_{quote}" |
AsyncAPI | rust | async-tungstenite | planned | / |
OpenAPI | python | reqwest | planned | / |
AsyncAPI | rust | tokio-tungstenite | planned | / |
you can use these commands to generate code manually as well
install OpenAPI CLI
npm install -g @openapitools/openapi-generator-cli
install AsyncAPI CLI
npm install -g @asyncapi/cli
language | input | command |
---|---|---|
rust | openapi (REST, reqwest) | openapi-generator-cli generate -i {YAML} -g rust -o {OUTPUT_DIR} --additional-properties=library=reqwest |
rust | asyncapi (WS, tokio-tungstenite) | asyncapi generate fromTemplate {YAML} asyncapi-rust-ws-template -p exchange={EXCHANGE} |
python | openapi (REST, asyncio) | openapi-generator-cli generate -i {YAML} -g python -o {OUTPUT_DIR} --additional-properties=asyncio=true |
python | asyncapi (WS, asyncio-websockets) | wip |
- gather assets
- gather 3 sets of API docs initial assets
- gather 10 exchanges to validate the idea
- gather 100 exchanges to have a competitive trading library
- set up CI for codegen model
- set up guilder trading library
- define market data traits
- define order placement traits
- define ledger traits
- implement traits on top of the codegen model
- package models with opinionated trait per language
- the
ag
command seems to be deprecated and cannot generate code properly, useasyncapi generate
instead - you can install
asyncapi-preview
extension on vs code for preview - comnunity AsyncAPI templates like
python-sanic-template
are not working properly
I keep this project opensource so that everyone can take part of it. If you have any OpenAPI / AsyncAPI document for a crypto exchange, you are more than welcome to add with a pull request, or I am willing to purchase at reasonable cost as well.
Please contact Sho for partnerships.
I am gathering API doc with @pakTech786 would be great if more people can help with it.
I have set up a repo to develop AsyncAPI template for Rust WS in React. I want a version for python/go as well. I am not a TS expert, so I would love to have an expert to accelarate development.
- exchange-collection-rust - rust client generated from exchange-collection
- guilder - Unopinionated Cross-Exchange Crypto Trading Library
- asyncapi-rust-ws-template - AsyncAPI Template for Generating Rust WebSocket Client
- kucoin-arbitrage - KuCoin Cyclic Arbitrage, in Tokio Rust (legacy)
- typed-websocket - rust typed websocket client