# Send Trading212 API to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "trading212-api",
    "name": "Trading212 API",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/tsvetelin-kulinski/trading212-api",
    "canonicalUrl": "https://clawhub.ai/tsvetelin-kulinski/trading212-api",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/trading212-api",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=trading212-api",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "SKILL.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "trading212-api",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-10T04:53:40.865Z",
      "expiresAt": "2026-05-17T04:53:40.865Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=trading212-api",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=trading212-api",
        "contentDisposition": "attachment; filename=\"trading212-api-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "trading212-api"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/trading212-api"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/trading212-api",
    "downloadUrl": "https://openagent3.xyz/downloads/trading212-api",
    "agentUrl": "https://openagent3.xyz/skills/trading212-api/agent",
    "manifestUrl": "https://openagent3.xyz/skills/trading212-api/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/trading212-api/agent.md"
  }
}
```
## Documentation

### Trading 212 API

Note: The Trading 212 API is currently in beta and under active development. Some endpoints or behaviors may change.

### Environments

EnvironmentBase URLPurposeDemohttps://demo.trading212.com/api/v0Paper trading - test without real fundsLivehttps://live.trading212.com/api/v0Real money trading

### Order Quantity Convention

Positive quantity = BUY (e.g., 10 buys 10 shares)
Negative quantity = SELL (e.g., -10 sells 10 shares)

### Account Types

Only Invest and Stocks ISA accounts are supported.

### Instrument Identifiers

Trading 212 uses custom tickers as unique identifiers for instruments.
Always search for the Trading 212 ticker before making instrument requests.

### Authentication

HTTP Basic Auth with API Key (username) and API Secret (password).

### Check Existing Setup First

Before guiding the user through authentication setup, check if credentials are already configured:

Semantic rule: Credentials are configured when at least one complete set is present: a complete set is key + secret for the same account (e.g. T212_API_KEY + T212_API_SECRET, or T212_API_KEY_INVEST + T212_API_SECRET_INVEST, or T212_API_KEY_STOCKS_ISA + T212_API_SECRET_STOCKS_ISA). You do not need all four account-specific vars; having only the Invest pair or only the Stocks ISA pair is enough. Check for any combination that gives at least one usable key+secret pair.

# Example: configured if any complete credential set exists
if [ -n "$T212_AUTH_HEADER" ] && [ -n "$T212_BASE_URL" ]; then
  echo "Configured (derived vars)"
elif [ -n "$T212_API_KEY" ] && [ -n "$T212_API_SECRET" ]; then
  echo "Configured (single account)"
elif [ -n "$T212_API_KEY_INVEST" ] && [ -n "$T212_API_SECRET_INVEST" ]; then
  echo "Configured (Invest); Stocks ISA also if T212_API_KEY_STOCKS_ISA and T212_API_SECRET_STOCKS_ISA are set"
elif [ -n "$T212_API_KEY_STOCKS_ISA" ] && [ -n "$T212_API_SECRET_STOCKS_ISA" ]; then
  echo "Configured (Stocks ISA); Invest also if T212_API_KEY_INVEST and T212_API_SECRET_INVEST are set"
else
  echo "No complete credential set found"
fi

If any complete set is present, skip the full setup and proceed with API calls; when making requests, use the resolution order in "Making Requests" below (pick the pair that matches the user's account context when multiple sets exist). Do not ask the user to run derivation one-liners or merge keys into a header. Only guide users through the full setup process below when no complete credential set exists.

Important: Before making any API calls, always ask the user which environment they want to use: LIVE (real money) or DEMO (paper trading). Do not assume the environment.

### API Keys Are Environment-Specific

API keys are tied to a specific environment and cannot be used across environments.

API Key Created InWorks WithDoes NOT Work WithLIVE accountlive.trading212.comdemo.trading212.comDEMO accountdemo.trading212.comlive.trading212.com

If you get a 401 error, verify that:

You're using the correct API key for the target environment
The API key was generated in the same environment (LIVE or DEMO) you're trying to access

### Get Credentials

Decide which environment to use - LIVE (real money) or DEMO (paper trading)
Open Trading 212 app (mobile or web)
Switch to the correct account - Make sure you're in LIVE or DEMO mode matching your target environment
Navigate to Settings > API
Generate a new API key pair - you'll receive:

API Key (ID) (e.g., 35839398ZFVKUxpHzPiVsxKdOtZdaDJSrvyPF)
API Secret (e.g., 7MOzYJlVJgxoPjdZJCEH3fO9ee7A0NzLylFFD4-3tlo)


Store the credentials separately for each environment if you use both

### Building the Auth Header

Combine your API Key (ID) and Secret with a colon, base64 encode, and prefix with Basic  for the Authorization header.

Optional: To precompute the header from key/secret, you can set:

export T212_AUTH_HEADER="Basic $(echo -n "$T212_API_KEY:$T212_API_SECRET" | base64)"

Otherwise, the agent builds the header from T212_API_KEY and T212_API_SECRET when making requests.

Manual (placeholders):

# Format: T212_AUTH_HEADER = "Basic " + base64(API_KEY_ID:API_SECRET)
export T212_AUTH_HEADER="Basic $(echo -n "<YOUR_API_KEY_ID>:<YOUR_API_SECRET>" | base64)"

# Example with sample credentials:
export T212_AUTH_HEADER="Basic $(echo -n "35839398ZFVKUxpHzPiVsxKdOtZdaDJSrvyPF:7MOzYJlVJgxoPjdZJCEH3fO9ee7A0NzLylFFD4-3tlo" | base64)"

### Making Requests

When making API calls, use the first option that applies (semantically: pick the credential set that matches the user's account, or the only set present):

If T212_AUTH_HEADER and T212_BASE_URL are set: use them in requests.
Else if T212_API_KEY and T212_API_SECRET are set: use this pair (single account). Build header as Basic $(echo -n "$T212_API_KEY:$T212_API_SECRET" | base64) and base URL as https://${T212_ENV:-live}.trading212.com. Do not guide the user to derive or merge; you do it.
Else if both account-specific pairs are set (T212_API_KEY_INVEST/T212_API_SECRET_INVEST and T212_API_KEY_STOCKS_ISA/T212_API_SECRET_STOCKS_ISA): the user must clearly specify which account to target (Invest or Stocks ISA), unless they ask for information for all accounts. Use the Invest pair when the user refers to Invest, and the Stocks ISA pair when the user refers to ISA/Stocks ISA. If the user wants information for all accounts, make multiple API calls—one per account (Invest and Stocks ISA)—and present or aggregate the results for both. If it is not clear from context which account to use (and they did not ask for all accounts), ask for confirmation before making API calls (e.g. "Which account should I use — Invest or Stocks ISA?"). Do not assume. Build the header from the chosen key/secret and base URL as https://${T212_ENV:-live}.trading212.com.
Else if only the Invest pair is set (T212_API_KEY_INVEST and T212_API_SECRET_INVEST): use this pair for requests; if the user asks about Stocks ISA, only the Invest account is configured.
Else if only the Stocks ISA pair is set (T212_API_KEY_STOCKS_ISA and T212_API_SECRET_STOCKS_ISA): use this pair for requests; if the user asks about Invest, only the Stocks ISA account is configured.

Use the T212_AUTH_HEADER value in the Authorization header when it is set:

# When T212_AUTH_HEADER and T212_BASE_URL are set:
curl -H "Authorization: $T212_AUTH_HEADER" \\
  "${T212_BASE_URL}/api/v0/equity/account/summary"

When only primary vars are set, use the inline form in the curl:

# When only T212_API_KEY, T212_API_SECRET, T212_ENV are set:
curl -H "Authorization: Basic $(echo -n "$T212_API_KEY:$T212_API_SECRET" | base64)" \\
  "https://${T212_ENV:-live}.trading212.com/api/v0/equity/account/summary"

Warning: T212_AUTH_HEADER must be the full header value including the Basic  prefix.
# WRONG - raw base64 without "Basic " prefix
curl -H "Authorization: <base64-only>" ...  # This will NOT work!

# CORRECT - use T212_AUTH_HEADER (contains "Basic <base64>")
curl -H "Authorization: $T212_AUTH_HEADER" ...  # This works

### Environment Variables

Single account vs all accounts: API keys are for a single account. One key/secret pair (T212_API_KEY + T212_API_SECRET) = one account (Invest or Stocks ISA). To use all accounts (Invest and Stocks ISA), the user must set two sets of key/secret: T212_API_KEY_INVEST / T212_API_SECRET_INVEST and T212_API_KEY_STOCKS_ISA / T212_API_SECRET_STOCKS_ISA. When both pairs are set, the user must clearly specify which account to target; if it is not clear from context, ask for confirmation (Invest or Stocks ISA) before making API calls.

Primary (single account): Set these for consistent setup with the plugin README:

export T212_API_KEY="your-api-key"       # API Key (ID) from Trading 212
export T212_API_SECRET="your-api-secret"
export T212_ENV="demo"                   # or "live" (defaults to "live" if unset)

Account-specific (Invest and/or Stocks ISA): Set only the pair(s) you use. One complete set (key + secret for the same account) is enough. For example, only Invest:

export T212_API_KEY_INVEST="your-invest-api-key"
export T212_API_SECRET_INVEST="your-invest-api-secret"
export T212_ENV="demo"                   # or "live"

For both accounts, set both pairs:

export T212_API_KEY_INVEST="your-invest-api-key"
export T212_API_SECRET_INVEST="your-invest-api-secret"
export T212_API_KEY_STOCKS_ISA="your-stocks-isa-api-key"
export T212_API_SECRET_STOCKS_ISA="your-stocks-isa-api-secret"
export T212_ENV="demo"                   # or "live" (applies to both)

Optional – precomputed (for scripts or if the user prefers): The user can set the auth header and base URL from the primary vars, but they do not need to; when making API calls you (the agent) must build the header and base URL from primary vars if these are not set.

# Build auth header and base URL from T212_API_KEY, T212_API_SECRET, T212_ENV
export T212_AUTH_HEADER="Basic $(echo -n "$T212_API_KEY:$T212_API_SECRET" | base64)"
export T212_BASE_URL="https://${T212_ENV:-live}.trading212.com"

Alternative (manual): If you prefer not to store key/secret in env, set derived vars directly. Remember: API keys only work with their matching environment.

# For DEMO (paper trading)
export T212_AUTH_HEADER="Basic $(echo -n "<DEMO_API_KEY_ID>:<DEMO_API_SECRET>" | base64)"
export T212_BASE_URL="https://demo.trading212.com"

# For LIVE (real money) - generate separate credentials in LIVE account
# export T212_AUTH_HEADER="Basic $(echo -n "<LIVE_API_KEY_ID>:<LIVE_API_SECRET>" | base64)"
# export T212_BASE_URL="https://live.trading212.com"

Tip: If you use both environments, use separate variable names:

# Demo credentials
export T212_DEMO_AUTH_HEADER="Basic $(echo -n "<DEMO_KEY_ID>:<DEMO_SECRET>" | base64)"

# Live credentials
export T212_LIVE_AUTH_HEADER="Basic $(echo -n "<LIVE_KEY_ID>:<LIVE_SECRET>" | base64)"

### Common Auth Errors

CodeCauseSolution401Invalid credentialsCheck API key/secret, ensure no extra whitespace401Environment mismatchLIVE API keys don't work with DEMO and vice versa - verify key matches target environment403Missing permissionsCheck API permissions in Trading 212 settings408Request timed outRetry the request429Rate limit exceededWait for x-ratelimit-reset timestamp

### Get Account Summary

GET /api/v0/equity/account/summary (1 req/5s)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/account/summary"

Response Schema:

{
  "id": 12345678,
  "currency": "GBP",
  "totalValue": 15250.75,
  "cash": {
    "availableToTrade": 2500.5,
    "reservedForOrders": 150.0,
    "inPies": 500.0
  },
  "investments": {
    "currentValue": 12100.25,
    "totalCost": 10500.0,
    "realizedProfitLoss": 850.5,
    "unrealizedProfitLoss": 1600.25
  }
}

### Account Fields

FieldTypeDescriptionidintegerPrimary trading account numbercurrencystringPrimary account currency (ISO 4217)totalValuenumberTotal account value in primary currencycash.availableToTradenumberFunds available for investingcash.reservedForOrdersnumberCash reserved for pending orderscash.inPiesnumberUninvested cash inside piesinvestments.currentValuenumberCurrent value of all investmentsinvestments.totalCostnumberCost basis of current investmentsinvestments.realizedProfitLossnumberAll-time realized P&Linvestments.unrealizedProfitLossnumberPotential P&L if sold now

### Order Types

TypeEndpointAvailabilityDescriptionMarket/api/v0/equity/orders/marketDemo + LiveExecute immediately at best priceLimit/api/v0/equity/orders/limitDemo + LiveExecute at limit price or betterStop/api/v0/equity/orders/stopDemo + LiveMarket order when stop price reachedStopLimit/api/v0/equity/orders/stop_limitDemo + LiveLimit order when stop price reached

### Order Statuses

StatusDescriptionLOCALOrder created locally, not yet sentUNCONFIRMEDSent to exchange, awaiting confirmationCONFIRMEDConfirmed by exchangeNEWActive and awaiting executionCANCELLINGCancel request in progressCANCELLEDSuccessfully cancelledPARTIALLY_FILLEDSome shares executedFILLEDCompletely executedREJECTEDRejected by exchangeREPLACINGModification in progressREPLACEDSuccessfully modified

### Time Validity

ValueDescriptionDAYExpires at midnight in exchange timezoneGOOD_TILL_CANCELActive until filled or cancelled (default)

### Order Strategy

ValueDescriptionQUANTITYOrder by number of shares (API supported)VALUEOrder by monetary value (not supported via API)

### Initiated From

ValueDescriptionAPIPlaced via this APIIOSiOS appANDROIDAndroid appWEBWeb platformSYSTEMSystem-generatedAUTOINVESTAutoinvest feature

### Place Market Order

POST /api/v0/equity/orders/market (50 req/min)

# Buy 5 shares
curl -X POST -H "Authorization: $T212_AUTH_HEADER" \\
  -H "Content-Type: application/json" \\
  "$T212_BASE_URL/api/v0/equity/orders/market" \\
  -d '{"ticker": "AAPL_US_EQ", "quantity": 5}'

# Sell 3 shares (negative quantity)
curl -X POST -H "Authorization: $T212_AUTH_HEADER" \\
  -H "Content-Type: application/json" \\
  "$T212_BASE_URL/api/v0/equity/orders/market" \\
  -d '{"ticker": "AAPL_US_EQ", "quantity": -3}'

# Buy with extended hours enabled
curl -X POST -H "Authorization: $T212_AUTH_HEADER" \\
  -H "Content-Type: application/json" \\
  "$T212_BASE_URL/api/v0/equity/orders/market" \\
  -d '{"ticker": "AAPL_US_EQ", "quantity": 5, "extendedHours": true}'

Request Fields:

FieldTypeRequiredDescriptiontickerstringYesInstrument ticker (e.g., AAPL_US_EQ)quantitynumberYesPositive for buy, negative for sellextendedHoursbooleanNoSet true to allow execution in pre-market (4:00-9:30 ET) and after-hours (16:00-20:00 ET) sessions. Default: false

Response:

{
  "id": 123456789,
  "type": "MARKET",
  "ticker": "AAPL_US_EQ",
  "instrument": {
    "ticker": "AAPL_US_EQ",
    "name": "Apple Inc",
    "isin": "US0378331005",
    "currency": "USD"
  },
  "quantity": 5,
  "filledQuantity": 0,
  "status": "NEW",
  "side": "BUY",
  "strategy": "QUANTITY",
  "initiatedFrom": "API",
  "extendedHours": false,
  "createdAt": "2024-01-15T10:30:00Z"
}

### Place Limit Order

POST /api/v0/equity/orders/limit (1 req/2s)

curl -X POST -H "Authorization: $T212_AUTH_HEADER" \\
  -H "Content-Type: application/json" \\
  "$T212_BASE_URL/api/v0/equity/orders/limit" \\
  -d '{"ticker": "AAPL_US_EQ", "quantity": 5, "limitPrice": 150.00, "timeValidity": "DAY"}'

Request Fields:

FieldTypeRequiredDescriptiontickerstringYesInstrument tickerquantitynumberYesPositive for buy, negative for selllimitPricenumberYesMaximum price for buy, minimum for selltimeValiditystringNoDAY (default) or GOOD_TILL_CANCEL

### Place Stop Order

POST /api/v0/equity/orders/stop (1 req/2s)

curl -X POST -H "Authorization: $T212_AUTH_HEADER" \\
  -H "Content-Type: application/json" \\
  "$T212_BASE_URL/api/v0/equity/orders/stop" \\
  -d '{"ticker": "AAPL_US_EQ", "quantity": -5, "stopPrice": 140.00, "timeValidity": "GOOD_TILL_CANCEL"}'

Request Fields:

FieldTypeRequiredDescriptiontickerstringYesInstrument tickerquantitynumberYesPositive for buy, negative for sellstopPricenumberYesTrigger price (based on Last Traded Price)timeValiditystringNoDAY (default) or GOOD_TILL_CANCEL

### Place Stop-Limit Order

POST /api/v0/equity/orders/stop_limit (1 req/2s)

curl -X POST -H "Authorization: $T212_AUTH_HEADER" \\
  -H "Content-Type: application/json" \\
  "$T212_BASE_URL/api/v0/equity/orders/stop_limit" \\
  -d '{"ticker": "AAPL_US_EQ", "quantity": -5, "stopPrice": 145.00, "limitPrice": 140.00, "timeValidity": "DAY"}'

Request Fields:

FieldTypeRequiredDescriptiontickerstringYesInstrument tickerquantitynumberYesPositive for buy, negative for sellstopPricenumberYesTrigger price to activate limit orderlimitPricenumberYesLimit price for the resulting ordertimeValiditystringNoDAY (default) or GOOD_TILL_CANCEL

### Get Pending Orders

GET /api/v0/equity/orders (1 req/5s)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/orders"

Returns array of Order objects with status NEW, PARTIALLY_FILLED, etc.

### Get Order by ID

GET /api/v0/equity/orders/{id} (1 req/1s)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/orders/123456789"

### Cancel Order

DELETE /api/v0/equity/orders/{id} (50 req/min)

curl -X DELETE -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/orders/123456789"

Returns 200 OK if cancellation request accepted. Order may already be filled.

### Common Order Errors

ErrorCauseSolutionInsufficientFreeForStocksBuyNot enough cashCheck cash.availableToTradeSellingEquityNotOwnedSelling more than ownedCheck quantityAvailableForTradingMarketClosedOutside trading hoursCheck exchange schedule

### Get All Positions

GET /api/v0/equity/positions (1 req/1s)

Query Parameters:

ParameterTypeRequiredDescriptiontickerstringNoFilter by specific ticker (e.g., AAPL_US_EQ)

# All positions
curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/positions"

# Filter by ticker
curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/positions?ticker=AAPL_US_EQ"

Response Schema:

[
  {
    "instrument": {
      "ticker": "AAPL_US_EQ",
      "name": "Apple Inc",
      "isin": "US0378331005",
      "currency": "USD"
    },
    "quantity": 15.5,
    "quantityAvailableForTrading": 12.5,
    "quantityInPies": 3,
    "currentPrice": 185.5,
    "averagePricePaid": 170.25,
    "createdAt": "2024-01-10T09:15:00Z",
    "walletImpact": {
      "currency": "GBP",
      "totalCost": 2089.45,
      "currentValue": 2275.1,
      "unrealizedProfitLoss": 185.65,
      "fxImpact": 12.3
    }
  }
]

### Position Fields

FieldTypeDescriptionquantitynumberTotal shares ownedquantityAvailableForTradingnumberShares available to sellquantityInPiesnumberShares allocated to piescurrentPricenumberCurrent price (instrument currency)averagePricePaidnumberAverage cost per sharecreatedAtdatetimePosition open datewalletImpact.currencystringAccount currencywalletImpact.totalCostnumberTotal cost in account currencywalletImpact.currentValuenumberCurrent value in account currencywalletImpact.unrealizedProfitLossnumberP&L in account currencywalletImpact.fxImpactnumberCurrency rate impact on value

### Position Quantity Scenarios

ScenarioquantityquantityAvailableForTradingquantityInPiesAll direct holdings10100Some in pie1073All in pie10010

Important: Always check quantityAvailableForTrading before placing sell orders.

### Ticker Lookup Workflow

When users reference instruments by common names (e.g., "SAP", "Apple", "AAPL"), you must look up the exact Trading 212 ticker before making any order, position, or historical data queries. Never construct ticker formats manually.

CACHE FIRST: Always check /tmp/t212_instruments.json before calling the API. The instruments endpoint has a 50-second rate limit and returns ~5MB. Only call the API if cache is missing or older than 1 hour.

Generic search: Match the user's search term in the three meaningful fields: ticker, name, or shortName. Use one variable (e.g. SEARCH_TERM) with test($q; "i") on each field so "TSLA", "Tesla", "TL0", etc. match efficiently. For regional filtering (e.g. "US stocks", "European SAP"), use the ISIN prefix (first 2 characters) for country code or currencyCode after the grep.

IMPORTANT: Never auto-select instruments. If multiple options exist, you are required to ask the user for their preference.

# SEARCH_TERM = user query (e.g. TSLA, Tesla, AAPL, SAP)
SEARCH_TERM="TSLA"
CACHE_FILE="/tmp/t212_instruments.json"
if [ -f "$CACHE_FILE" ] && [ $(($(date +%s) - $(stat -f %m "$CACHE_FILE" 2>/dev/null || stat -c %Y "$CACHE_FILE"))) -lt 3600 ]; then
  # Search ticker, name, or shortName fields
  jq --arg q "$SEARCH_TERM" '[.[] | select((.ticker // "" | test($q; "i")) or (.name // "" | test($q; "i")) or (.shortName // "" | test($q; "i")))]' "$CACHE_FILE"
else
  curl -s -H "Authorization: $T212_AUTH_HEADER" \\
    "$T212_BASE_URL/api/v0/equity/metadata/instruments" > "$CACHE_FILE"
fi

### Get All Instruments

GET /api/v0/equity/metadata/instruments (1 req/50s)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/metadata/instruments"

Response Schema:

[
  {
    "ticker": "AAPL_US_EQ",
    "name": "Apple Inc",
    "shortName": "AAPL",
    "isin": "US0378331005",
    "currencyCode": "USD",
    "type": "STOCK",
    "maxOpenQuantity": 10000,
    "extendedHours": true,
    "workingScheduleId": 123,
    "addedOn": "2020-01-15T00:00:00Z"
  }
]

### Instrument Fields

FieldTypeDescriptiontickerstringUnique instrument identifiernamestringFull instrument nameshortNamestringShort symbol (e.g., AAPL)isinstringInternational Securities IDcurrencyCodestringTrading currency (ISO 4217)typestringInstrument type (see below)maxOpenQuantitynumberMaximum position size allowedextendedHoursbooleanWhether extended hours trading is availableworkingScheduleIdintegerReference to exchange scheduleaddedOndatetimeWhen added to platform

### Instrument Types

TypeDescriptionSTOCKCommon stockETFExchange-traded fundCRYPTOCURRENCYCryptocurrencyCRYPTOCrypto assetFOREXForeign exchangeFUTURESFutures contractINDEXIndexWARRANTWarrantCVRContingent value rightCORPACTCorporate action

### Ticker Format

{SYMBOL}_{EXCHANGE}_{TYPE} - Examples:

AAPL_US_EQ - Apple on US exchange
VUSA_LSE_EQ - Vanguard S&P 500 on London
BTC_CRYPTO - Bitcoin

### Get Exchange Metadata

GET /api/v0/equity/metadata/exchanges (1 req/30s)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/metadata/exchanges"

Response Schema:

[
  {
    "id": 123,
    "name": "NASDAQ",
    "workingSchedules": [
      {
        "id": 456,
        "timeEvents": [
          { "type": "PRE_MARKET_OPEN", "date": "2024-01-15T09:00:00Z" },
          { "type": "OPEN", "date": "2024-01-15T14:30:00Z" },
          { "type": "CLOSE", "date": "2024-01-15T21:00:00Z" },
          { "type": "AFTER_HOURS_CLOSE", "date": "2024-01-15T01:00:00Z" }
        ]
      }
    ]
  }
]

### Time Event Types

TypeDescriptionPRE_MARKET_OPENPre-market session startsOPENRegular trading startsBREAK_STARTTrading break beginsBREAK_ENDTrading break endsCLOSERegular trading endsAFTER_HOURS_OPENAfter-hours session startsAFTER_HOURS_CLOSEAfter-hours session endsOVERNIGHT_OPENOvernight session starts

### Historical Data

All historical endpoints use cursor-based pagination with nextPagePath.

### Pagination Parameters

ParameterTypeDefaultMaxDescriptionlimitinteger2050Items per pagecursorstring/number--Pagination cursor (used in nextPagePath)tickerstring--Filter by ticker (orders, dividends)timedatetime--Pagination time (used in nextPagePath for transactions)

### Pagination Example

#!/bin/bash
# Fetch all historical orders with pagination

NEXT_PATH="/api/v0/equity/history/orders?limit=50"

while [ -n "$NEXT_PATH" ]; do
  echo "Fetching: $NEXT_PATH"

  RESPONSE=$(curl -s -H "Authorization: $T212_AUTH_HEADER" \\
    "$T212_BASE_URL$NEXT_PATH")

  # Process items (e.g., save to file)
  echo "$RESPONSE" | jq '.items[]' >> orders.json

  # Get next page path (null if no more pages)
  NEXT_PATH=$(echo "$RESPONSE" | jq -r '.nextPagePath // empty')

  # Wait 1 second between requests (50 req/min limit)
  if [ -n "$NEXT_PATH" ]; then
    sleep 1
  fi
done

echo "Done fetching all orders"

### Historical Orders

GET /api/v0/equity/history/orders (50 req/min)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/history/orders?limit=50"

# Filter by ticker
curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/history/orders?ticker=AAPL_US_EQ&limit=50"

Response Schema:

{
  "items": [
    {
      "order": {
        "id": 123456789,
        "type": "MARKET",
        "ticker": "AAPL_US_EQ",
        "instrument": {
          "ticker": "AAPL_US_EQ",
          "name": "Apple Inc",
          "isin": "US0378331005",
          "currency": "USD"
        },
        "quantity": 5,
        "filledQuantity": 5,
        "status": "FILLED",
        "side": "BUY",
        "createdAt": "2024-01-15T10:30:00Z"
      },
      "fill": {
        "id": 987654321,
        "type": "TRADE",
        "quantity": 5,
        "price": 185.5,
        "filledAt": "2024-01-15T10:30:05Z",
        "tradingMethod": "TOTV",
        "walletImpact": {
          "currency": "GBP",
          "fxRate": 0.79,
          "netValue": 732.72,
          "realisedProfitLoss": 0,
          "taxes": [
            { "name": "STAMP_DUTY", "quantity": 3.66, "currency": "GBP" }
          ]
        }
      }
    }
  ],
  "nextPagePath": "/api/v0/equity/history/orders?limit=50&cursor=1705326600000"
}

### Fill Types

TypeDescriptionTRADERegular trade executionSTOCK_SPLITStock split adjustmentSTOCK_DISTRIBUTIONStock distributionFOPFree of payment transferFOP_CORRECTIONFOP correctionCUSTOM_STOCK_DISTRIBUTIONCustom stock distributionEQUITY_RIGHTSEquity rights issue

### Trading Methods

MethodDescriptionTOTVTraded on trading venueOTCOver-the-counter

### Tax Types (walletImpact.taxes)

TypeDescriptionCOMMISSION_TURNOVERCommission on turnoverCURRENCY_CONVERSION_FEEFX conversion feeFINRA_FEEFINRA trading activity feeFRENCH_TRANSACTION_TAXFrench FTTPTM_LEVYPanel on Takeovers levySTAMP_DUTYUK stamp dutySTAMP_DUTY_RESERVE_TAXUK SDRTTRANSACTION_FEEGeneral transaction fee

### Historical Dividends

GET /api/v0/equity/history/dividends (50 req/min)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/history/dividends?limit=50"

# Filter by ticker
curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/history/dividends?ticker=AAPL_US_EQ&limit=50"

Response Schema:

{
  "items": [
    {
      "ticker": "AAPL_US_EQ",
      "instrument": {
        "ticker": "AAPL_US_EQ",
        "name": "Apple Inc",
        "isin": "US0378331005",
        "currency": "USD"
      },
      "type": "ORDINARY",
      "amount": 12.5,
      "amountInEuro": 14.7,
      "currency": "GBP",
      "tickerCurrency": "USD",
      "grossAmountPerShare": 0.24,
      "quantity": 65.5,
      "paidOn": "2024-02-15T00:00:00Z",
      "reference": "DIV-123456"
    }
  ],
  "nextPagePath": null
}

### Dividend Types (Common)

TypeDescriptionORDINARYRegular dividendBONUSBonus dividendINTERESTInterest paymentDIVIDENDGeneric dividendCAPITAL_GAINSCapital gains distributionRETURN_OF_CAPITALReturn of capitalPROPERTY_INCOMEProperty income (REITs)DEMERGERDemerger distributionQUALIFIED_INVESTMENT_ENTITYQIE distributionTRUST_DISTRIBUTIONTrust distribution

Note: Many additional US tax-specific types exist for 1042-S reporting.

### Account Transactions

GET /api/v0/equity/history/transactions (50 req/min)

Pagination:

First request: Must use only the limit parameter (no cursor, no timestamp)
Subsequent requests: Use the nextPagePath from the previous response, which includes cursor and timestamp automatically
Time filtering: Transactions cannot be filtered by time - pagination is the only way to navigate through historical data

# First request - use only limit
curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/history/transactions?limit=50"

Response Schema:

{
  "items": [
    {
      "type": "DEPOSIT",
      "amount": 1000.0,
      "currency": "GBP",
      "dateTime": "2024-01-10T14:30:00Z",
      "reference": "TXN-123456"
    }
  ],
  "nextPagePath": null
}

### Transaction Types

TypeDescriptionDEPOSITFunds deposited to accountWITHDRAWFunds withdrawn from accountFEEFee chargedTRANSFERInternal transfer

### CSV Reports

Request report: POST /api/v0/equity/history/exports (1 req/30s)

curl -X POST -H "Authorization: $T212_AUTH_HEADER" \\
  -H "Content-Type: application/json" \\
  "$T212_BASE_URL/api/v0/equity/history/exports" \\
  -d '{
    "dataIncluded": {
      "includeDividends": true,
      "includeInterest": true,
      "includeOrders": true,
      "includeTransactions": true
    },
    "timeFrom": "2024-01-01T00:00:00Z",
    "timeTo": "2024-12-31T23:59:59Z"
  }'

Response:

{
  "reportId": 12345
}

Poll for completion: GET /api/v0/equity/history/exports (1 req/min)

curl -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/history/exports"

Response:

[
  {
    "reportId": 12345,
    "status": "Finished",
    "dataIncluded": {
      "includeDividends": true,
      "includeInterest": true,
      "includeOrders": true,
      "includeTransactions": true
    },
    "timeFrom": "2024-01-01T00:00:00Z",
    "timeTo": "2024-12-31T23:59:59Z",
    "downloadLink": "https://trading212-reports.s3.amazonaws.com/..."
  }
]

Download the report:

# Get the download link from the response
DOWNLOAD_URL=$(curl -s -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/history/exports" | jq -r '.[0].downloadLink')

# Download the CSV file
curl -o trading212_report.csv "$DOWNLOAD_URL"

### Report Status Values

StatusDescriptionQueuedReport request receivedProcessingReport generation startedRunningReport actively generatingFinishedComplete - downloadLink availableCanceledReport cancelledFailedGeneration failed

### Before BUY - Check Available Funds

#!/bin/bash
# Validate funds before placing a buy order

TICKER="AAPL_US_EQ"
QUANTITY=10
ESTIMATED_PRICE=185.00
ESTIMATED_COST=$(echo "$QUANTITY * $ESTIMATED_PRICE" | bc)

# Get available funds
AVAILABLE=$(curl -s -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/account/summary" | jq '.cash.availableToTrade')

echo "Estimated cost: $ESTIMATED_COST"
echo "Available funds: $AVAILABLE"

if (( $(echo "$ESTIMATED_COST > $AVAILABLE" | bc -l) )); then
  echo "ERROR: Insufficient funds"
  exit 1
fi

echo "OK: Funds available, proceeding with order"

### Before SELL - Check Available Shares

#!/bin/bash
# Validate position before placing a sell order

TICKER="AAPL_US_EQ"
SELL_QUANTITY=5

# Get position for the ticker
POSITION=$(curl -s -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/positions?ticker=$TICKER")

AVAILABLE_QTY=$(echo "$POSITION" | jq '.[0].quantityAvailableForTrading // 0')

echo "Sell quantity: $SELL_QUANTITY"
echo "Available to sell: $AVAILABLE_QTY"

if (( $(echo "$SELL_QUANTITY > $AVAILABLE_QTY" | bc -l) )); then
  echo "ERROR: Insufficient shares (some may be in pies)"
  exit 1
fi

echo "OK: Shares available, proceeding with order"

### Understanding Rate Limits

Rate limits are per-account, not per API key or IP address. If you have multiple applications using the same Trading 212 account, they share the same rate limit pool.

### Response Headers

Every API response includes rate limit headers:

HeaderDescriptionx-ratelimit-limitTotal requests allowed in periodx-ratelimit-periodTime period in secondsx-ratelimit-remainingRequests remainingx-ratelimit-resetUnix timestamp when limit resetsx-ratelimit-usedRequests already made

### Avoid Burst Requests to avoid Rate Limiting

Do not send requests in bursts. Even if an endpoint allows 50 requests per minute, sending them all at once can trigger rate limiting and degrade performance.
Pace your requests evenly, for example, by making one call every 1.2 seconds, ensuring you always stay within the limit.

Bad approach (bursting):

# DON'T DO THIS - sends all requests at once
for ticker in AAPL_US_EQ MSFT_US_EQ GOOGL_US_EQ; do
  curl -H "Authorization: $T212_AUTH_HEADER" \\
    "$T212_BASE_URL/api/v0/equity/positions?ticker=$ticker" &
done
wait

Good approach (paced):

# DO THIS - space requests evenly
for ticker in AAPL_US_EQ MSFT_US_EQ GOOGL_US_EQ; do
  curl -H "Authorization: $T212_AUTH_HEADER" \\
    "$T212_BASE_URL/api/v0/equity/positions?ticker=$ticker"
  sleep 1.2  # 1.2 second between requests for 50 req/m limit
done

### Caching Strategy

For data that doesn't change frequently, cache locally to reduce API calls:

#!/bin/bash
# Cache instruments list (changes rarely)

CACHE_FILE="/tmp/t212_instruments.json"
CACHE_MAX_AGE=3600  # 1 hour

if [ -f "$CACHE_FILE" ]; then
  CACHE_AGE=$(($(date +%s) - $(stat -f %m "$CACHE_FILE")))
  if [ "$CACHE_AGE" -lt "$CACHE_MAX_AGE" ]; then
    cat "$CACHE_FILE"
    exit 0
  fi
fi

# Cache expired or doesn't exist - fetch fresh data
curl -s -H "Authorization: $T212_AUTH_HEADER" \\
  "$T212_BASE_URL/api/v0/equity/metadata/instruments" > "$CACHE_FILE"

cat "$CACHE_FILE"

### Safety Guidelines

Test in demo first - Always validate workflows before live trading
Validate before ordering - Check funds (cash.availableToTrade) before buy, positions (quantityAvailableForTrading) before sell
Confirm destructive actions - Order placement and cancellation are irreversible
API is not idempotent - Duplicate requests may create duplicate orders
Never log credentials - Use environment variables
Respect rate limits - Space requests evenly, never burst
Max 50 pending orders - Per ticker, per account
Cache metadata - Instruments and exchanges change rarely
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: tsvetelin-kulinski
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-10T04:53:40.865Z
- Expires at: 2026-05-17T04:53:40.865Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/trading212-api)
- [Send to Agent page](https://openagent3.xyz/skills/trading212-api/agent)
- [JSON manifest](https://openagent3.xyz/skills/trading212-api/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/trading212-api/agent.md)
- [Download page](https://openagent3.xyz/downloads/trading212-api)