# Tiger API

## 🯩 What is Tiger API

Tiger API is a **local WebSocket server** embedded in the **Tiger.com Windows** terminal that allows **external systems (e.g., screeners)** to control the interface of the terminal.

### 🔗 Main Purpose

The `setLinkSymbol` command instantly **opens the specified symbol** (e.g., `BTCUSDT`) in the specified **link group** (e.g., `A`) inside the terminal.

## ⚙️ How to Enable Tiger API in the Terminal

1. Go to: `Settings → Local Signal Server`
2. Enable the option: `Enable Signal Server`
3. Press `Save`
4. Default WebSocket port: `7819`

## 📡 WebSocket Request Format

```
{
  "type": "setLinkSymbol",
  "e": "BINANCE",         // Exchange
  "m": "SPOT",            // Market type: SPOT or FUTURES
  "symbol": "BTCUSDT",    // Trading pair
  "linkGroup": "A"        // Link group: A–11
}
```

* All fields are **required**
* Case-insensitive
* Response normalizes values (e.g., `Spot`, `Futures`)

## ✅ Example of a Successful Response

```
{
  "title": "Successful request",
  "message": "Symbol linked successfully.",
  "request": {
    "e": "BINANCE",
    "m": "Spot",
    "symbol": "BTCUSDT",
    "linkGroup": "A",
    "type": "SetLinkSymbol"
  },
  "response": {
    "type": "successfully",
    "timestamp": "..."
  }
}
```

## ❌ Error Examples

### 1. Invalid Command Type

```
{
  "type": "InvalidType"
}
```

Result: error + connection is closed (`code: 400`, WebSocket `1007`)

### 2. Invalid JSON Format

```
{
  "type": "setLinkSymbol", e: "BINANCE"... // broken syntax
}
```

Result: error + `connection_close`

### 3. Validation Errors (do not close WS connection)

* Empty fields
* Unknown `symbol`
* Invalid `linkGroup` (e.g., `AX`)

## 🟢 Ping/Pong Support

### 1. Text-based:

```
ping → pong
```

### 2. JSON-based:

```
{
  "type": "ping", 
  "title": "...", 
  "message": "..."
}
→
{
  "title": "Pong", 
  "message": "Response 'pong' to 'ping'."
}
```

## 📘 Reference Tables

### Exchanges (`e`):

* BINANCE, BINANCE-FUT, BYBIT, OKX, MEXC, BITMEX, Bitfinex, Gate.io, Bitget, TigerX

### Market Types (`m`):

* SPOT, FUTURES

### Link Groups (`linkGroup`):

* Letters `A–Z` (e.g., A = `#FFF9C4`)
* Digits `0–11` (e.g., 0 = `#FFAA00`)

## 📌 Error Handling Table

| Error Type        | Code | Action           |
| ----------------- | ---- | ---------------- |
| Invalid JSON      | 400  | WS closed (1007) |
| Validation errors | 400  | WS remains open  |

## 📌 Request examples

```
socket.send('{"type": "setLinkSymbol", "e": "TigerX Binance", "m": "SPOT", "symbol": "BTCUSDT", "linkGroup": "A"}');
//socket.send('{"type": "setLinkSymbol", "e": "TigerX OKX", "m": "FUTURES", "symbol": "BTCUSDT", "linkGroup": "A"}');
//socket.send('{"type": "setLinkSymbol", "e": "Bitget", "m": "FUTURES", "symbol": "PARTIUSDT", "linkGroup": "A"}');
//socket.send('{"type": "setLinkSymbol", "e": "MOEX", "m": "FUTURES", "symbol": "CR", "linkGroup": "A"}');
//socket.send('{"type": "setLinkSymbol", "e": "MOEX", "m": "FUTURES", "symbol": "CRZ5", "linkGroup": "A"}');
```

## 📌 Recommendations for Clients

* **Always validate JSON locally before sending**
* **On parsing errors → reconnect using exponential backoff**
* **Send regular `ping` messages to keep the connection alive**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.tiger.com/english/development-for-tiger.trade-windows/tiger-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
