OKX TypeScript SDK example: rest-public.ts

OKX REST REST public example for the Siebly OKX SDK, with TypeScript source for exchange REST API and WebSocket integration, setup, and production SDK docs.

What This Example Covers

  • OKX REST API example in TypeScript.
  • Uses the Siebly OKX SDK package okx-api instead of hand-written HTTP request plumbing.
  • Source path: OKX/Rest/rest-public.ts.
  • Example category: REST.
  • Imports SDK symbols including RestClient.
  • Calls SDK methods such as getInstruments().

How To Use This Example

  • Start here for the specific request or stream pattern, then check the matching SDK guide for install, credentials, and operational notes.
  • Open the repository source when you need the latest committed version: GitHub source file.

Example Path

OKX/Rest/rest-public.ts

Source Link

Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/OKX/Rest/rest-public.ts

Related SDK Docs

Example Source

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);
  }
})();