Skip to main content

Constructor

Constructor options

RestClient accepts a single optional RestClientOptions object.
string
Your OKX API key. Required for authenticated endpoints.
string
Your OKX API secret. Required for authenticated endpoints.
string
Your OKX API passphrase. Required for authenticated endpoints.
string
default:"prod"
The API group to connect to. Accepted values:
  • 'prod' — OKX global (www.okx.com)
  • 'EEA' — European Economic Area (my.okx.com)
  • 'US' — United States (app.okx.com)
boolean
default:"false"
Set to true to use OKX demo trading. No real funds are used.
boolean
default:"false"
When true, throws an error if any request parameter is undefined.
string
Override the default API base URL (protocol + domain). Use market instead to target my.okx.com, app.okx.com, etc.
boolean
default:"true"
When true, the client attempts to post-process request exceptions for a cleaner error object.
boolean
Enable HTTP keep-alive for REST requests (via axios).
number
default:"1000"
Interval (ms) for TCP keep-alive packets. Only relevant when keepAlive is true.
(message: string, secret: string) => Promise<string>
Provide a custom HMAC signing function. Useful for using Node’s native crypto.createHmac for better performance. See the examples/ folder for a demonstration.

Custom / utility methods


Trading account


Order trading

Algo orders


Grid trading


Signal bots


Recurring buy


Copy trading


Market data


Public data


Trading data (Rubik)


Funding


Subaccounts


Block trading (RFQ)


Spread trading


Earn and finance

Staking / DeFi

Simple earn (savings)

Fixed loan lending

Flexible loan


Affiliate and system