Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/bitget-api/llms.txt

Use this file to discover all available pages before exploring further.

The bitget-api SDK ships with two approaches for running in browser environments. Modern TypeScript projects can use direct ESM imports with crypto polyfills configured via tsconfig.json path aliases, while projects that need a classic <script> tag can use the included webpack configuration to build a self-contained UMD bundle. Both approaches give full access to the REST and WebSocket APIs from the browser.

Approach 1: Modern ESM Imports

This is the recommended approach for TypeScript projects and modern bundlers (Vite, esbuild, Angular, etc.). You map Node.js built-in modules to their browser-compatible polyfill equivalents using TypeScript’s paths compiler option.
1

Install browser polyfills

Install the browser-compatible versions of Node.js built-in modules that bitget-api depends on:
npm install crypto-browserify stream-browserify
2

Configure tsconfig.json paths

Add paths entries to your tsconfig.json to redirect crypto and stream imports to their browser polyfills:
{
  "compilerOptions": {
    "paths": {
      "crypto": [
        "./node_modules/crypto-browserify"
      ],
      "stream": [
        "./node_modules/stream-browserify"
      ]
    }
  }
}
3

Declare the global shim

In the global context of your application — for example, in a polyfills.ts file (Angular) or your top-level entry point — add:
(window as any).global = window;
This shim makes the global variable available, which some Node.js-style modules expect to find in the global scope.

Approach 2: Webpack Bundle

This is the classic approach for serving the SDK as a minified JavaScript file loaded via a <script> tag on any webpage. The repository ships a ready-made webpack.config.cjs that produces a UMD bundle.
1

Install dependencies

npm install
2

Build the project

Compile the TypeScript source to CommonJS before bundling:
npm run build
3

Pack the bundle

Run webpack to produce the minified browser bundle:
npm run pack
The output file bitgetapi.js (plus a source map) is written to the dist/ directory. Reference it with a standard script tag:
<script src="dist/bitgetapi.js"></script>
The webpack configuration targets UMD output and excludes the Node.js-only http and https modules via resolve.fallback, so the bundle works in browsers without those native modules:
// webpack/webpack.config.cjs (excerpt)
resolve: {
  fallback: {
    "http": false,
    "https": false,
  }
}

The webpack bundle and the ESM import approach should have largely consistent API surface, but small differences may exist. In particular, Node.js-only features such as the https.Agent keep-alive option (keepAlive: true) are silently skipped in browser environments because the https module is excluded from the bundle.
Never embed your Bitget API keys, secrets, or passphrases in browser-side code. Anyone who visits your page can read JavaScript loaded in the browser. For authenticated requests, proxy them through a secure backend server that holds your credentials.

Build docs developers (and LLMs) love