# Interactive Brokers API GET /portfolio/{accountId}/positions/{pageId}

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/brokers/ibkr/endpoints/portfolio-positions, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

All positions in an account, one page at a time, with size, market price, market value and unrealised profit and loss.

- Request: `GET /portfolio/{accountId}/positions/{pageId}`
- Version: v1
- Group: Accounts
- Status: verified. Source: [interactivebrokers.com](https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-paginated-positions), checked 2026-09-18.
- Official reference: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-paginated-positions

Note: IBKR's reference also has an uncached positions endpoint and a call to invalidate the positions cache.

## Parameters

- `accountId` (in path, type string, required): Your IBKR account ID. The code reads it from the IBKR_ACCOUNT_ID environment variable. Never type it into this site.
- `pageId` (in path, type integer, required): Page number of the results.
- `sort` (in query, type string, optional): Field to sort by. Listed on IBKR's page without a description.
- `direction` (in query, type string, optional): Sort direction. Listed on IBKR's page without a description.
- `waitForSecDef` (in query, type boolean, optional): Listed on IBKR's page without a description.

### Authentication headers

- `Authorization` (type string, optional): OAuth only; the Gateway sends none. On the OAuth host this is the SSO bearer token IBKR's reference lists for this call. With the Client Portal Gateway on your own computer the browser login holds the session. Placeholder only.

## Request

Written from the method, path and parameters recorded on this page. No demo host is recorded as a plain address for this API, so the samples read the base address from an environment variable. Not executed against a live or demo account. Credentials are read from environment variables on your own machine and are never entered on this site. The request builder at https://openbrokerapi.com/tools/request-builder writes these same snippets, from the same record.

### Python

```python
# Set IBKR_BASE_URL, IBKR_ACCOUNT_ID as environment variables first. Never paste real values into code.
# No demo host is recorded as a plain address for this API, so the base address is read from IBKR_BASE_URL.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: headers Authorization; query parameters sort, direction, waitForSecDef.
import os
import requests

BASE_URL = os.environ["IBKR_BASE_URL"]
headers = {}
resp = requests.get(BASE_URL + "/portfolio/" + os.environ["IBKR_ACCOUNT_ID"] + "/positions/{pageId}", headers=headers, timeout=10)
resp.raise_for_status()
print(resp.json())
```

### JavaScript

```javascript
// Set IBKR_BASE_URL, IBKR_ACCOUNT_ID as environment variables first. Never paste real values into code.
// No demo host is recorded as a plain address for this API, so the base address is read from IBKR_BASE_URL.
// Replace each {placeholder}, "..." and 0 with a real value before running.
// Optional and not shown: headers Authorization; query parameters sort, direction, waitForSecDef.
// Run as a module, for example a .mjs file, on a Node version that has fetch built in.
const BASE_URL = process.env.IBKR_BASE_URL;
const res = await fetch(BASE_URL + "/portfolio/" + process.env.IBKR_ACCOUNT_ID + "/positions/{pageId}", {
  method: "GET",
  headers: {
  },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(await res.json());
```

### curl

```bash
# Set IBKR_BASE_URL, IBKR_ACCOUNT_ID as environment variables first. Never paste real values into code.
# No demo host is recorded as a plain address for this API, so the base address is read from IBKR_BASE_URL.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: headers Authorization; query parameters sort, direction, waitForSecDef.
curl -X GET "$IBKR_BASE_URL/portfolio/$IBKR_ACCOUNT_ID/positions/{pageId}"
```

## Response

A mock response. The values are invented, so check field names against the [official reference](https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-paginated-positions).

```json
[
  {
    "_mock": true,
    "acctId": "MOCK-ACCOUNT-001",
    "conid": 265598,
    "ticker": "AAPL",
    "assetClass": "STK",
    "currency": "USD",
    "position": 10,
    "mktPrice": 190,
    "mktValue": 1900,
    "unrealizedPnl": 50
  }
]
```

## Response schema, HTTP 200

Every field this site's OpenAPI file for Interactive Brokers (https://openbrokerapi.com/specs/ibkr.json) declares for this response.

- `acctId` (string): Not recorded
- `conid` (integer): Not recorded
- `ticker` (string): Not recorded
- `assetClass` (string): Not recorded
- `currency` (string): Not recorded
- `position` (number): Not recorded
- `mktPrice` (number): Not recorded
- `mktValue` (number): Not recorded
- `unrealizedPnl` (number): Not recorded

