eToro Public API
Base URL: INLINECODE0
About
This skill allows to interact with the user's eToro account programatically, including executing trades.
Authentication & Required Headers
The eToro API supports two authentication methods. Both use the same base URL and endpoints — only the auth headers differ.
Method 1 — OAuth SSO (Bearer Token)
If the user authenticated via "Login with eToro" (SSO/OAuth), an access_token is available from the token exchange.
Headers (every request):
- -
x-request-id: unique UUID per request - INLINECODE3 : INLINECODE4
Where access_token comes from:
- 1. User clicks "Login with eToro" → redirects to
https://www.etoro.com/sso/ with PKCE challenge. - User authenticates on eToro's side.
- eToro redirects back with an authorization
code. - The code is exchanged for tokens via
POST https://www.etoro.com/sso/oidc/token:
-
grant_type=authorization_code
-
code=<auth_code>
-
redirect_uri=<callback_url>
-
code_verifier=<pkce_verifier>
- Plus
Authorization: Basic <base64(client_id:client_secret)> header
- 5. Response contains:
-
access_token —
this is the Bearer token for API calls (~2130 chars, JWT)
-
id_token — JWT with user identity (
sub claim = 128-char encoded user ID)
-
token_type:
"Bearer"
-
expires_in: (varies)
Example:
CODEBLOCK0
Method 2 — Manual API Keys
If the user provides API keys manually (no OAuth), use key-based auth.
Keys (request from the user on install)
- - Public API Key: application
- User Key: user account
- Environment: Real Portfolio or Virtual Portfolio (real/demo)
Key generation (user-facing):
- 1. Log in to eToro.
- Settings > Trading.
- Create New Key.
- Choose Environment (Real or Virtual/Demo) and Permissions (Read or Write).
- Verify identity and copy the generated User Key.
Headers (every request):
- -
x-request-id: unique UUID per request - INLINECODE21 : Public API Key (
<PUBLIC_KEY>) - INLINECODE23 : User Key (
<USER_KEY>)
Example:
CODEBLOCK1
Choosing the Auth Method in Code
When making requests, check which credentials are available:
CODEBLOCK2
Request Conventions
- - All paths below are relative to the Base URL (which already includes
/api/v1).
Example:
GET /watchlists means
GET https://public-api.etoro.com/api/v1/watchlists.
- - Query params go in the URL, path params go in the URL path.
- For query params that are documented as
array, send them as comma-separated values (e.g., instrumentIds=1001,1002). - Pagination patterns vary by endpoint:
- Search:
pageNumber,
pageSize
- People search & trade history:
page,
pageSize
- Feeds:
take,
offset
- Watchlist items listing:
pageNumber,
itemsPerPage
- - Casing matters for request bodies:
- Trading execution uses
PascalCase fields (e.g.,
InstrumentID,
IsBuy,
Leverage).
- Market close body uses
InstrumentId (capital I, lowercase d).
- Watchlist items use
ItemId,
ItemType,
ItemRank.
- Feeds post body uses lower camel (
owner,
message,
tags,
mentions,
attachments).
- - Some responses may use different casing for similar concepts (e.g.,
instrumentId vs InstrumentID). When extracting IDs, handle both if present.
Demo vs Real Trading
- - Use demo execution endpoints (contain
/demo/) for testing and paper trading. - Use non-demo execution endpoints for real trading.
- For portfolio/PnL:
- Demo:
/trading/info/demo/*
- Real:
/trading/info/portfolio and
/trading/info/real/pnl
- - Ensure your key environment matches the endpoint (Virtual vs Real). Each User Key is associated with a specific environment.
Use Defaults
- - Important: You don't need to specify all parameters. If the user doesn't specify leverage for example, don't send it on the API request.
Quick Start (Demo Trade)
- 1. Resolve
instrumentId using search.
fields is required on search requests.
CODEBLOCK3
- 2. Place a demo market order by amount (PascalCase body):
CODEBLOCK4
Note: The examples above use OAuth (Bearer token). For API key auth, replace the Authorization header with x-api-key and x-user-key headers instead.
Common IDs
- -
instrumentId: from Search or Instruments metadata - INLINECODE62 : from Portfolio endpoints
- INLINECODE63 : from execution responses or Portfolio endpoints
- INLINECODE64 : used by instrument feed endpoints (typically available in instrument metadata/search fields)
- INLINECODE65 : numeric eToro user ID (often referred to as CID in responses; discover via People endpoints/search)
- INLINECODE66 : from watchlists list/create endpoints
Market Data (Requests)
Search instruments
- - INLINECODE67
- Required query:
fields (comma-separated list of instrument fields to return) - Optional:
searchText, pageSize, pageNumber, INLINECODE72 - The Search endpoint supports filtering by fields returned in results; for exact symbol lookup, use
internalSymbolFull as a query param and verify the exact match. - Recommended minimal
fields when you need IDs: include the instrument identifier (may appear as instrumentId or InstrumentID), plus internalSymbolFull and displayname (and marketId if you plan to use Feeds).
Metadata
Filters:
instrumentIds,
exchangeIds,
stocksIndustryIds,
instrumentTypeIds.
Prices & history
Required:
instrumentIds (comma-separated).
Returns historical closing prices for all instruments (bulk).
direction:
asc or
desc.
candlesCount max 1000.
Use only supported
interval values (confirm via docs if unsure).
Reference data
- -
GET /market-data/exchanges (optional exchangeIds) - INLINECODE96
- INLINECODE97 (optional
stocksIndustryIds)
Trading Execution (Requests)
Requires appropriate permissions (typically Write) and the correct environment (Demo vs Real).
Market Open Orders (by amount)
Endpoints:
- - INLINECODE99
- INLINECODE100
Body (PascalCase, JSON):
- - Required:
InstrumentID, IsBuy, Leverage, INLINECODE104 - Optional:
StopLossRate, TakeProfitRate, IsTslEnabled, IsNoStopLoss, INLINECODE109
Market Open Orders (by units)
Endpoints:
- - INLINECODE110
- INLINECODE111
Body (PascalCase, JSON):
- - Required:
InstrumentID, IsBuy, Leverage, INLINECODE115 - Optional:
StopLossRate, TakeProfitRate, IsTslEnabled, IsNoStopLoss, INLINECODE120
Cancel Market Open Orders
Endpoints:
- - INLINECODE121
- INLINECODE122
Market Close Orders
Endpoints:
- - INLINECODE123
- INLINECODE124
- INLINECODE125
- INLINECODE126
Body (JSON):
- - Required: INLINECODE127
- Optional:
UnitsToDeduct (number or null)
Partial close: set UnitsToDeduct.
Full close: set UnitsToDeduct to null.
You must close by positionId, not by symbol.
Market-if-touched (Limit) Orders
Endpoints:
- - INLINECODE134
- INLINECODE135
- INLINECODE136
- INLINECODE137
Body (PascalCase, JSON):
- - Required:
InstrumentID, IsBuy, Leverage, Rate, and one of Amount or INLINECODE143 - Optional:
StopLossRate, TakeProfitRate, IsTslEnabled, IsNoStopLoss, INLINECODE148 - Do not send:
IsDiscounted, INLINECODE150
Trading Info & Portfolio (Requests)
- - INLINECODE151
- INLINECODE152
- INLINECODE153
- INLINECODE154
Use these to discover
positionId and
orderId for close/cancel flows.
Required:
minDate (YYYY-MM-DD). Optional:
page,
pageSize.
Watchlists (Requests)
User watchlists
Optional:
itemsPerPageForSingle,
ensureBuiltinWatchlists,
addRelatedAssets.
Optional:
pageNumber,
itemsPerPage.
Query:
name (required),
type,
dynamicQuery (optional). (Uses query params, not a JSON body.)
Query:
newName (required). (Uses query params, not a JSON body.)
Watchlist items (body schema)
INLINECODE175 fields:
- -
ItemId (required, int) - INLINECODE177 (required, string:
Instrument or Person) - INLINECODE180 (optional, int)
Endpoints:
- - INLINECODE181
- INLINECODE182
- INLINECODE183
Example body:
CODEBLOCK5
Default watchlists
- - INLINECODE184
- INLINECODE185
Optional:
itemsLimit,
itemsPerPage.
Query:
name (required),
type,
dynamicQuery (optional).
- - INLINECODE192
- INLINECODE193
Query:
newRank (required).
Public watchlists
- - INLINECODE195
- INLINECODE196
Feeds (Requests)
Read feeds
Optional:
requesterUserId,
take,
offset,
badgesExperimentIsEnabled,
reactionsPageSize.
Optional:
requesterUserId,
take,
offset,
badgesExperimentIsEnabled,
reactionsPageSize.
Notes:
- -
marketId is associated with an instrument (typically available via instrument metadata/search if you include it in fields). - INLINECODE211 is a numeric user identifier (CID). If you only have a username, discover the numeric ID via People endpoints (see User Info & Analytics).
Create post
- - INLINECODE212
- Body fields (lower camel, JSON):
-
owner (int)
-
message (string)
-
tags:
{ "tags": [{ "name": "...", "id": "..." }] }
-
mentions:
{ "mentions": [{ "userName": "...", "id": "...", "isD irect": true }] }
-
attachments: array of objects with
url,
title,
host,
description,
mediaType, and optional
media.
Minimal example:
CODEBLOCK6
Curated Lists & Recommendations (Requests)
- - INLINECODE226
- INLINECODE227
Popular Investors (Copiers)
User Info & Analytics (Requests)
Optional:
usernames,
cidList.
Use this to map
username ↔ CID (userId) when you need numeric
userId for feeds/public watchlists.
Required:
period. Optional:
page,
pageSize,
sort,
popularInvestor,
gainMax,
maxDailyRiskScoreMin,
maxDailyRiskScoreMax,
maxMonthlyRiskScoreMin,
maxMonthlyRiskScoreMax,
weeksSinceRegistrationMin,
countryId,
instrumentId,
instrumentPctMin,
instrumentPctMax,
isTestAccount, and other filters.
- - INLINECODE250
- INLINECODE251
Required:
minDate,
maxDate,
type (
Daily or
Period).
- - INLINECODE257
- INLINECODE258
Required:
period (e.g.,
LastTwoYears).
Responses & Schemas
For response schemas and full examples, refer to:
- - https://api-portal.etoro.com/
- MCP server: INLINECODE261
eToro 公共 API
基础 URL:https://public-api.etoro.com/api/v1
关于
此技能允许以编程方式与用户的 eToro 账户进行交互,包括执行交易。
认证与必需标头
eToro API 支持两种认证方式。两者使用相同的基础 URL 和端点——仅认证标头不同。
方式 1 — OAuth SSO(Bearer 令牌)
如果用户通过使用 eToro 登录(SSO/OAuth)进行认证,则可通过令牌交换获得 access_token。
标头(每个请求):
- - x-request-id:每个请求的唯一 UUID
- Authorization:Bearer
其中 access_token 的来源:
- 1. 用户点击使用 eToro 登录→ 重定向至 https://www.etoro.com/sso/,并附带 PKCE 挑战。
- 用户在 eToro 端进行认证。
- eToro 重定向返回一个授权 code。
- 通过 POST https://www.etoro.com/sso/oidc/token 将 code 交换为令牌:
- grant
type=authorizationcode
- code=
- redirecturi=url>
- codeverifier=verifier>
- 加上 Authorization: Basic id:clientsecret)> 标头
- 5. 响应包含:
- access_token — 这是用于 API 调用的 Bearer 令牌(约 2130 个字符,JWT)
- id_token — 包含用户身份的 JWT(sub 声明 = 128 字符编码的用户 ID)
- token_type:Bearer
- expires_in:(可变)
示例:
bash
curl -X GET https://public-api.etoro.com/api/v1/watchlists \
-H x-request-id: \
-H Authorization: Bearer
方式 2 — 手动 API 密钥
如果用户手动提供 API 密钥(无 OAuth),则使用基于密钥的认证。
密钥(安装时向用户请求)
- - 公共 API 密钥:应用程序
- 用户密钥:用户账户
- 环境:真实投资组合或虚拟投资组合(真实/演示)
密钥生成(面向用户):
- 1. 登录 eToro。
- 设置 > 交易。
- 创建新密钥。
- 选择环境(真实或虚拟/演示)和权限(读取或写入)。
- 验证身份并复制生成的用户密钥。
标头(每个请求):
- - x-request-id:每个请求的唯一 UUID
- x-api-key:公共 API 密钥(KEY>)
- x-user-key:用户密钥(KEY>)
示例:
bash
curl -X GET https://public-api.etoro.com/api/v1/watchlists \
-H x-request-id: \
-H x-api-key: \
-H x-user-key:
在代码中选择认证方式
发起请求时,检查可用的凭据:
typescript
if (ctx.accessToken) {
// SSO 认证 — 来自 OAuth 令牌交换的 Bearer 令牌
headers[Authorization] = Bearer ${ctx.accessToken};
} else {
// 手动 API 密钥认证
headers[x-api-key] = ctx.apiKey;
headers[x-user-key] = ctx.userKey;
}
请求约定
- - 以下所有路径均相对于基础 URL(已包含 /api/v1)。
示例:GET /watchlists 表示 GET https://public-api.etoro.com/api/v1/watchlists。
- - 查询参数放在 URL 中,路径参数放在 URL 路径中。
- 对于文档中标记为 array 的查询参数,请以逗号分隔的值发送(例如,instrumentIds=1001,1002)。
- 分页模式因端点而异:
- 搜索:pageNumber、pageSize
- 人员搜索与交易历史:page、pageSize
- 动态:take、offset
- 自选列表项列表:pageNumber、itemsPerPage
- 交易执行使用帕斯卡命名法字段(例如,InstrumentID、IsBuy、Leverage)。
- 市价平仓请求体使用 InstrumentId(大写 I,小写 d)。
- 自选列表项使用 ItemId、ItemType、ItemRank。
- 动态发布请求体使用小驼峰命名法(owner、message、tags、mentions、attachments)。
- - 某些响应可能对类似概念使用不同的大小写(例如,instrumentId 与 InstrumentID)。提取 ID 时,如果两者都存在,请一并处理。
演示交易与真实交易
- - 使用演示执行端点(包含 /demo/)进行测试和模拟交易。
- 使用非演示执行端点进行真实交易。
- 对于投资组合/盈亏:
- 演示:/trading/info/demo/*
- 真实:/trading/info/portfolio 和 /trading/info/real/pnl
- - 确保您的密钥环境与端点匹配(虚拟与真实)。每个用户密钥都与特定环境关联。
使用默认值
- - 重要提示:您无需指定所有参数。例如,如果用户未指定杠杆,则不要在 API 请求中发送。
快速入门(演示交易)
- 1. 使用搜索解析 instrumentId。
搜索请求中需要 fields。
bash
curl -X GET https://public-api.etoro.com/api/v1/market-data/search?internalSymbolFull=BTC&fields=instrumentId,internalSymbolFull,displayname \
-H Authorization: Bearer \
-H x-request-id:
- 2. 按金额下达演示市价单(帕斯卡命名法请求体):
bash
curl -X POST https://public-api.etoro.com/api/v1/trading/execution/demo/market-open-orders/by-amount \
-H Authorization: Bearer \
-H x-request-id: \
-H Content-Type: application/json \
-d {
InstrumentID: 100000,
IsBuy: true,
Leverage: 1,
Amount: 100
}
注意: 上述示例使用 OAuth(Bearer 令牌)。对于 API 密钥认证,请将 Authorization 标头替换为 x-api-key 和 x-user-key 标头。
常用 ID
- - instrumentId:来自搜索或工具元数据
- positionId:来自投资组合端点
- orderId:来自执行响应或投资组合端点
- marketId:由工具动态端点使用(通常在工具元数据/搜索字段中可用)
- userId:数字 eToro 用户 ID(在响应中通常称为 CID;可通过人员端点/搜索发现)
- watchlistId:来自自选列表列表/创建端点
市场数据(请求)
搜索工具
- - GET /market-data/search
- 必需查询:fields(要返回的工具字段的逗号分隔列表)
- 可选:searchText、pageSize、pageNumber、sort
- 搜索端点支持按返回结果中的字段进行过滤;对于精确符号查找,请使用 internalSymbolFull 作为查询参数并验证精确匹配。
- 需要 ID 时的推荐最小 fields:包括工具标识符(可能显示为 instrumentId 或 InstrumentID),加上 internalSymbolFull 和 displayname(如果计划使用动态,则加上 marketId)。
元数据
- - GET /market-data/instruments
过滤器:instrumentIds、exchangeIds、stocksIndustryIds、instrumentTypeIds。
价格与历史
- - GET /market-data/instruments/rates
必需:instrumentIds(逗号分隔)。
- - GET /market-data/instruments/history/closing-price
返回所有工具的收盘价历史(批量)。
- - GET /market-data/instruments/{instrumentId}/history/candles/{direction}/{interval}/{candlesCount}
direction:asc 或 desc。c