# AttentionHub API > Global event heat rankings, bilingual news events, continuous probability forecasting, and daily tech & business briefings over a unified HTTPS JSON API. Open to everyone with no API key required. > > **Entity Note**: Operated at `attentionhub.cn` (`api.attentionhub.cn` / `docs.attentionhub.cn`). Independent of and unaffiliated with the academic repository `attentionhub.org`. ## Base & Access Tiers - Base URL: `https://api.attentionhub.cn` (HTTPS / TLS 1.2+) - **Open Public Tier (No Key Required)**: Public read endpoints, web search and fetch, and `POST /v1/predictions` (`visibility: "public"`) work directly with **zero authentication headers**, rate-limited per client IP with daily anonymous prediction caps. - **Self-Generated Private Scope (`X-Private-Token`, Optional, No Signup)**: To create and read `visibility: "private"` predictions without an API key, pass a locally generated high-entropy token (`32–128` chars `[A-Za-z0-9_-]`, at least `10` distinct characters) in `X-Private-Token`. Isolated server-side via salted hashing; does **not** raise anonymous IP rate limits or daily caps. - **High-Volume / Partner Tier (`X-API-Key`, Optional)**: Not required for basic usage; unlocks higher QPS and dedicated daily prediction budgets. Apply at https://docs.attentionhub.cn/apply (or `POST /v1/key-applications`). Passing an invalid or duplicate `X-API-Key` returns `401`. Never send both `X-API-Key` and `X-Private-Token` together (`400 AMBIGUOUS_CREDENTIALS`). - Never hardcode keys or private tokens in source code or expose `X-API-Key` in browser clients; read optionally from `ATTENTIONHUB_API_KEY` or `ATTENTIONHUB_PRIVATE_TOKEN`. - All `/v1/*` responses return `Cache-Control: private, no-store`. - Event cover images use absolute WebP URLs hosted on `https://img.attentionhub.cn` (or `null` when unavailable/filtered). ## Content Display Mode (`cn_safe`) - Default mode is safe (`cn_safe=true`) when `cn_safe` is omitted. - To request the full unfiltered view, pass the exact lowercase query parameter `?cn_safe=false` once. - Any other form (`False`, `0`, duplicate keys, array syntax) falls back to safe mode. - Pagination cursors are bound to the active `cn_safe` mode, credential scope, and query filters; clear `cursor` whenever changing filters, credentials, or display mode (`400 INVALID_QUERY` otherwise). - In safe mode, sensitive events or public predictions queried by ID return `200 { "id": "...", "cn_filtered": true }`. ## Endpoints ### Heat Ranking & Events - `GET /v1/rankings/heat?window=breaking|24h&category=all&limit=20&cursor=...` — Real-time (`breaking`) or 24-hour (`24h`) global event heat snapshot (refreshed every 5 minutes). Each item includes `id`, `rank`, `score`, `rank_delta`, `title`, `summary`, `cover_url`, `representative_sources`, plus v1.2 nullable `source_count`, `article_count`, and `latest_report_at` (mode-scoped to `cn_safe`). - `GET /v1/events/{id}` — Full bilingual event details including v1.3 `body: {zh, en}|null` + `body_status` (`current` | `stale` | `missing`), merged member articles, cover URL, `{ id, merged_into }` redirect when merged, or `{ id, cn_filtered: true }`. - `GET /v1/events?ids=id1,id2,...` — Batch lookup (`1–50` IDs) preserving input order; returns detail, `{ id, merged_into }`, `{ id, cn_filtered: true }`, or `{ id, not_found: true }`. ### Continuous Probability Predictions - `probability`, `probabilities`, and `delta` use a **`0.0–1.0` decimal scale** (e.g. `0.55` = `55%`, `delta: -0.07` = `-7pp`). Valid `status` values: `pending_initial`, `active`, `resolved`, `cancelled`, `invalid`. - `POST /v1/predictions` — Submit a verifiable future-event question (`{ "question": "...", "visibility": "public" | "private" }`, optional `Idempotency-Key` header strongly recommended). `visibility: "public"` works keyless; `visibility: "private"` requires self-generated `X-Private-Token` or `X-API-Key`. Body `cn_safe` is ignored (server-classified); query `?cn_safe=false` controls `similar_questions` visibility. Returns `202 Accepted` with `prediction_id`, `similar_questions`, and `poll_after_ms: 1000`. Relative time returns `422 INVALID_PREDICTION`, `reason: "relative_time_not_allowed"`. - `GET /v1/predictions?status=...&category=...&updated_since=...&sort=recent|updated&limit=20&cursor=...` — Paginated list of public predictions plus private predictions matching the caller's `X-Private-Token` or `X-API-Key`. Each summary includes v1.2 nullable `title: {zh, en}`, `latest_delta`, and `latest_reason: {zh, en}` (fall back to `question` when `title` is `null`). - `GET /v1/predictions/search?q=...&mode=keyword|semantic&limit=20&status=...` — Keyword search or natural-language semantic search (falls back to keyword with `degraded: true` on timeout). - `GET /v1/predictions/{id}` — Poll target after `202` until `status != "pending_initial"`; returns `probability`, `contract`, `related_markets`, plus v1.2 nullable `title`, `latest_delta`, `latest_reason`, and `resolution_recap` (`{ summary: {zh, en} | null, judgment_count, sources: [{ id, source, url, published_at, title, title_zh, summary, summary_zh }] }` on resolved forecasts, v1.3). Private predictions belonging to another token/account return `404`. - `GET /v1/predictions/{id}/history?limit=50&before_id=...` — Reverse-chronological probability history points with `delta`, `reason`, v1.2 nullable `reason_zh`, and v1.3 structured bilingual `evidence[]` (`{ id, source, url, published_at, title, title_zh, summary, summary_zh }`, or `{ id, cn_filtered: true }` in safe mode). ### Daily Tech & Business Briefings (`08:00 UTC+8 / Asia/Shanghai`) - `GET /v1/briefings/latest?lang=both|zh|en` (alias `/v1/briefings/daily/latest`) — Latest published daily briefing (`version` param rejected with `400`). - `GET /v1/briefings/{date}?version=1&lang=both|zh|en` (alias `/v1/briefings/daily/{date}`) — Specific `YYYY-MM-DD` issue with optional immutable `version >= 1`. - `GET /v1/briefings?limit=20&cursor=...&lang=both|zh|en` (alias `/v1/briefings/daily`) — Paginated archive of past issues. ### Web Search and Page Extraction - `GET /v1/web/search?q=NASA+Artemis` or `POST /v1/web/search` with JSON — keyless search with `mode=auto|fast|aggregate`, `topic=general|news`, optional `time_range`, `lang`, `limit`, and `include_content`. A successful response may include partial provider results. - `POST /v1/web/fetch` with `{"url":"https://example.org/"}` — return title and text from a public HTTPS page. - Both routes default to the safe view. Pass `?cn_safe=false` for full. CLI commands are `web-search` and `web-fetch`. They share anonymous 10/min (burst 5) or API-key 60/min (burst 20). ### High-Quota API Key Applications - `POST /v1/key-applications` — Submit a high-quota `X-API-Key` application (`{ "email", "discovery_channel", "use_case" }`; web form hosted at https://docs.attentionhub.cn/apply). Rate limited `3 req/hour` per IP; returns `201 Created` with `{ application_id, status: "pending", created_at }` or `409 APPLICATION_ALREADY_PENDING`. ## Rate Limits & Quotas - General read endpoints (`/v1/rankings/heat`, `/v1/events*`, `/v1/predictions` GET, `/v1/predictions/{id}*`): Open IP `10 req/s` (burst `20`); High-Quota `X-API-Key` `30 req/s` (burst `60`). - Prediction submission (`POST /v1/predictions`): Open IP `6 req/min` (burst `2`), `20/IP/day`, `200/day` global anonymous cap; High-Quota `X-API-Key` `30 req/min` (burst `10`) with dedicated daily quota. Max body `16 KiB`. - Prediction search (`GET /v1/predictions/search`): Open IP `3 req/s` (burst `5`); High-Quota `X-API-Key` `10 req/s` (burst `15`). - Daily briefings (`GET /v1/briefings*`): Open IP `3 req/s` (burst `8`); High-Quota `X-API-Key` `10 req/s` (burst `20`). - On `429 RATE_LIMITED`, honor `Retry-After`; on `429 PREDICTION_BUDGET_EXHAUSTED`, do not retry. ## Error Handling - Branch programmatically on `error.code` (and `error.reason` on `422`): - `400` `INVALID_QUERY` / `INVALID_REQUEST` / `INVALID_IDEMPOTENCY_KEY` / `INVALID_PRIVATE_TOKEN` / `PRIVATE_TOKEN_REQUIRED` / `AMBIGUOUS_CREDENTIALS` — invalid parameter, expired/mismatched cursor, weak/malformed `X-Private-Token`, `private` without credential, or sending both `X-API-Key` and `X-Private-Token`. - `401` `UNAUTHORIZED` — invalid, revoked, or duplicate `X-API-Key` (never triggered when `X-API-Key` is omitted). - `404` `NOT_FOUND` / `RECORD_NOT_FOUND` — resource/issue not found or inaccessible private prediction. - `409` `IDEMPOTENCY_CONFLICT` / `APPLICATION_ALREADY_PENDING` — reused `Idempotency-Key` with changed body, or duplicate pending key application within 24h. - `422` `INVALID_PREDICTION` — undecidable question or relative time (`reason: "relative_time_not_allowed"`). - `429` `RATE_LIMITED` / `PREDICTION_BUDGET_EXHAUSTED` — retry with `Retry-After` on rate limit; do not retry on daily budget exhaustion. - `503` `DEPENDENCY_UNAVAILABLE` — transient upstream issue (`retryable: true`); retry with capped exponential backoff. ## Machine-Readable Docs & Agent Skill Package - OpenAPI 3.1 JSON: https://docs.attentionhub.cn/openapi.json - OpenAPI 3.1 YAML: https://docs.attentionhub.cn/openapi.yaml - Agent Skill Package (`.tar.gz`, complete folder with `SKILL.md`, `scripts/attentionhub.py`, `references/`, `examples/`): https://docs.attentionhub.cn/skills/attentionhub-api.tar.gz - Agent Skill Package (`.zip`): https://docs.attentionhub.cn/skills/attentionhub-api.zip - Skill Manifest & SHA-256 Checksums: https://docs.attentionhub.cn/skills/attentionhub-api/manifest.json - Skill Entry (`SKILL.md`): https://docs.attentionhub.cn/skills/attentionhub-api/SKILL.md - High-Quota Key Application Page: https://docs.attentionhub.cn/apply - Full LLM Reference (complete contracts, errors, workflows & FAQ): https://docs.attentionhub.cn/llms-full.txt - RFC 9727 API Catalog: https://docs.attentionhub.cn/.well-known/api-catalog - English Documentation: https://docs.attentionhub.cn/en/ - Interactive Reference (Chinese): https://docs.attentionhub.cn/