Node.js connector for the OKX APIs and WebSockets:
- Complete integration with all OKX APIs.
- WebSocket support coming soon.
- TypeScript support (with type declarations for most API requests & responses).
- Over 100 end-to-end tests making real API calls
& WebSocket connections, validating any changes before they reach npm. - Coming soon: robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
- Browser support (via webpack bundle - see "Browser Usage" below).
- REST APIs are fully integrated with end to end test coverage
- WebSocket support is coming soon.
npm install --save okx-api
- Issues? Check the issues tab.
- Discuss & collaborate with other node devs? Join our Node.js Algo Traders engineering community on telegram.
- Try my connectors:
- Try my misc utilities:
- Check out my examples:
Most methods accept JS objects. These can be populated using parameters specified by okx's API documentation, or check the type definition in the rest-client class methods.
This project uses typescript. Resources are stored in 3 key structures:
- src - the whole connector written in typescript
- lib - the javascript version of the project (compiled from typescript). This should not be edited directly, as it will be overwritten with each release. This is also the version published to npm.
- dist - the packed bundle of the project for use in browser environments (manual, using webpack).
- examples - some implementation examples & demonstrations. Contributions are welcome!
Create API credentials at okx
- If your IDE doesn't have IntelliSense, check the rest-client.ts for a list of methods, params & return types.
- Requests follow the same ordering and format as the categories in the API docs.
- Responses are parsed automatically for less nesting. Error responses are thrown in full:
- If the response looks successful (HTTP 200 and "code" in the response body === "0"), only the
dataproperty is directly (without thecode,data&msgproperties). - If the response looks like an error (HTTP error OR the "code" property in the response does not equal "0"), the full response is thrown (including
codeandmsgproperties). See the interface for APIResponse.
- If the response looks successful (HTTP 200 and "code" in the response body === "0"), only the
Build a bundle using webpack:
npm installnpm buildnpm pack
The bundle can be found in dist/. Altough usage should be largely consistent, smaller differences will exist. Documentation is still TODO.
Support my efforts to make algo trading accessible to all - register with my referral links:
Or buy me a coffee using any of these:
- BTC:
1C6GWZL1XW3jrjpPTS863XtZiXL1aTK7Jk - ETH (ERC20):
0xd773d8e6a50758e1ada699bb6c4f98bb4abf82da
Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.
