Bybit JavaScript SDK example: rest-v5-custom-url.ts

Bybit REST V5 custom url JavaScript example for the Siebly Bybit SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

We use environment variables in our examples for API keys. It is your responsibility to manage and secure your keys appropriately.

examples/Bybit/Rest/rest-v5-custom-url.ts

What this example covers

  • Bybit REST API JavaScript example.
  • Uses the Siebly Bybit SDK package bybit-api instead of hand-written HTTP request plumbing.
  • Source path: Bybit/Rest/rest-v5-custom-url.ts.
  • Imports SDK symbols including RestClientV5.
  • Calls SDK methods such as getServerTime().

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.
import { RestClientV5 } from 'bybit-api'; /** * The first parameter of the REST client allows you to pass any configuration parameters supported by the SDK. * * These include API keys, if you wish to use private endpoints, but also expose other features such as * setting a custom base URL (e.g. for Turkish users). * * Refer to the API documentation for a complete list of domains: https://bybit-exchange.github.io/docs/v5/guide#authentication */const client = new RestClientV5({  /**   * You can pass a completely custom base URL,   * e.g. if you're trying to use a domain that hasn't been added yet (please let us know)   */  // baseUrl: 'https://api5.bybit.com',  //  //  /**   *   * There are also predefined API regions, which you can easily use with the "apiRegion" property:   *   */  //  //  // default: routes to api.bybit.com  // apiRegion: 'default',  //  //  // bytick: routes to api.bytick.com  // apiRegion: 'bytick',  //  //  // NL: routes to api.bybit.nl (for Netherland users)  // apiRegion: 'NL',  //  //  // HK: routes to api.byhkbit.com (for Hong Kong users)  // apiRegion: 'HK',  //  //  // TK: routes to api.bybit-tr.com (for Turkey users)  // apiRegion: 'TK',}); (async () => {  try {    const time1 = await client.getServerTime();     console.log('time res: ', { time1 });  } catch (e) {    console.error('request failed: ', e);  }})(); 

Subscribe on Substack

Complete the Substack form below to join our newsletter. Substack handles all subscriber data directly.