This repo reads public Substack data with Python or curl. You can search newsletters by keyword and read a newsletter's profile, its posts, one post, and its comments. You need one EveryInfra API key. You do not need a Substack account or cookie. The same API also works as an MCP tool in Claude and Cursor. Billing is per call: these 5 capabilities cost $1.39 per 1,000 calls (about $0.0014 per call). Failed calls and empty results are not charged. The EveryInfra Substack API has 7 capabilities, all listed on the platform page: https://everyinfra.com/en/substack-api?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
git clone https://github.com/everyinfra/substack-api.git
cd substack-api
pip install -r requirements.txt
export EVERYINFRA_API_KEY=<your API key>
python main.py search technology --out newsletters.csv
python main.py newsletter https://astralcodexten.substack.com
python main.py posts https://astralcodexten.substack.com --out posts.csv
python main.py post "<post url>" --out post.json
python main.py comments "<post url>" --out comments.csv- For
newsletterandposts, pass the newsletter's home link (*.substack.com). Forpostandcomments, pass a /p/ post link. Theurlfrom apostsresult works. - Without
--out, the command prints the first 3 rows as JSON. With--out, it saves a .csv or .json file. The CSV has a BOM, so Excel opens it without garbled text. - Register at everyinfra.com, then create the API key in the console. Steps: https://everyinfra.com/en/docs?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api#quickstart
curl -X POST https://api.everyinfra.com/api/v1/social \
-H "Authorization: Bearer $EVERYINFRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"platform":"substack","action":"search","params":{"keyword":"technology"}}'All capabilities use the same URL. Change action and params to call another one. Examples for publication, publication_posts, post, and comments are in examples/curl.sh.
The remote MCP URL is https://api.everyinfra.com/mcp. Add the Authorization: Bearer header with your API key. EveryInfra runs the server, so you install no local program.
Claude Code:
claude mcp add --transport http everyinfra https://api.everyinfra.com/mcp --header "Authorization: Bearer <API Key>"Cursor and other clients that read mcp.json (examples/mcp.json):
{
"mcpServers": {
"everyinfra": {
"url": "https://api.everyinfra.com/mcp",
"headers": {
"Authorization": "Bearer <API Key>"
}
}
}
}Custom connectors in Claude on the web and desktop, and ChatGPT, accept only a URL. Enter https://api.everyinfra.com/mcp/all, sign in to EveryInfra when asked, and allow access. You do not need to enter a key. Full steps: https://everyinfra.com/en/mcp-server?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
action |
Per 1,000 calls |
|---|---|
search |
$1.39 |
publication |
$1.39 |
publication_posts |
$1.39 |
post |
$1.39 |
comments |
$1.39 |
- Billing is per call, about $0.0014 each. Failed calls, empty results, parameter errors, and authentication failures are not charged.
- A new account gets a $1 trial allowance, valid for 24 hours. No credit card is needed. How to claim it: https://everyinfra.com/en/pricing?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
- Prices for the other 2 Substack capabilities are on the platform page: https://everyinfra.com/en/substack-api?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
These are the fields that the 5 capabilities returned in our test. Each meaning is the first sentence of the field's entry in the API documentation. The link under each table has the full text.
| Field | Meaning |
|---|---|
id |
The record's unique ID on the platform. |
handle |
User handle. |
name |
Name of the object itself, for account, product and business capabilities. |
url |
Link to the record on the platform. |
bio |
Profile bio written by the account; may contain line breaks and emoji. |
language |
Content language code (for example zh, en) as judged by the platform; it can be wrong. |
payments_enabled |
Whether the publication has paid subscriptions enabled. |
avatar_url |
Avatar image link. |
cover_url |
Cover image. |
platform |
Source platform identifier, the same as platform in the request (for example xiaohongshu, tiktok). |
author_name |
Author's display name. |
author_username |
Author's username (@handle), usually usable in URLs. |
custom_domain |
Custom domain. |
All parameters and fields: https://everyinfra.com/en/substack-api/search?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
| Field | Meaning |
|---|---|
handle |
User handle. |
name |
Name of the object itself, for account, product and business capabilities. |
url |
Link to the record on the platform. |
custom_domain |
Custom domain. |
bio |
Profile bio written by the account; may contain line breaks and emoji. |
language |
Content language code (for example zh, en) as judged by the platform; it can be wrong. |
payments_enabled |
Whether the publication has paid subscriptions enabled. |
avatar_url |
Avatar image link. |
platform |
Source platform identifier, the same as platform in the request (for example xiaohongshu, tiktok). |
All parameters and fields: https://everyinfra.com/en/substack-api/publication?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
| Field | Meaning |
|---|---|
id |
The record's unique ID on the platform. |
url |
Link to the record on the platform. |
title |
Title. null when the platform has no titles (for example text-only posts). |
subtitle |
Subtitle. |
text |
Body text with HTML removed, returned in full and never cut short (on a few platforms the list results themselves carry only an excerpt; the platform's field notes say so). |
author_name |
Author's display name. |
author_username |
Author's username (@handle), usually usable in URLs. |
publication_name |
Publication (newsletter) name. |
publication_url |
Publication link. |
like_count |
Likes. null means the platform or this capability does not disclose it; it is not 0. |
comment_count |
Comments. null means not disclosed, not 0. |
repost_count |
Reposts (as distinct from quote posts). null means not disclosed. |
word_count |
Word count of the body text. |
post_type |
Content type (newsletter/podcast/thread, etc.). |
audience |
Audience scope (everyone/paid, etc.). |
is_paid |
Whether the content is paid. |
image_url |
Image link. |
posted_at |
Publish time in ISO 8601, UTC (for example 2026-08-07T12:34:56+00:00). |
updated_at |
Update time. |
platform |
Source platform identifier, the same as platform in the request (for example xiaohongshu, tiktok). |
All parameters and fields: https://everyinfra.com/en/substack-api/publication_posts?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
| Field | Meaning |
|---|---|
id |
The record's unique ID on the platform. |
url |
Link to the record on the platform. |
title |
Title. null when the platform has no titles (for example text-only posts). |
subtitle |
Subtitle. |
text |
Body text with HTML removed, returned in full and never cut short (on a few platforms the list results themselves carry only an excerpt; the platform's field notes say so). |
author_name |
Author's display name. |
author_username |
Author's username (@handle), usually usable in URLs. |
publication_name |
Publication (newsletter) name. |
publication_url |
Publication link. |
like_count |
Likes. null means the platform or this capability does not disclose it; it is not 0. |
comment_count |
Comments. null means not disclosed, not 0. |
repost_count |
Reposts (as distinct from quote posts). null means not disclosed. |
word_count |
Word count of the body text. |
post_type |
Content type (newsletter/podcast/thread, etc.). |
audience |
Audience scope (everyone/paid, etc.). |
is_paid |
Whether the content is paid. |
image_url |
Image link. |
posted_at |
Publish time in ISO 8601, UTC (for example 2026-08-07T12:34:56+00:00). |
updated_at |
Update time. |
platform |
Source platform identifier, the same as platform in the request (for example xiaohongshu, tiktok). |
All parameters and fields: https://everyinfra.com/en/substack-api/post?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
| Field | Meaning |
|---|---|
id |
The record's unique ID on the platform. |
text |
Body text with HTML removed, returned in full and never cut short (on a few platforms the list results themselves carry only an excerpt; the platform's field notes say so). |
author_name |
Author's display name. |
author_username |
Author's username (@handle), usually usable in URLs. |
like_count |
Likes. null means the platform or this capability does not disclose it; it is not 0. |
is_reply |
Whether it is a reply (for Notes). |
is_pinned |
Whether it is pinned. |
is_author |
Whether the commenter is the author of the post. |
posted_at |
Publish time in ISO 8601, UTC (for example 2026-08-07T12:34:56+00:00). |
platform |
Source platform identifier, the same as platform in the request (for example xiaohongshu, tiktok). |
reply_to_id |
ID of the content being replied to. |
All parameters and fields: https://everyinfra.com/en/substack-api/comments?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
Do I need a Substack account or cookie to call the API?
No. Send the Authorization: Bearer header with your API key. The request body holds platform, action, and the capability parameters. You do not scan a QR code, keep a login session, or open a browser.
How much does it cost? Are failed calls charged? Is there a free allowance?
Billing is per call, from $1.39 per 1,000 calls. Failed calls, empty results, parameter errors, and authentication failures are not charged. A new account gets a $1 trial allowance, valid for 24 hours. No credit card is needed. How to claim it: https://everyinfra.com/en/pricing?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
Can I connect the Substack API to Claude or Cursor?
Yes. The remote MCP URL is https://api.everyinfra.com/mcp. Add the Authorization: Bearer header with your API key. You install no local program. Setup for Claude, Cursor, ChatGPT, and Claude Code: https://everyinfra.com/en/mcp-server?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api. An agent can then search Substack content, read comments, and look up accounts by itself.
What legal points apply when I use Substack data?
The EveryInfra Terms of Service require you to make sure your use of the data follows applicable law and the terms of the relevant platform. Do not use the data for anything illegal or anything that violates privacy or intellectual property rights. Do not use bulk scraping for harassment, fraud, or other abuse. When you use personal information such as nicknames and avatars, keep only the fields your business needs.
Which Substack data can I get?
The EveryInfra Substack API has 7 capabilities:
- keyword search
- publication
- publication posts
- post details
- comments
- profile or object details
- notes
Parameters and return fields for each capability are on the platform page: https://everyinfra.com/en/substack-api?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
Before release, we ran the 5 commands in Quick start against the live API with this repo's code.
| Command | Time (Singapore, UTC+8) | Rows | Charged |
|---|---|---|---|
python main.py search technology --out newsletters.csv |
2026-11-29 19:15 | 10 | $0.001389 |
python main.py newsletter https://astralcodexten.substack.com |
2026-11-29 19:15 | 1 | $0.001389 |
python main.py posts https://astralcodexten.substack.com --out posts.csv |
2026-11-29 19:15 | 10 | $0.001389 |
python main.py post "<post url>" --out post.json |
2026-11-29 19:15 | 1 | $0.001389 |
python main.py comments "<post url>" --out comments.csv |
2026-11-29 19:16 | 20 | $0.001389 |
本仓库用 Python 或 curl 读 Substack 公开数据:按关键词搜专栏,读专栏资料、文章列表、单篇文章和评论。只需一把 EveryInfra API Key,不用 Substack 账号和 Cookie,也能作为 MCP 工具接进 Claude、Cursor。按调用次数计费,这 5 个能力每千次 $1.39(每次约 $0.0014),失败和空结果不收费。Substack 共 7 个能力:https://everyinfra.com/substack-api?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
git clone https://github.com/everyinfra/substack-api.git
cd substack-api
pip install -r requirements.txt
export EVERYINFRA_API_KEY=<你的 API Key>
python main.py search technology --out newsletters.csv
python main.py newsletter https://astralcodexten.substack.com
python main.py posts https://astralcodexten.substack.com --out posts.csv
python main.py post "<文章链接>" --out post.json
python main.py comments "<文章链接>" --out comments.csvnewsletter和posts传专栏主页链接(*.substack.com);post和comments传 /p/ 开头的文章链接,可用posts结果里的url。- 不加
--out时打印前 3 条 JSON;加--out存成 .csv 或 .json。CSV 带 BOM,Excel 直接打开不乱码。 - API Key 在 everyinfra.com 注册后到控制台创建,步骤见 https://everyinfra.com/docs?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api#quickstart
curl -X POST https://api.everyinfra.com/api/v1/social \
-H "Authorization: Bearer $EVERYINFRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"platform":"substack","action":"search","params":{"keyword":"technology"}}'所有能力都发到同一个地址,换 action 和 params 就行;publication、publication_posts、post、comments 的写法见 examples/curl.sh。
远程 MCP 地址是 https://api.everyinfra.com/mcp,请求头加 Authorization: Bearer 和 API Key;服务器由 EveryInfra 运行,不用装本地程序。
Claude Code:
claude mcp add --transport http everyinfra https://api.everyinfra.com/mcp --header "Authorization: Bearer <API Key>"Cursor 等读 mcp.json 的客户端(examples/mcp.json):
{
"mcpServers": {
"everyinfra": {
"url": "https://api.everyinfra.com/mcp",
"headers": {
"Authorization": "Bearer <API Key>"
}
}
}
}Claude 网页版和桌面版的自定义连接器、ChatGPT 只能填网址:填 https://api.everyinfra.com/mcp/all,连接时登录 EveryInfra 并允许,不用填 Key。完整步骤见 https://everyinfra.com/mcp-server?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
| 能力 | action |
每千次 |
|---|---|---|
| 关键词搜索 | search |
$1.39 |
| 出版物或专栏 | publication |
$1.39 |
| 出版物文章 | publication_posts |
$1.39 |
| 单条内容 | post |
$1.39 |
| 评论 | comments |
$1.39 |
- 按调用次数计费,每次约 $0.0014;失败、空结果、参数错误和鉴权失败都不收费。
- 新账号有 $1 试用额度,24 小时内有效,不用信用卡,领取方式见 https://everyinfra.com/pricing?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
- Substack 其他 2 个能力的单价见平台页 https://everyinfra.com/substack-api?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
下面是这 5 个能力实测返回的字段,含义取自接口文档每条说明的第一句,完整说明在每张表下面的链接里。
| 字段 | 含义 |
|---|---|
id |
该记录在原平台上的唯一标识。 |
handle |
用户短名。 |
name |
名称。 |
url |
该记录在原平台上的可访问链接。 |
bio |
个人简介,账号自己填写的文本。 |
language |
内容语言代码(如 zh、en),由平台判定,可能不准。 |
payments_enabled |
该出版物是否开通了付费订阅。 |
avatar_url |
头像图片链接。 |
cover_url |
封面图。 |
platform |
数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。 |
author_name |
作者昵称(显示名)。 |
author_username |
作者用户名(@handle),通常可用于拼 URL。 |
custom_domain |
自定义域名,配了说明作者有意长期经营。 |
| 字段 | 含义 |
|---|---|
handle |
用户短名。 |
name |
名称。 |
url |
该记录在原平台上的可访问链接。 |
custom_domain |
自定义域名,配了说明作者有意长期经营。 |
bio |
个人简介,账号自己填写的文本。 |
language |
内容语言代码(如 zh、en),由平台判定,可能不准。 |
payments_enabled |
该出版物是否开通了付费订阅。 |
avatar_url |
头像图片链接。 |
platform |
数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。 |
| 字段 | 含义 |
|---|---|
id |
该记录在原平台上的唯一标识。 |
url |
该记录在原平台上的可访问链接。 |
title |
标题。 |
subtitle |
副标题。 |
text |
正文内容,已去除 HTML 标签,全文返回、不截断(个别平台的列表结果本身只有摘要,以该平台的字段说明为准)。 |
author_name |
作者昵称(显示名)。 |
author_username |
作者用户名(@handle),通常可用于拼 URL。 |
publication_name |
出版物(Newsletter)名称。 |
publication_url |
出版物链接。 |
like_count |
点赞数。 |
comment_count |
评论数。 |
repost_count |
转发数(区别于引用转发)。 |
word_count |
正文字数。 |
post_type |
内容类型(newsletter/podcast/thread 等)。 |
audience |
受众范围(everyone/paid 等)。 |
is_paid |
是否为付费内容。 |
image_url |
图片链接。 |
posted_at |
发布时间,ISO 8601 格式、UTC 时区(如 2026-08-07T12:34:56+00:00)。 |
updated_at |
更新时间。 |
platform |
数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。 |
| 字段 | 含义 |
|---|---|
id |
该记录在原平台上的唯一标识。 |
url |
该记录在原平台上的可访问链接。 |
title |
标题。 |
subtitle |
副标题。 |
text |
正文内容,已去除 HTML 标签,全文返回、不截断(个别平台的列表结果本身只有摘要,以该平台的字段说明为准)。 |
author_name |
作者昵称(显示名)。 |
author_username |
作者用户名(@handle),通常可用于拼 URL。 |
publication_name |
出版物(Newsletter)名称。 |
publication_url |
出版物链接。 |
like_count |
点赞数。 |
comment_count |
评论数。 |
repost_count |
转发数(区别于引用转发)。 |
word_count |
正文字数。 |
post_type |
内容类型(newsletter/podcast/thread 等)。 |
audience |
受众范围(everyone/paid 等)。 |
is_paid |
是否为付费内容。 |
image_url |
图片链接。 |
posted_at |
发布时间,ISO 8601 格式、UTC 时区(如 2026-08-07T12:34:56+00:00)。 |
updated_at |
更新时间。 |
platform |
数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。 |
| 字段 | 含义 |
|---|---|
id |
该记录在原平台上的唯一标识。 |
text |
正文内容,已去除 HTML 标签,全文返回、不截断(个别平台的列表结果本身只有摘要,以该平台的字段说明为准)。 |
author_name |
作者昵称(显示名)。 |
author_username |
作者用户名(@handle),通常可用于拼 URL。 |
like_count |
点赞数。 |
is_reply |
是否为回复(Notes 场景)。 |
is_pinned |
是否置顶。 |
is_author |
评论者是否为文章作者本人。 |
posted_at |
发布时间,ISO 8601 格式、UTC 时区(如 2026-08-07T12:34:56+00:00)。 |
platform |
数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。 |
reply_to_id |
被回复内容的 ID。 |
调用时要不要提供 Substack 账号或 Cookie?
不用,请求头带 Authorization: Bearer 和 API Key 就能调,请求体写 platform、action 和能力参数。不用扫码、维护登录状态,也不用开浏览器。
怎么收费?失败了收不收钱?有免费额度吗?
按调用次数计费,每千次 $1.39 起。失败、空结果、参数错误和鉴权失败都不收费。新账号有 $1 试用额度,24 小时内有效,不用信用卡,领取方式见定价页 https://everyinfra.com/pricing?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
能把 Substack 接口接进 Claude、Cursor 吗?
能,远程 MCP 地址是 https://api.everyinfra.com/mcp,请求头加 Authorization: Bearer 和 API Key,不用装本地程序。Claude、Cursor、ChatGPT、Claude Code 配置见 https://everyinfra.com/mcp-server?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api。Agent 能自己搜 Substack 内容、读评论、查账号。
用 Substack 数据要注意哪些合规问题?
EveryInfra 服务条款要求你自行确保数据用法符合适用法律和相关平台条款,禁止用于违法、侵犯隐私或知识产权,或批量抓取用于骚扰、欺诈等恶意用途。用到昵称、头像等个人信息时,只留业务用得上的字段。
可以拿到 Substack 的哪些数据?
Substack 有 7 个能力:关键词搜索、出版物或专栏、出版物文章、单条内容、评论、主页或对象详情、文章与笔记列表。每个能力的参数和返回字段见平台页 https://everyinfra.com/substack-api?utm_source=github&utm_medium=example_repo&utm_campaign=substack-api
发布前用本仓的代码对线上接口跑过一遍,命令就是「快速开始」里的 5 条。
| 命令 | 时间(新加坡时间) | 返回条数 | 扣费 |
|---|---|---|---|
python main.py search technology --out newsletters.csv |
2026-11-29 19:15 | 10 | $0.001389 |
python main.py newsletter https://astralcodexten.substack.com |
2026-11-29 19:15 | 1 | $0.001389 |
python main.py posts https://astralcodexten.substack.com --out posts.csv |
2026-11-29 19:15 | 10 | $0.001389 |
python main.py post "<文章链接>" --out post.json |
2026-11-29 19:15 | 1 | $0.001389 |
python main.py comments "<文章链接>" --out comments.csv |
2026-11-29 19:16 | 20 | $0.001389 |
post 返回的一条(正文截到 60 字,作者字段没放进来):
{
"id": 225306079,
"title": "Open Thread 460",
"like_count": 65,
"comment_count": 510,
"repost_count": 5,
"word_count": 108,
"posted_at": "2026-11-17T06:30:03.490000+00:00",
"updated_at": "2026-11-17T06:30:08.378000+00:00"
}EveryInfra LLC · 30 N Gould St, Ste N, Sheridan, WY 82801, USA · +1 (307) 418-3419 · everyinfra.com
MIT