Status: unverified. No source opened. This schema is not sourced to a page of the provider's own that we opened, so check field names against the official reference.

## Limits that apply at Interactive Brokers

- Global requests a second (Web API): 10 requests per second
  - Scope: Per authenticated username, that is per Web API session
  - Status: verified. Source: [ibkrcampus.com](https://www.ibkrcampus.com/campus/ibkr-api-page/webapi-doc/), checked 2026-10-12.
  - Corroborated by [interactivebrokers.com/docs/web-api/trading/usage-and-availability/pacing-limitations](https://www.interactivebrokers.com/docs/web-api/trading/usage-and-availability/pacing-limitations)
  - Note: Client Portal Web API. Some endpoints carry their own lower limit, held in separate records. A breach returns HTTP 429, and both IBKR pages read on 12 Oct 2026 give a penalty box of 10 minutes for a violating IP address.
- Historical market data requests: Either 10 req/s or 50 req/minute, as the page words it
  - Scope: GET /iserver/marketdata/history only
  - Status: verified. Source: [interactivebrokers.com](https://www.interactivebrokers.com/docs/web-api/trading/usage-and-availability/pacing-limitations), checked 2026-10-12.
  - Corroborated by [ibkrcampus.com/campus/ibkr-api-page/webapi-doc/](https://www.ibkrcampus.com/campus/ibkr-api-page/webapi-doc/)
  - Note: The page gives two figures joined by or and does not say which applies when, so no single number is recorded. The IBKR Campus page also lists 5 concurrent requests for this endpoint.
- Market data snapshot requests a second: 10 requests per second
  - Scope: GET /iserver/marketdata/snapshot only
  - Status: verified. Source: [interactivebrokers.com](https://www.interactivebrokers.com/docs/web-api/trading/usage-and-availability/pacing-limitations), checked 2026-10-12.
  - Corroborated by [ibkrcampus.com/campus/ibkr-api-page/webapi-doc/](https://www.ibkrcampus.com/campus/ibkr-api-page/webapi-doc/)
- Order and trade list requests: 1 req/5 s
  - Scope: GET /iserver/orders and GET /iserver/trades, each counted on its own
  - Status: verified. Source: [interactivebrokers.com](https://www.interactivebrokers.com/docs/web-api/trading/usage-and-availability/pacing-limitations), checked 2026-10-12.
  - Corroborated by [ibkrcampus.com/campus/ibkr-api-page/webapi-doc/](https://www.ibkrcampus.com/campus/ibkr-api-page/webapi-doc/)
  - Note: The same figure applies to /iserver/account/pnl/partitioned, /portfolio/accounts and /portfolio/subaccounts. The window is 5 seconds, which a single unit cannot state, so the figure stays as wording.
- Session validation requests a minute: 1 requests per minute
  - Scope: GET /sso/validate only
  - Status: verified. Source: [interactivebrokers.com](https://www.interactivebrokers.com/docs/web-api/trading/usage-and-availability/pacing-limitations), checked 2026-10-12.
  - Corroborated by [ibkrcampus.com/campus/ibkr-api-page/webapi-doc/](https://www.ibkrcampus.com/campus/ibkr-api-page/webapi-doc/)
- Session keep alive requests a second: 1 requests per second
  - Scope: GET /tickle only
  - Status: verified. Source: [interactivebrokers.com](https://www.interactivebrokers.com/docs/web-api/trading/usage-and-availability/pacing-limitations), checked 2026-10-12.
  - Corroborated by [ibkrcampus.com/campus/ibkr-api-page/webapi-doc/](https://www.ibkrcampus.com/campus/ibkr-api-page/webapi-doc/)

## More on the Interactive Brokers API

- [All Interactive Brokers API endpoints](https://openbrokerapi.com/brokers/ibkr/endpoints): 23 documented, grouped by what they do.
- [Interactive Brokers API quickstart](https://openbrokerapi.com/brokers/ibkr/quickstart)
- [All Interactive Brokers API error codes](https://openbrokerapi.com/errors/ibkr)
- [Interactive Brokers API page](https://openbrokerapi.com/brokers/ibkr): The full record: access, authentication, limits and the source for each.
- [Interactive Brokers API as an OpenAPI file](https://openbrokerapi.com/specs/ibkr.json): Generated from these endpoint records. Independent and unofficial.

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: Interactive Brokers API GET /portfolio/{accountId}/positions/{pageId}. Broker API Hub, https://openbrokerapi.com/brokers/ibkr/endpoints/portfolio-positions, newest check 2026-09-18.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
