Side-by-side metrics for up to ten accounts
https://api.handlesapi.com/v1/insights/x/compareThe POST /v1/insights/x/compare endpoint of Handles API (Insights): Side-by-side metrics for up to ten accounts. One call costs 1 credit (a catalog read) and needs the insights:read scope. A success returns JSON as { data, meta }.
Competitive analysis in one call: the same engagement block and cohort placement for every handle in the body, plus a ranking by engagement rate so follower count does not decide the answer. Handles we have not measured come back with null metrics and their coverage marker rather than being dropped.
- At most 10 handles per call.
- Ranking excludes handles with no tweet coverage; they are still present in accounts with coverage.tweets=false.
- Rates are only comparable between accounts of similar size. peer_percentile is the size-adjusted number and is the fairer column to sort a competitive set on.
Request
curl -X POST "https://api.handlesapi.com/v1/insights/x/compare" \
-H "Authorization: Bearer $HANDLES_API_KEY"const res = await fetch("https://api.handlesapi.com/v1/insights/x/compare", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.HANDLES_API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error.code);
const { data, meta } = await res.json();
console.log(data);import os
import requests
res = requests.post(
"https://api.handlesapi.com/v1/insights/x/compare",
headers={"Authorization": f"Bearer {os.environ['HANDLES_API_KEY']}"},
)
res.raise_for_status()
print(res.json()["data"])Set HANDLES_API_KEY to a key from your dashboard. Keys start with hk_live_.
Request body
JSON, sent with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
| handles | array of string | Required | Array of X handles without the @, 1-10 of them, for example ["elonmusk","BillGates","NASA"]. Duplicates are collapsed case-insensitively before they take a slot. |
| metric | enum | Optional | Echoed onto the response for clients that batch several metrics. |
Response
Success is always { data, meta }.
{
"data": {
"requested": 3,
"resolved": 3,
"ranking": [
{
"handle": "elonmusk",
"engagement_rate": 0.0471,
"peer_percentile": 99.7,
"followers": 241382119
},
{
"handle": "BillGates",
"engagement_rate": 0.0142,
"peer_percentile": 71,
"followers": 65130442
},
{
"handle": "NASA",
"engagement_rate": 0.0117,
"peer_percentile": 62,
"followers": 96204881
}
],
"accounts": [
{
"handle": "elonmusk",
"found": true,
"coverage": {
"tweets": true,
"reliable": true
}
}
]
},
"meta": {
"request_id": "req_9f2c41a8b3d5",
"generated_at": "2026-08-23T09:14:02.317Z",
"took_ms": 42
}
}Response headers
Every successful response carries these headers.
| Header | Type | Description |
|---|---|---|
| X-Request-Id | string | Quote this to support. |
| X-RateLimit-Limit | integer | Requests allowed in the current one-minute window. |
| X-RateLimit-Remaining | integer | Requests left in the current one-minute window. |
| X-RateLimit-Reset | integer | Unix seconds at which the current window resets. |
| X-Credits-Cost | integer | Credits this call used. |
| X-Credits-Remaining | integer | Plan credits left in the current period. |
| X-Credits-Period-End | string | When the current period ends (ISO 8601). |
Errors
| Status | Error code | When |
|---|---|---|
| 401 | unauthorized | No key was sent, or the key is unknown or revoked. |
| 402 | quota_exceeded | Your plan's credits for this period are used up and overage is off (or its cap is reached). Waiting does not help: upgrade, or turn on overage in the dashboard. |
| 422 | invalid_request | A parameter is malformed, out of range or mutually exclusive with another. details names the offending fields. |
| 429 | rate_limitedlive_limit_reached | Too many requests. rate_limited clears when the minute window resets (see Retry-After); live_limit_reached (Free plan) clears at 00:00 UTC.Also sends Retry-After, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset. |
| 500 | internal_error | Something failed on our side. The call was not charged; quote the request_id to support. |
| 503 | upstream_timeoutupstream_errorplatform_unavailableservice_unavailable | The call could not be served right now and was not charged. upstream_timeout / upstream_error: a data source was slow or failed, retry with backoff. platform_unavailable: live reads for that platform are paused. service_unavailable: retry shortly. |
Failures use the error envelope. Branch on error.code, never on the message.