> ## Documentation Index
> Fetch the complete documentation index at: https://whitebit-mintlify-fix-broken-links-1774829655.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# API Reference

> WhiteBIT REST API overview — base URL, authentication, quickstart examples, rate limits, and links to all endpoint groups.

export const RegionBaseUrl = ({className = "", showBaseUrl = true}) => {
  const [region, setRegionState] = useState(() => {
    if (typeof window !== 'undefined') {
      return localStorage.getItem("api-region-preference") || "com";
    }
    return "com";
  });
  const [mounted, setMounted] = useState(false);
  const observerRef = useRef(null);
  const isSyncingRef = useRef(false);
  const updateAllContentOnPage = targetRegion => {
    try {
      const domainFrom = targetRegion === "eu" ? "whitebit.com" : "whitebit.eu";
      const domainTo = targetRegion === "eu" ? "whitebit.eu" : "whitebit.com";
      const links = document.querySelectorAll('a');
      links.forEach(link => {
        let href = link.getAttribute('href');
        if (href && href.includes(domainFrom)) {
          link.setAttribute('href', href.replace(domainFrom, domainTo));
        }
      });
      const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, {
        acceptNode: node => {
          if (node.parentElement?.closest('.region-toggle-component')) {
            return NodeFilter.FILTER_REJECT;
          }
          return node.textContent.includes(domainFrom) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
        }
      });
      let currentNode;
      while (currentNode = walker.nextNode()) {
        currentNode.textContent = currentNode.textContent.replace(new RegExp(domainFrom, 'g'), domainTo);
      }
      console.log(`[RegionSync] Global content updated to ${domainTo}`);
    } catch (e) {
      console.error("[RegionSync] Error updating content:", e);
    }
  };
  const updateRegion = (newRegion, source) => {
    if (region === newRegion) return;
    console.log(`[RegionBaseUrl] Updating to "${newRegion}" (Source: ${source})`);
    if (source === 'observer') {
      isSyncingRef.current = true;
      setTimeout(() => isSyncingRef.current = false, 1000);
    }
    setRegionState(newRegion);
    localStorage.setItem("api-region-preference", newRegion);
    updateAllContentOnPage(newRegion);
    if (source === 'user-click') {
      window.dispatchEvent(new CustomEvent("regionChange", {
        detail: newRegion
      }));
      attemptToUpdateNativeDropdown(newRegion, 0);
      setTimeout(() => attemptToUpdateNativeDropdown(newRegion, 1), 500);
      setTimeout(() => attemptToUpdateNativeDropdown(newRegion, 2), 1500);
    }
  };
  const attemptToUpdateNativeDropdown = (targetRegion, attempt) => {
    if (isSyncingRef.current) return;
    try {
      const targetUrl = targetRegion === "eu" ? "https://whitebit.eu" : "https://whitebit.com";
      const targetDesc = targetRegion === "eu" ? "EU Server" : "Production Server";
      const selects = document.querySelectorAll('select');
      for (const select of selects) {
        if (select.innerHTML.includes('whitebit.com') || select.innerHTML.includes('whitebit.eu')) {
          select.value = targetUrl;
          select.dispatchEvent(new Event('change', {
            bubbles: true
          }));
          return;
        }
      }
      const buttons = Array.from(document.querySelectorAll('button, [role="combobox"]'));
      const serverSelector = buttons.find(btn => {
        if (btn.closest('a') || btn.closest('[class*="card"]') || btn.closest('nav')) {
          return false;
        }
        const txt = btn.textContent || "";
        const isServerDropdown = (txt.includes('Production Server') || txt.includes('EU Server') || txt.includes('WhiteBIT Global Server') || txt.includes('WhiteBIT EU Server')) && !txt.includes('Run') && !txt.includes('Send') || btn.getAttribute('role') === 'combobox';
        return isServerDropdown;
      });
      if (serverSelector) {
        const currentText = serverSelector.textContent || "";
        if (currentText.includes(targetDesc)) return;
        serverSelector.click();
        setTimeout(() => {
          const options = document.querySelectorAll('[role="option"], li, button');
          for (const opt of options) {
            const optText = opt.textContent || "";
            if (optText.includes(targetDesc) || optText.includes(targetUrl)) {
              opt.click();
              return;
            }
          }
        }, 100);
      }
    } catch (e) {
      console.error("[Sync] Error:", e);
    }
  };
  useEffect(() => {
    setMounted(true);
    updateAllContentOnPage(region);
    const handleStorageChange = e => {
      if (e.key === "api-region-preference" && e.newValue) {
        updateRegion(e.newValue, 'storage');
      }
    };
    const handleRegionChange = e => {
      if (e.detail !== region) {
        updateRegion(e.detail, 'event');
      }
    };
    window.addEventListener("storage", handleStorageChange);
    window.addEventListener("regionChange", handleRegionChange);
    observerRef.current = new MutationObserver(mutations => {
      if (isSyncingRef.current) return;
      updateAllContentOnPage(region);
      for (const mutation of mutations) {
        if (mutation.type !== 'childList' && mutation.type !== 'characterData') continue;
        const target = mutation.target;
        const el = target.nodeType === Node.TEXT_NODE ? target.parentElement : target;
        if (el && (el.getAttribute('role') === 'option' || el.closest('[role="listbox"]'))) continue;
        const text = target.textContent || "";
        if (text.includes('WhiteBIT EU Server') || text.includes('https://whitebit.eu') && text.includes('Server')) {
          if (el && el.tagName !== 'A' && !el.closest('.region-toggle-component')) {
            if (region !== 'eu') updateRegion('eu', 'observer');
          }
        } else if (text.includes('WhiteBIT Global Server') || text.includes('https://whitebit.com') && text.includes('Server')) {
          if (el && el.tagName !== 'A' && !el.closest('.region-toggle-component')) {
            if (region !== 'com') updateRegion('com', 'observer');
          }
        }
      }
    });
    observerRef.current.observe(document.body, {
      childList: true,
      subtree: true,
      characterData: true
    });
    if (typeof window !== 'undefined') {
      const current = localStorage.getItem("api-region-preference");
      if (current) attemptToUpdateNativeDropdown(current, 'init');
    }
    return () => {
      window.removeEventListener("storage", handleStorageChange);
      window.removeEventListener("regionChange", handleRegionChange);
      if (observerRef.current) observerRef.current.disconnect();
    };
  }, [region]);
  const apiBaseUrl = region === "eu" ? "https://whitebit.eu" : "https://whitebit.com";
  if (!mounted) return null;
  return <div className={`flex items-center gap-2 flex-wrap my-4 region-toggle-component ${className}`}>
            <span className="text-sm text-gray-500 dark:text-gray-400 font-mono">
                Base URL
            </span>
            <span className="text-sm text-gray-400">(</span>
            <div className="inline-flex bg-gray-100 dark:bg-gray-800 rounded-lg p-0.5 border border-gray-200 dark:border-gray-700">
                <button onClick={() => updateRegion("com", "user-click")} className={`px-2 py-0.5 text-xs font-medium rounded-md transition-all ${region === "com" ? "bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm" : "text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`}>
                    .com
                </button>
                <button onClick={() => updateRegion("eu", "user-click")} className={`px-2 py-0.5 text-xs font-medium rounded-md transition-all ${region === "eu" ? "bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm" : "text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`}>
                    .eu
                </button>
            </div>
            <span className="text-sm text-gray-400">)</span>
            {showBaseUrl && <>
                    <span className="text-sm text-gray-400">:</span>
                    <a href={apiBaseUrl} target="_blank" rel="noopener noreferrer" className="text-sm font-mono text-primary dark:text-primary-light hover:underline">
                        {apiBaseUrl}
                    </a>
                </>}
        </div>;
};

