自建 API key 说明

Own API Key Guide · 版本 2026-10-19.1 · 2026-10-19 生效

API 查询宏观阿尔法内容库,推荐通过 Agent J:在 Agent J 广场安装「宏观阿尔法内容库」技能,由你自己的 Agent 调用,不必自己管理 key。付费会员也可以按本页自建 API key 直接调用。

谁可以建

任一付费会员档(无常及以上)且订阅有效的账号。会员到期或降为免费后,已建的 key 会暂停(返回 403),恢复订阅后自动恢复。

能查什么

价格(从你的账号积分扣,1 积分 = $0.001)

限额

第 1 步:登录,拿到临时访问令牌

用你在 app.macroalpha.io 的邮箱和密码登录。如果你一直用 Apple 或 Google 登录、没设过密码,先在登录页点「忘记密码」,用账号邮箱(Apple 隐藏邮箱就填那个转发地址)设一个密码。

响应里的 accessToken 在本流程里用来建、查看和吊销 key,15 分钟内有效。它等同于你的登录凭据,不要外泄。

curl -s https://app.macroalpha.io/api/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"email":"you@example.com","password":"<你的密码>"}'

第 2 步:建一把 data key

name 是给自己看的名字(1–60 字),scopes 必须写 ["data"];不写会建出没有数据权限的 key,调用时返回 403,还会占用当天的新建次数。

curl -s https://app.macroalpha.io/api/account/api-keys \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"name":"my data key","scopes":["data"]}'

响应里的 key 就是完整的 API key,只显示这一次,请立刻存进密码管理器或环境变量。丢了无法找回,只能吊销后重建。apiKey.id 是这把 key 的编号,吊销时要用。

建完就退出这次登录。每个账号最多同时保留 5 个登录会话,反复登录不退出,会把你手机 App 或浏览器上的登录挤掉:

curl -s -X POST https://app.macroalpha.io/api/auth/logout \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

第 3 步:用 key 直接调用

基础地址 https://app.macroalpha.io/api/v1/data,每次请求带上 Authorization: Bearer <YOUR_API_KEY>。

# 节目列表(可加 q 关键词、topic 播放列表编号 0–10、access=free|members|all、from/to 日期、pageSize ≤ 50)
curl -s -G https://app.macroalpha.io/api/v1/data/episodes \
  --data-urlencode 'q=无常' --data-urlencode 'pageSize=5' \
  -H 'Authorization: Bearer <YOUR_API_KEY>'

# 单集详情(免费节目带全文 body)
curl -s https://app.macroalpha.io/api/v1/data/episodes/<EPISODE_ID> \
  -H 'Authorization: Bearer <YOUR_API_KEY>'

# 语义搜索
curl -s https://app.macroalpha.io/api/v1/data/search \
  -H 'Authorization: Bearer <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{"query":"AI 有没有佛性","topK":5}'

# 这个话题讲过没有(verdict = covered / related / new)
curl -s https://app.macroalpha.io/api/v1/data/coverage \
  -H 'Authorization: Bearer <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{"topic":"斯多葛主义和佛教的无常观有什么异同"}'

# 用量(免费)
curl -s https://app.macroalpha.io/api/v1/data/usage \
  -H 'Authorization: Bearer <YOUR_API_KEY>'

调用成功时,响应头里的 X-Credits-Charged 是本次扣的积分,X-Credits-Balance 是剩余余额;用 GET /usage 可以随时核对。

查看与吊销

需要先按第 1 步登录拿到 accessToken,用完照样退出。

# 列出我的 key(只显示前缀,不显示完整 key)
curl -s https://app.macroalpha.io/api/account/api-keys \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

# 吊销一把 key(立即生效,不可恢复)
curl -s -X DELETE https://app.macroalpha.io/api/account/api-keys/<KEY_ID> \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

怀疑 key 泄露时请马上吊销再重建。不要把 key 写进公开代码、截图或发给别人。

使用条款

仅供参考与研究,不得整篇转载或再分发。问题请在 App 的“消息 → 联系支持”提交,或发邮件至 founder@macroalpha.io。

English

For API queries of the MacroAlpha content library we recommend Agent J: install the MacroAlpha Library skill from the Agent J Plaza and let your own agent call it, with no keys to manage. Paid members can also create their own API key and call the API directly, as described below.

Who can create a key

Any account with an active paid membership (Wuchang or above). If the membership lapses, existing keys are paused (403) and resume automatically when it is renewed.

What you can query

Published episodes of the MacroAlpha Chinese channel: list and filter, episode details, semantic search, and a "have you covered this topic?" check. Free episodes include the full transcript, and search results usually include snippets; members-only episodes return public metadata (title, date, links) only, without transcript or snippets. Unpublished or scheduled content is never returned.

Prices (charged to your account credits; 1 credit = $0.001)

  • GET /episodes and GET /episodes/{id}: 10 credits ($0.01) per call.
  • POST /search and POST /coverage: 20 credits ($0.02) per call.
  • GET /usage: free.
  • Only successful calls are charged. If your balance is below the price of the call, you get 402 and nothing is charged.

Limits

Up to 5 active keys per account; at most 3 creations and 3 revocations per 24 hours. Each key: 60 requests per minute and 5,000 per day, of which search and coverage 20 per minute; usage 60 per hour. Over the limit you get 429 with a Retry-After header.

Step 1: sign in for a short-lived access token

curl -s https://app.macroalpha.io/api/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"email":"you@example.com","password":"<your password>"}'

If you have always signed in with Apple or Google and never set a password, first use "Forgot password" on the sign-in page with your account email (for Hide My Email, the relay address) to set one. The accessToken is used here to create, list and revoke keys and is valid for 15 minutes; it is equivalent to your sign-in credentials, so keep it private.

Step 2: create a data key

curl -s https://app.macroalpha.io/api/account/api-keys \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"name":"my data key","scopes":["data"]}'

scopes must be ["data"]; without it the key has no data access (calls return 403) and the attempt still counts toward the daily creation limit.

The key field is your full API key and is shown only once. Store it in a password manager or environment variable right away; a lost key cannot be recovered, only revoked and replaced. apiKey.id identifies the key for revocation.

Sign out when you are done. An account keeps at most 5 sign-in sessions, so repeated sign-ins without signing out can sign your phone app or browser out:

curl -s -X POST https://app.macroalpha.io/api/auth/logout \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

Step 3: call the API with your key

Base URL https://app.macroalpha.io/api/v1/data; send Authorization: Bearer <YOUR_API_KEY> with every request.

curl -s 'https://app.macroalpha.io/api/v1/data/episodes?pageSize=5' \
  -H 'Authorization: Bearer <YOUR_API_KEY>'

curl -s https://app.macroalpha.io/api/v1/data/search \
  -H 'Authorization: Bearer <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{"query":"Does AI have Buddha-nature?","topK":5}'

On successful calls, the X-Credits-Charged and X-Credits-Balance response headers show the credits charged and your remaining balance; GET /usage lets you check at any time.

List and revoke

curl -s https://app.macroalpha.io/api/account/api-keys \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

curl -s -X DELETE https://app.macroalpha.io/api/account/api-keys/<KEY_ID> \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'

Revocation takes effect immediately and cannot be undone. Revoke and replace a key at once if you think it has leaked; never put it in public code or screenshots.

Terms

For reference and research only; do not republish or redistribute full texts. For help, use Messages → Contact Support in the app or email founder@macroalpha.io.