---
name: iborrowdesk
description: Fetch Interactive Brokers stock-loan data (borrow fee, rebate, shares available to short) from the IBorrowDesk v2 API, as daily OHLC back to 2015 or 15-minute readings. Use when asked about the cost to borrow or short a stock, short availability, hard-to-borrow names, borrow-fee history, or squeeze-style analysis, for US and international tickers.
---

# IBorrowDesk v2 API

IBorrowDesk records the borrow fee, rebate and shares available that
Interactive Brokers publishes for tens of thousands of securities in 17
countries. The v2 API serves that history as JSON behind an API key. It is
**paid**: every data call draws *units* from the account holder's plan, so
plan the pull and price it before running it.

## Setup

The key comes from the account holder's developer console,
<https://www.iborrowdesk.com/developer?utm_source=agent-skill&utm_medium=agent>, which needs the API plan. Read it
from the environment. Never ask for it in chat, echo it or write it to a file:

```bash
export IBORROWDESK_API_KEY=ibd_...      # set by the user
```

Use `https://www.iborrowdesk.com` only. The bare `iborrowdesk.com` host
doesn't serve the API. Two calls are free and spend nothing:

```bash
# The live limits. No key needed. Read these rather than hardcoding them.
curl -sS https://www.iborrowdesk.com/api/v2/coverage
# Confirms the key. Units left are the sum of `remaining` across `buckets`.
curl -sS https://www.iborrowdesk.com/api/v2/usage \
  -H "Authorization: Bearer $IBORROWDESK_API_KEY"
```

## Choosing a series

| Question | Use | Cost |
|---|---|---|
| Fee/availability over months or years, trend, "has it ever been this expensive" | `daily`: one OHLC bar per trading day, back to 2015 | 1 unit per symbol per 365 days of history returned |
| What happened today or this week, intraday spikes, the fee at a given time | `intraday`: 15-minute readings, from mid-July 2026 (`coverage.earliest_available`) | 1 unit per symbol **per call** that returns data |

- `daily` with no `start` is **all-time**, about 12 units per long-listed
  symbol. If the question only needs the last year, pass `start` and pay
  1 unit.
- `intraday` serves at most `max_span_days` (31) per call. A 90-day pull is
  three calls, so up to three units per symbol. With no `start` you get the
  trailing week.
- Symbols with no data cost nothing: unknown tickers, holidays, gaps.

## Workflow

1. **Plan the calls** against `/coverage`. At most `max_symbols` (100) per
   call. Intraday windows of at most `max_span_days`. A daily call's worst
   case must fit `daily_max_units_per_request` (150), or the API answers 400:
   all-time daily is at most 12 symbols a call.
2. **Price the worst case** before spending anything. The API charges at most:
   - daily: symbols × ⌈days / `unit_days`⌉, with `days` counted from `start`
     (or `daily_earliest_available` when `start` is omitted) to `end`,
     inclusive;
   - intraday: symbols × number of windows.

   If the total is above 100 units, or above what `/usage` says is left, tell
   the user the estimate and the units remaining, and wait for their OK.
3. **Fetch to a file**, one call per planned chunk, and read it with code
   (`jq`, Python). Don't paste the rows into the conversation:
   ```bash
   curl -sS https://www.iborrowdesk.com/api/v2/daily/borrow \
     -H "Authorization: Bearer $IBORROWDESK_API_KEY" \
     -G -d symbols=GME,AMC -d start=2025-01-01 -o borrow.json
   curl -sS https://www.iborrowdesk.com/api/v2/intraday/borrow \
     -H "Authorization: Bearer $IBORROWDESK_API_KEY" \
     -G -d symbols=TSLA -d start=2026-10-01 -d end=2026-10-20 -o tsla.json
   ```
4. **Report** the sum of `meta.units_billed` when you tell the user what you
   fetched, and any `meta.unresolved` symbols.

## Reading the data

- **`fee`** is the annualised borrow rate in percent (`5.38` = 5.38%/yr).
  **`rebate`** is the annualised rate paid on short-sale proceeds, in
  `currency`, and goes negative when the fee is above the benchmark rate.
  **`available`** is the share count IB has to lend. It is capped in the feed
  (10,000,000 for the largest US names), so a flat ceiling means "plenty", not
  a measured quantity.
- **Tickers.** US tickers are plain (`GME`). Everything else takes a venue
  suffix: `.GR` Germany, `.LN` UK, `.CA` Canada, `.JP` Japan, `.HK` Hong Kong,
  `.AU` Australia, `.SW` Switzerland, `.NA` Netherlands, `.FP` France, `.IM`
  Italy, `.SM` Spain, `.SS` Sweden, `.BB` Belgium, `.AV` Austria, `.MM` Mexico,
  `.IN` India. A symbol that doesn't resolve lands in `meta.unresolved` and
  doesn't fail the call. Tell the user rather than guessing another ticker.
- **Identity.** A series follows the security, not the ticker, so it runs
  straight through a rename. `previous_identities` lists the earlier symbols
  and names (META was FB until 2022-06-09). Join datasets on `figi`, not on
  the symbol or name.
- **Daily `date`** is the local trading date. `open` is the first in-session
  reading, not the opening print. Older non-US rows were keyed on the US
  Eastern date (see REFERENCE.md). `high`/`low` are null on early backfilled
  rows.
- **Short series.** `meta.earliest_available` is where our data starts. A
  series that begins there doesn't mean the stock wasn't borrowable earlier.
  Intraday requests that start before the floor are moved forward onto it.

## Errors

Every error is JSON `{"error", "message"}`. Branch on `error`:

| `error` | Meaning | What to do |
|---|---|---|
| `invalid_request` (400) | `details` lists every bad parameter | Fix all of them, then retry once |
| `invalid_api_key` (401) | Missing, wrong or revoked key | Ask the user to check `IBORROWDESK_API_KEY` |
| `units_exhausted` (402) | Worst case exceeds the units left. Nothing was charged | Narrow the pull, or tell the user to buy a unit pack in the console |
| `no_api_access` (403) | The account has no API plan | Tell the user it needs the API plan ($29/month at <https://www.iborrowdesk.com/plans?utm_source=agent-skill&utm_medium=agent>) |
| `rate_limited` (429) | 60/min, 2,000/hour, 20,000/day per key | Back off and retry, honouring `Retry-After` if present |
| `server_error` (5xx) | Transient | Retry with backoff, a few times at most |

## Without a key

The v2 API is the only supported programmatic access. The site's own JSON
endpoints are an internal interface for the web app. They block scripted
clients and have no stable contract, so don't scrape them. If the user has no
key, say so and point them to <https://www.iborrowdesk.com/developer?utm_source=agent-skill&utm_medium=agent>.

For field-level detail see `REFERENCE.md`. The OpenAPI 3 spec is at
<https://www.iborrowdesk.com/api/v2/openapi.json>.
