# Crypto Long/Short + Open Interest API - Binance/OKX/Bitget (`gochujang/long-short-oi-aggregator`) Actor

Aggregate perpetual open interest (USD) and long/short ratios across Binance, OKX, and Bitget. Spot crowded positioning, liquidation candidates, and trader skew.

- **URL**: https://apify.com/gochujang/long-short-oi-aggregator.md
- **Developed by:** [Hojun Lee](https://apify.com/gochujang) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Crypto Long/Short + Open Interest Aggregator

> Aggregate perpetual **open interest (USD)** and **long/short ratios** across **Binance, OKX, and Bitget**. Spot crowded positioning, liquidation candidates, and trader skew. No API key required.

---

### What It Does

Pulls per-symbol perpetual futures positioning data from three venues and computes aggregate signals:

- **Total OI in USD** across all enabled venues + per-venue breakdown
- **3 different long/short ratios**: Binance top-trader-by-position, Binance global-account, OKX top-trader-account
- **Average L/S** + skew label: `EXTREME_LONG / LONG_SKEWED / NEUTRAL / SHORT_SKEWED / EXTREME_SHORT`
- Configurable L/S period (5m, 15m, 1h, 4h, 1d)

---

### Why This Matters

Open interest tells you **how much money is in the trade**; long/short ratio tells you **which side is crowded**. Together they predict where liquidation cascades start:

- **Large OI + EXTREME_LONG** = primed for downside cascade (longs over-positioned)
- **Large OI + EXTREME_SHORT** = primed for short squeeze
- **OI dropping while price rises** = shorts capitulating (continuation signal)
- **OI rising into resistance** = both sides loading up (volatility coming)

This is the same data Coinglass charges $20-50/month for, served as a clean API for your bot or dashboard.

---

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `symbols` | string[] | `[]` | Base symbols. Empty = bundled top-50 majors seed list |
| `includeBinance` | boolean | `true` | OI + 2 L/S ratios from Binance USDT-M |
| `includeOkx` | boolean | `true` | OI + top-trader L/S from OKX SWAP |
| `includeBitget` | boolean | `true` | OI from Bitget USDT-FUTURES (USD-converted via mark) |
| `lsPeriod` | string | `1h` | Binance L/S window: `5m`, `15m`, `30m`, `1h`, `2h`, `4h`, `1d` |
| `sortBy` | string | `oi_desc` | `oi_desc`, `ls_long_extreme_desc`, `ls_short_extreme_desc`, `symbol_asc` |
| `alertLsThreshold` | number | `0` | Telegram alert when avg L/S crosses this (e.g. `3` = heavy long crowd) |
| `telegramBotToken` | string (secret) | — | Bot token for alerts |
| `telegramChatId` | string | — | Chat ID for alerts |

#### Example: Track BTC/ETH crowdedness, alert on extreme long-skew
```json
{
  "symbols": ["BTC", "ETH", "SOL"],
  "lsPeriod": "1h",
  "alertLsThreshold": 3,
  "telegramBotToken": "<token>",
  "telegramChatId": "<chat>"
}
````

#### Example: Find biggest OI altcoins right now

```json
{
  "sortBy": "oi_desc",
  "lsPeriod": "1h"
}
```

***

### Output

```json
{
  "symbol": "BTC",
  "mark_price": 68763,
  "total_oi_usd": 12450000000,
  "binance_oi_usd": 7557329774,
  "okx_oi_usd": 2617294488,
  "bitget_oi_usd": 2403000000,
  "venues_with_oi": 3,
  "binance_top_trader_ls": 1.4455,
  "binance_global_account_ls": 2.1027,
  "okx_ls": 2.0,
  "avg_ls_ratio": 1.8494,
  "ls_metrics_count": 3,
  "skew_label": "LONG_SKEWED",
  "timestamp": "2026-06-02T14:00:00+00:00"
}
```

***

### Pricing

Pay-Per-Event (PPE):

- **$0.002 per symbol returned**

Examples:

- Top 50 symbols: **$0.10**
- 10 majors per minute (1440 runs/day): **$2.88/day**

***

### Use Cases

**Liquidation hunter** — Find symbols with large OI + extreme L/S skew (cascade primed):

```bash
curl -X POST "https://api.apify.com/v2/acts/gochujang~long-short-oi-aggregator/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"sortBy": "ls_long_extreme_desc"}'
```

**Squeeze radar** — Alert when any major flips to EXTREME\_SHORT (capitulation buy signal):

```json
{
  "symbols": ["BTC", "ETH", "SOL", "HYPE"],
  "alertLsThreshold": 0.4,
  "telegramBotToken": "<token>",
  "telegramChatId": "<chat>"
}
```

***

### Data Sources

- **Binance**: `/fapi/v1/openInterest` + `/futures/data/topLongShortPositionRatio` + `/futures/data/globalLongShortAccountRatio`
- **OKX**: `/api/v5/public/open-interest` + `/api/v5/rubik/stat/contracts/long-short-account-ratio`
- **Bitget**: `/api/v2/mix/market/open-interest`

All public, no auth. Note: Binance may be geo-blocked from some cloud IPs — if that happens, OKX + Bitget continue to provide coverage.

***

### Related Actors

- **[CEX Funding Rate Aggregator](https://apify.com/gochujang/cex-funding-aggregator)** — Funding rates across 5 venues with OI + L/S overlay.
- **[Hyperliquid Whale Tracker](https://apify.com/gochujang/hyperliquid-whale-tracker)** — Specific trader positions to complement aggregate OI.
- **[Smart Money Wallet Tracker](https://apify.com/gochujang/smart-money-tracker)** — Spot-market whale activity.

***

### Feedback

If this Actor saves you time, a quick review helps others find it: [Leave a review on Apify Store](https://apify.com/gochujang/long-short-oi-aggregator#reviews)

# Actor input Schema

## `symbols` (type: `array`):

Base symbols (e.g. BTC, ETH, SOL). Empty = use bundled top-50 majors seed list.

## `includeBinance` (type: `boolean`):

Include Binance OI + top-trader-position L/S + global-account L/S.

## `includeOkx` (type: `boolean`):

Include OKX SWAP OI + top-trader account ratio.

## `includeBitget` (type: `boolean`):

Include Bitget USDT-FUTURES OI (in tokens, converted to USD via mark price).

## `includeOiChange24h` (type: `boolean`):

Add okx\_oi\_24h\_change\_pct field — sign of position buildup (+) vs unwind (-). Adds one extra OKX call per symbol.

## `lsPeriod` (type: `string`):

Time window for Binance L/S ratios.

## `sortBy` (type: `string`):

Sort order for results.

## `alertLsThreshold` (type: `number`):

Alert when any symbol's average L/S ratio crosses this (e.g. >3 = heavy long crowd, <0.5 = heavy short crowd). 0 = disabled.

## `telegramBotToken` (type: `string`):

Telegram bot token for alerts. Leave empty to disable.

## `telegramChatId` (type: `string`):

Chat ID to receive alerts.

## Actor input object example

```json
{
  "symbols": [
    "BTC",
    "ETH",
    "SOL",
    "DOGE",
    "XRP",
    "HYPE"
  ],
  "includeBinance": true,
  "includeOkx": true,
  "includeBitget": true,
  "includeOiChange24h": true,
  "lsPeriod": "1h",
  "sortBy": "oi_desc",
  "alertLsThreshold": 0,
  "telegramChatId": ""
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "symbols": [
        "BTC",
        "ETH",
        "SOL",
        "DOGE",
        "XRP",
        "HYPE"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gochujang/long-short-oi-aggregator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "symbols": [
        "BTC",
        "ETH",
        "SOL",
        "DOGE",
        "XRP",
        "HYPE",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("gochujang/long-short-oi-aggregator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "symbols": [
    "BTC",
    "ETH",
    "SOL",
    "DOGE",
    "XRP",
    "HYPE"
  ]
}' |
apify call gochujang/long-short-oi-aggregator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=gochujang/long-short-oi-aggregator",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Crypto Long/Short + Open Interest API - Binance/OKX/Bitget",
        "description": "Aggregate perpetual open interest (USD) and long/short ratios across Binance, OKX, and Bitget. Spot crowded positioning, liquidation candidates, and trader skew.",
        "version": "0.1",
        "x-build-id": "3fCi7ROkL9W0uiMmz"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/gochujang~long-short-oi-aggregator/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-gochujang-long-short-oi-aggregator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/gochujang~long-short-oi-aggregator/runs": {
            "post": {
                "operationId": "runs-sync-gochujang-long-short-oi-aggregator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/gochujang~long-short-oi-aggregator/run-sync": {
            "post": {
                "operationId": "run-sync-gochujang-long-short-oi-aggregator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "symbols": {
                        "title": "Symbols",
                        "type": "array",
                        "description": "Base symbols (e.g. BTC, ETH, SOL). Empty = use bundled top-50 majors seed list.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "includeBinance": {
                        "title": "Include Binance",
                        "type": "boolean",
                        "description": "Include Binance OI + top-trader-position L/S + global-account L/S.",
                        "default": true
                    },
                    "includeOkx": {
                        "title": "Include OKX",
                        "type": "boolean",
                        "description": "Include OKX SWAP OI + top-trader account ratio.",
                        "default": true
                    },
                    "includeBitget": {
                        "title": "Include Bitget",
                        "type": "boolean",
                        "description": "Include Bitget USDT-FUTURES OI (in tokens, converted to USD via mark price).",
                        "default": true
                    },
                    "includeOiChange24h": {
                        "title": "Include 24h OI Change %",
                        "type": "boolean",
                        "description": "Add okx_oi_24h_change_pct field — sign of position buildup (+) vs unwind (-). Adds one extra OKX call per symbol.",
                        "default": true
                    },
                    "lsPeriod": {
                        "title": "Long/Short Period",
                        "enum": [
                            "5m",
                            "15m",
                            "30m",
                            "1h",
                            "2h",
                            "4h",
                            "1d"
                        ],
                        "type": "string",
                        "description": "Time window for Binance L/S ratios.",
                        "default": "1h"
                    },
                    "sortBy": {
                        "title": "Sort By",
                        "enum": [
                            "oi_desc",
                            "ls_long_extreme_desc",
                            "ls_short_extreme_desc",
                            "symbol_asc"
                        ],
                        "type": "string",
                        "description": "Sort order for results.",
                        "default": "oi_desc"
                    },
                    "alertLsThreshold": {
                        "title": "Telegram Alert L/S Threshold",
                        "minimum": 0,
                        "type": "number",
                        "description": "Alert when any symbol's average L/S ratio crosses this (e.g. >3 = heavy long crowd, <0.5 = heavy short crowd). 0 = disabled.",
                        "default": 0
                    },
                    "telegramBotToken": {
                        "title": "Telegram Bot Token",
                        "type": "string",
                        "description": "Telegram bot token for alerts. Leave empty to disable."
                    },
                    "telegramChatId": {
                        "title": "Telegram Chat ID",
                        "type": "string",
                        "description": "Chat ID to receive alerts.",
                        "default": ""
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