<RegionBaseUrl />

## Base URL

All REST API endpoints are available at:

```text theme={null}
https://whitebit.com/api/v4/{endpoint}
```

* **Public endpoints** use the `GET` method and accept parameters as query strings.
* **Private endpoints** use the `POST` method and accept parameters as JSON in the request body.
* All endpoints return time in Unix-time format and respond with JSON.

***

## Quickstart

### Prerequisites

* A WhiteBIT account ([Sign up](https://whitebit.com/auth))
* An API key with appropriate permissions ([API Settings](https://whitebit.com/settings/api))
* A programming language or HTTP client (cURL, Python, JavaScript, or similar)

### Step 1: First public API call

The [Server Status](/api-reference/market-data/server-status) endpoint returns the API life-state. No authentication is required.

**Request:**

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X GET "https://whitebit.com/api/v4/public/ping"
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    response = requests.get("https://whitebit.com/api/v4/public/ping")
    print(response.json())
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch("https://whitebit.com/api/v4/public/ping");
    const data = await response.json();
    console.log(data);
    ```
  </Tab>
</Tabs>

**Expected response:**

```json theme={null}
["pong"]
```

A response of `["pong"]` confirms the API is operational.

### Step 2: Authentication setup

Private endpoints require HMAC-SHA512 signed requests. See the [Authentication](/api-reference/authentication) guide for the full signing process.

WhiteBIT provides the [API Quick Start Helper](https://github.com/whitebit-exchange/api-quickstart) with examples in Python, PHP, Node.js, Go, JavaScript, Kotlin, .NET, Ruby, C++, and Rust.

**Required headers for private endpoints:**

| Header            | Value                               |
| ----------------- | ----------------------------------- |
| `Content-type`    | `application/json`                  |
| `X-TXC-APIKEY`    | The public API key                  |
| `X-TXC-PAYLOAD`   | Base64-encoded request body         |
| `X-TXC-SIGNATURE` | HMAC-SHA512 signature (hex encoded) |

### Step 3: First authenticated API call

The [Main Balance](/api-reference/account-wallet/main-balance) endpoint retrieves the main account balance. The request body must include `request` (the endpoint path) and `nonce` (unique identifier).

**Request body:**

```json theme={null}
{
  "request": "/api/v4/main-account/balance",
  "nonce": "1594297865000"
}
```

**Example with cURL** (replace `YOUR_API_KEY` and `YOUR_SIGNATURE` with the signed payload):

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://whitebit.com/api/v4/main-account/balance" \
      -H "Content-type: application/json" \
      -H "X-TXC-APIKEY: YOUR_API_KEY" \
      -H "X-TXC-PAYLOAD: BASE64_ENCODED_PAYLOAD" \
      -H "X-TXC-SIGNATURE: YOUR_SIGNATURE" \
      -d '{"request":"/api/v4/main-account/balance","nonce":"1594297865000"}'
    ```
  </Tab>

  <Tab title="Python (with helper)">
    ```python theme={null}
    # Use the API Quick Start Helper: https://github.com/whitebit-exchange/api-quickstart
    from whitebit import Whitebit

    wb = Whitebit(api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET")
    balance = wb.main_account_balance()
    print(balance)
    ```
  </Tab>
</Tabs>

**Expected response:**

```json theme={null}
{
  "BTC": { "main_balance": "0" },
  "USDT": { "main_balance": "100.50" }
}
```

The response contains balance data for each asset. Omitted assets have a zero balance.

***

## Rate Limits

| Scope                  | Limit                                     |
| ---------------------- | ----------------------------------------- |
| Public REST endpoints  | 2000 requests / 10 sec                    |
| Private REST endpoints | Varies per endpoint (see individual docs) |

For complete rate limits, error codes, and best practices, see [Rate Limits & Error Codes](/api-reference/rate-limits).

## Error Format

All V4 endpoints return errors as JSON. The format differs slightly between public and private APIs:

**Public endpoints:**

```json theme={null}
{
  "success": false,
  "message": "ERROR MESSAGE",
  "params": []
}
```

**Private endpoints:**

```json theme={null}
{
  "code": 0,
  "message": "MESSAGE",
  "errors": {
    "PARAM1": ["MESSAGE"],
    "PARAM2": ["MESSAGE"]
  }
}
```

***

## Endpoint Groups

<CardGroup cols={2}>
  <Card title="Market Data" icon="chart-bar" href="/api-reference/market-data/overview">
    Public market info, orderbook, trades, fees, server status, and more. No authentication required.
  </Card>

  <Card title="Spot Trading" icon="arrow-right-arrow-left" href="/api-reference/spot-trading/overview">
    Place and manage spot orders, query execution history, and control kill-switch timers.
  </Card>

  <Card title="Collateral Trading" icon="scale-balanced" href="/api-reference/collateral-trading/overview">
    Manage collateral positions, leverage, hedge mode, and collateral order types (limit, market, OCO, OTO).
  </Card>

  <Card title="Convert" icon="rotate" href="/api-reference/convert/convert-estimate">
    Estimate, confirm, and review currency conversion operations.
  </Card>

  <Card title="Account & Wallet" icon="wallet" href="/api-reference/account-wallet/overview">
    Main balance, deposits, withdrawals, transfers, codes, crypto lending, and fees.
  </Card>

  <Card title="Mining Pool" icon="pickaxe" href="/api-reference/mining-pool/pool-overview">
    Monitor mining operations, manage payouts, track worker performance, and create watcher links.
  </Card>

  <Card title="Sub-Accounts" icon="users" href="/api-reference/sub-accounts/overview">
    Create and manage sub-accounts, balances, transfers, and API keys.
  </Card>

  <Card title="OAuth" icon="key" href="/api-reference/oauth/usage/oauth">
    Third-party authorization: token exchange, refresh, and account endpoints.
  </Card>
</CardGroup>

## What's next

* [Authentication](/api-reference/authentication) — Full signing process and common errors
* [Rate Limits & Error Codes](/api-reference/rate-limits) — Per-endpoint limits, error formats, and troubleshooting
* [Market Data](/api-reference/market-data/overview) — Public endpoints for orderbook, trades, and market info
* [Spot Trading](/api-reference/spot-trading/overview) — Place and manage orders
* [WebSocket API](/websocket/overview) — Real-time market data and account streams
* [API Quick Start Helper](https://github.com/whitebit-exchange/api-quickstart) — Multi-language SDK for authentication and requests
