# bitkub-client

> A client wrapper class for calling the Bitkub APIs

Latest version **3.0.0** (published 2026-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install bitkub-client
pnpm add bitkub-client
yarn add bitkub-client
bun add bitkub-client
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-10-13 |
| First published | 2022-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 36.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Akkapon Somjai |
| Maintainers | xsodus |
| Keywords | bitkub, API, client, crypto, exchange |

## Links

- npm: https://www.npmjs.com/package/bitkub-client
- Repository: https://github.com/xsodus/bitkub-client
- Homepage: https://github.com/xsodus/bitkub-client#readme
- Issues: https://github.com/xsodus/bitkub-client/issues
- npm.io page: https://npm.io/package/bitkub-client

## Dependencies (4)

- [axios](https://npm.io/package/axios.md) ^1.20.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.22.5
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.22.5

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-10-13
- 2.0.4 — 2026-10-12
- 2.0.3 — 2025-12-30
- 2.0.2 — 2025-12-30
- 2.0.1 — 2025-12-30
- 2.0.0 — 2025-12-30
- 1.4.3 — 2024-01-14
- 1.4.2 — 2024-01-14
- 1.4.1 — 2024-01-14
- 1.4.0 — 2024-01-14
- 1.3.1 — 2024-01-02
- 1.3.0 — 2024-01-02
- 1.2.2 — 2023-05-03
- 1.2.1 — 2023-05-03
- 1.2.0 — 2023-05-02
- … 22 more at https://npm.io/package/bitkub-client/versions

## README

# bitkub-client

`bitkub-client` is a TypeScript wrapper for selected [Bitkub API v3](https://github.com/bitkub/bitkub-official-api-docs/blob/master/rest-v3.md) and [v4](https://github.com/bitkub/bitkub-official-api-docs/blob/master/rest-v4.md) endpoints. It handles API request signing for authenticated methods and returns Axios responses.

## Install

```bash
npm install bitkub-client
# or
yarn add bitkub-client
```

## Quick start

Create an API key and secret in your [Bitkub account](https://www.bitkub.com/publicapi). Keep the secret private; load credentials from environment variables or another secrets manager instead of committing them to source control.

```typescript
import BitkubClient, { BitkubEnvironment } from "bitkub-client";

const client = new BitkubClient(
  process.env.BITKUB_API_KEY!,
  process.env.BITKUB_API_SECRET!,
  BitkubEnvironment.TEST
);

async function main() {
  const time = await client.getServerTime();
  console.log("Server time:", time.data);

  const symbols = await client.getSymbols();
  console.log("Symbols:", symbols.data.result);

  const balances = await client.getBalances();
  console.log("Balances:", balances.data.data);

  const assets = await client.getWalletAssets();
  console.log("Assets:", assets.data.data);
}

main().catch(console.error);
```

The constructor defaults to `BitkubEnvironment.TEST`. In this environment, `placeBid` and `placeAsk` call Bitkub's test-order endpoints. Set `BitkubEnvironment.PRODUCTION` to send those orders to the live endpoints. Check the environment before placing a live order.

```typescript
const client = new BitkubClient(
  process.env.BITKUB_API_KEY!,
  process.env.BITKUB_API_SECRET!,
  BitkubEnvironment.PRODUCTION
);
```

## Available methods

| Method | Purpose |
| --- | --- |
| `getServerTime()` | Get Bitkub server time. |
| `getSymbols()` | List market symbols. |
| `getBalances(params?)` | Get funding wallet balances from v4. Amounts are decimal strings in `response.data.data`. |
| `getWalletAssets(params?)` | Get funding wallet assets from v4. |
| `getBids(symbol, limit?)` | Get bids for a market; limit defaults to `1`. |
| `getAsks(symbol, limit?)` | Get asks for a market; limit defaults to `1`. |
| `placeBid(symbol, amount, rate, orderType?, clientId?)` | Place a buy order. Order type defaults to `BitkubOrderType.MARKET`. |
| `placeAsk(symbol, amount, rate, orderType?, clientId?)` | Place a sell order. Order type defaults to `BitkubOrderType.MARKET`. |
| `cancelOrder(hash, symbol?, orderId?, orderSide?)` | Cancel by order hash, or provide `null` for the hash and identify the order with symbol, ID, and side. |

Methods return an Axios response. The Bitkub response body is in `.data`; for example, `const { data } = await client.getSymbols()`.

### Place and cancel orders

```typescript
import { BitkubOrderType } from "bitkub-client";

// On the TEST environment this uses Bitkub's test-order endpoint.
const order = await client.placeBid(
  "BTC_THB",
  1, // amount
  500000, // rate
  BitkubOrderType.LIMIT
);

// Cancel using the order hash returned by Bitkub.
const cancellation = await client.cancelOrder(order.data.result.hash);

```

You can also cancel with `cancelOrder(null, symbol, orderId, orderSide)` when you do not have the order hash. The side is `"buy"` or `"sell"`.

`placeAsk` takes the same arguments as `placeBid`. Review Bitkub's API documentation for symbol formats, order requirements, and response fields.

## Signing other API requests

For a secured API v3 or v4 endpoint that this package does not wrap, use `buildRequestHeaders()` to create the API key, timestamp, and signature headers. Pass the path relative to `/api`; for GET requests, include the query string in that path or pass query parameters as the third argument. Send the request using the same method, path, and payload you signed.

```typescript
import axios from "axios";

const path = "/v3/market/cancel-order";
const payload = { hash: "ORDER_HASH" };
const headers = await client.buildRequestHeaders("POST", path, payload);

const response = await axios.post(
  `https://api.bitkub.com/api${path}`,
  payload,
  { headers }
);
```

`buildRequestHeaders()` calls Bitkub's v3 server-time endpoint to create the timestamp used in the signature. Market data, orders, and server time use v3; wallet balances and assets use v4. See the [v3](https://github.com/bitkub/bitkub-official-api-docs/blob/master/rest-v3.md) and [v4](https://github.com/bitkub/bitkub-official-api-docs/blob/master/rest-v4.md) documentation for endpoint requirements.

## API key version

This package uses endpoint-specific Bitkub API versions. API keys need the permissions required by the endpoints you call. If you are upgrading from an API key created for version 1.x or 2.x, create a new API key in Bitkub before using this client.

## Documentation

See the [bitkub-client API documentation](https://xsodus-bitkub-client.netlify.app) for TypeScript types and further details.

## Contributing

Install dependencies and run the integration tests:

```bash
yarn install
yarn test
```

Tests use `nock` to mock Bitkub API requests. Add or update mocks in `src/BitkubClient.test.ts` so tests do not depend on live requests or change account data. Pull requests are welcome.

---
_Source: https://npm.io/package/bitkub-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
