OKX REST public JavaScript example. Read the source code, review its SDK calls, and browse related exchange integration examples.
This example uses okx-api, the JavaScript and TypeScript SDK for OKX. Install it with npm install okx-api.
We use environment variables in our examples for API keys. It is your responsibility to manage and secure your keys appropriately.
okx-api instead of hand-written HTTP request plumbing.OKX/Rest/rest-public.ts.RestClient.getInstruments().import { RestClient } from 'okx-api'; const client = new RestClient(); /** * This is a simple script wrapped in a immediately invoked function expression, designed to make public API calls without credentials */(async () => { try { const results = await client.getInstruments({ instType: 'SPOT' }); console.log( 'result: ', results.filter((row) => row.baseCcy === 'SUI'), ); return; } catch (e) { console.error('request failed: ', e); }})(); We use essential cookies and optional analytics. Read the Privacy Policy.
Essential cookies stay on. Toggle analytics if you want to share anonymous usage insights. You can revisit this anytime via Cookie Settings in the footer.