okx-os-api
v1.2.6
Published
okx-os-api
Readme
OKX OS API
Features
- [x] Wallet API
- [x] DEX API
- [x] Marketplace API
Install
npm install okx-os-api
# or
yarn add okx-os-apiQuick start
import createOkxOsApi, {
defineModule,
defineEndpoint,
defaultApiConfig,
} from 'okx-os-api'
const api = createOkxOsApi({
apiKey: 'your-api-key',
secretKey: 'your-secret-key',
passphrase: 'your-passphrase',
project: 'your-project-id',
})
// call built-in endpoints
const prices = await api.wallet.token_price.current_price([
{ chainIndex: '1', tokenAddress: '0x...' },
])
// extend with custom endpoint via config
const custom = api.extend(
defineModule({
endpoints: {
server_time: defineEndpoint<void, { now: string }>({
method: 'GET',
path: '/api/v5/public/time',
}),
},
})
)
const time = await custom.server_time()Config-driven APIs
- All APIs are defined in
src/apiConfig.ts. Add/override endpoints by composing modules withdefineModule/defineEndpoint. - Type exports live under
src/types/(wallet, marketplace, dex) for tree-shaken imports.
Notes
- Requests are signed per OKX OS spec;
createOkxOsApiaccepts an optionalapiConfigif you want to swap the entire API tree. - Build with
npm run build. The CLI may time out in some environments despite successful emits; rerun locally if you need a zero exit code.
Contributing
See CONTRIBUTING.md and Code of Conduct.
