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.
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!
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 data property is directly (without the code, data & msg properties).
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 code and msg properties). See the interface for APIResponse.
Websocket Client
This connector includes a high-performance node.js & typescript websocket client for the OKX public & private websockets.
If your IDE doesn't have IntelliSense, check the websocket-client.ts for a list of methods, params & return types.
When subscribing to channels, only the "args" should be passed as an object or array when calling the websocket client subcribe() function: API docs.
TypeScript recommended (but it is not required) for a richer experience:
The ws client will automatically open connections as needed when subscribing to a channel.
If the connection is lost for any reason, the ws client will detect this (via the connection heartbeats). It will then:
Automatically teardown the dead connection.
Automatically respawn a fresh connection.
Automatically reauthenticate, if using private channels.
Automatically resubscribe to previously subscribed topics.
Resume producing events as before, without extra handling needed in your logic.
The ws client will automatically authenticate if accounts are provided and a private channel is subscribed to.
Up to 100 accounts are supported on the private connection, as per the API docs. Authentication is automatic if accounts are provided.
For examples in using the websocket client, check the examples in the repo:
Complete & robust Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests
The npm package okx-api receives a total of 790 weekly downloads. As such, okx-api popularity was classified as not popular.
We found that okx-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 0 open source maintainers collaborating on the project.
Package last updated on 30 Sep 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
A malicious Maven package typosquatting a popular library is secretly stealing OAuth credentials on the 15th of each month, putting Java developers at risk.
Socket and Seal Security collaborate to fix a critical npm overrides bug, resolving a three-year security issue in the JavaScript ecosystem's most popular package manager.
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.