Substack Posts
Recent posts of any Substack publication (or one post by URL): metadata, paywall status, engagement, author and the article body as HTML, Markdown and text.
- Price per call
- 1 credit
- per successful call
- Price ceiling
- 19 credits
- if a call is retried elsewhere
- Failed calls
- Free
- retried automatically
- Billed
- Per call
- only on success
Endpoint
api.primaryapi.com/ v1/ run/ substack. postsAuth: API key with run or full access, or a dashboard session
Send the input below as a JSON body. The call is routed to a healthy upstream; if an attempt fails, it is retried automatically inside the same request and you pay only for the answer you get. To check an input and see the exact price without running anything, call POST /v1/quote/substack.posts with the same body (free).
Example request
curl -sS -X POST "https://api.primaryapi.com/v1/run/substack.posts" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://thezvi.substack.com","limit":5}'const res = await fetch('https://api.primaryapi.com/v1/run/substack.posts', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://thezvi.substack.com',
limit: 5,
}),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.code}: ${body.error}`);
// found:false is a successful answer ("does not exist"), not an error
console.log(body.output.found ? body.output.data : body.output.reason, body.credits);import os
import requests
res = requests.post(
"https://api.primaryapi.com/v1/run/substack.posts",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={
"url": "https://thezvi.substack.com",
"limit": 5,
},
timeout=60,
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{body['code']}: {body['error']}")
# found=False is a successful answer ("does not exist"), not an error
print(body["output"]["data"] if body["output"]["found"] else body["output"]["reason"], body["credits"]){
"name": "run_api",
"arguments": {
"sku": "substack.posts",
"input": {
"url": "https://thezvi.substack.com",
"limit": 5
}
}
}Price this exact input first (free)
curl -sS -X POST "https://api.primaryapi.com/v1/quote/substack.posts" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://thezvi.substack.com","limit":5}'Returns credits (what the call is expected to cost) and maxCredits (the most it can cost, which is set aside while it runs). Invalid input fails here the same way it would on run.
Input
JSON body fields. Unknown fields are rejected with 400 invalid_input (never silently ignored). You may add the routing controls preferLatencyUnderMs and maxCredits to the same object.
urlstringrequired- A Substack publication URL or custom domain to list its recent posts (e.g. https://thezvi.substack.com or https://www.astralcodexten.com), OR a single post URL (…/p/<slug>) to fetch just that article.max 2048 chars
limitintegerdefault25- Maximum number of recent posts to scan for a publication URL (1-100, default 25); ignored for a single post URL. Billed per post returned.1–100
contentTypeenumdefault"all"- Restrict to one post type, or 'all'.one of: all, newsletter, podcast, thread
includeContentbooleandefaulttrue- Include the article body as HTML, Markdown and text. Set false for metadata only (faster).
includeCommentsbooleandefaultfalse- Include public comment threads with their direct replies on each post.
maxCommentsintegerdefault20- Maximum comments (top-level + direct replies) per post when includeComments is true (0-500, default 20; 0 = none). No extra charge.0–500
minCommentsinteger- Only return posts with at least this many comments.≥ 0
minReactionsinteger- Only return posts with at least this many reactions.≥ 0
minWordCountinteger- Only return posts with at least this many words (filters out short notes).≥ 0
onlyFreebooleandefaultfalse- Return only free (non-paywalled) posts.
startDatestring- Only posts published on or after this date (YYYY-MM-DD), applied within the most recent `limit` posts scanned.pattern: ^\d{4}-\d{2}-\d{2}$
endDatestring- Only posts published on or before this date (YYYY-MM-DD), applied within the most recent `limit` posts scanned.pattern: ^\d{4}-\d{2}-\d{2}$
Output
When output.found is true, output.data has these fields (a list under items, billed per item returned).
itemsobject[]items[].postIdstring | null- Substack post id
items[].titlestring | nullitems[].subtitlestring | nullitems[].slugstring | nullitems[].urlstringitems[].createdUtcinteger | null- Publication time, UTC epoch seconds
items[].updatedUtcinteger | nullitems[].descriptionstring | nullitems[].imagestring | null- Cover image URL
items[].postTypestring | null- newsletter | podcast | thread
items[].isPaidboolean | null- true when the post is restricted to paying subscribers
items[].contentStatusenum- full body · truncated (paywalled preview) · feed (as published in RSS) · unavailable · omitted (includeContent=false)one of: full, truncated, feed, unavailable, omitted
items[].wordcountinteger | nullitems[].reactionCountinteger | nullitems[].commentCountinteger | nullitems[].restackCountinteger | nullitems[].authorNamestring | nullitems[].authorHandlestring | nullitems[].authorImagestring | nullitems[].authorBiostring | nullitems[].authorUrlstring | nullitems[].publicationobjectitems[].publication.idstring | nullitems[].publication.namestring | nullitems[].publication.urlstring | nullitems[].languagestring | nullitems[].htmlstring | nullitems[].markdownstring | nullitems[].textstring | nullitems[].podcastUrlstring | nullitems[].hasVoiceoverboolean | nullitems[].commentsobject[]items[].comments[].idstringitems[].comments[].authorNamestring | nullitems[].comments[].authorHandlestring | nullitems[].comments[].authorImagestring | nullitems[].comments[].textstring | nullitems[].comments[].createdUtcinteger | null- UTC epoch seconds
items[].comments[].reactionCountinteger | nullitems[].comments[].replyCountinteger | nullitems[].comments[].repliesobject[]- Direct replies
items[].comments[].replies[].idstringitems[].comments[].replies[].authorNamestring | nullitems[].comments[].replies[].authorHandlestring | nullitems[].comments[].replies[].authorImagestring | nullitems[].comments[].replies[].textstring | nullitems[].comments[].replies[].createdUtcinteger | null- UTC epoch seconds
items[].comments[].replies[].reactionCountinteger | nullitems[].comments[].replies[].replyCountinteger | nullnextCursorstring | null- Always null (raise `limit` to scan further back)
TypeScript type
/** output.data when output.found is true */
type SubstackPosts = {
items: {
/** Substack post id */
postId: string | null;
title: string | null;
subtitle: string | null;
slug: string | null;
url: string;
/** Publication time, UTC epoch seconds */
createdUtc: number | null;
updatedUtc: number | null;
description: string | null;
/** Cover image URL */
image: string | null;
/** newsletter | podcast | thread */
postType: string | null;
/** true when the post is restricted to paying subscribers */
isPaid: boolean | null;
/** full body · truncated (paywalled preview) · feed (as published in RSS) · unavailable · omitted (includeContent=false) */
contentStatus: "full" | "truncated" | "feed" | "unavailable" | "omitted";
wordcount: number | null;
reactionCount: number | null;
commentCount: number | null;
restackCount: number | null;
authorName: string | null;
authorHandle: string | null;
authorImage: string | null;
authorBio: string | null;
authorUrl: string | null;
publication: {
id: string | null;
name: string | null;
url: string | null;
};
language: string | null;
html: string | null;
markdown: string | null;
text: string | null;
podcastUrl: string | null;
hasVoiceover: boolean | null;
comments: {
id: string;
authorName: string | null;
authorHandle: string | null;
authorImage: string | null;
text: string | null;
/** UTC epoch seconds */
createdUtc: number | null;
reactionCount: number | null;
replyCount: number | null;
/** Direct replies */
replies: {
id: string;
authorName: string | null;
authorHandle: string | null;
authorImage: string | null;
text: string | null;
/** UTC epoch seconds */
createdUtc: number | null;
reactionCount: number | null;
replyCount: number | null;
}[];
}[];
}[];
/** Always null (raise `limit` to scan further back) */
nextCursor: string | null;
};If what you asked about does not exist, is private, or a search matches nothing, the call still succeeds: output.found is false, output.data is null and output.reason says why. Such misses are free unless the notes below say misses are billed, in which case a miss costs the price of one call.
Example response
Values are placeholders that follow the output schema (strings as "string", numbers as 0); credits shows what this call would cost at the usual price.
{
"output": {
"found": true,
"data": {
"items": [
{
"postId": "string",
"title": "string",
"subtitle": "string",
"slug": "string",
"url": "https://thezvi.substack.com",
"createdUtc": 0,
"updatedUtc": 0,
"description": "string",
"image": "string",
"postType": "string",
"isPaid": true,
"contentStatus": "full",
"wordcount": 0,
"reactionCount": 0,
"commentCount": 0,
"restackCount": 0,
"authorName": "string",
"authorHandle": "string",
"authorImage": "string",
"authorBio": "string",
"authorUrl": "https://example.com",
"publication": {
"id": "string",
"name": "string",
"url": "https://thezvi.substack.com"
},
"language": "string",
"html": "string",
"markdown": "string",
"text": "string",
"podcastUrl": "https://example.com",
"hasVoiceover": true,
"comments": [
{
"id": "string",
"authorName": "string",
"authorHandle": "string",
"authorImage": "string",
"text": "string",
"createdUtc": 0,
"reactionCount": 0,
"replyCount": 0,
"replies": [
{
"id": null,
"authorName": null,
"authorHandle": null,
"authorImage": null,
"text": null,
"createdUtc": null,
"reactionCount": null,
"replyCount": null
}
]
}
]
}
],
"nextCursor": null
}
},
"provider": "PrimaryAPI",
"credits": 1,
"items": 1,
"requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
"nextCursor": null
}Pricing and reliability
Calls go only to upstreams that are healthy right now. If an attempt fails, the call is retried automatically inside the same request; a failed attempt costs nothing, and a call never costs more than its quote’s maxCredits. Live figures below are measured on real traffic.
Success rate, uptime, latency and call counts are measured live from real traffic over 30 days and show “—” until there is data.
Errors
Errors are JSON { code, error, requestId } and are never charged. The ones to handle for this endpoint:
- invalid_inputThe request failed validation before anything ran.
- unauthorizedNo valid API key or session was presented.
- insufficient_balanceThe balance cannot cover the most this call could cost.
- key_limit_reachedThe key’s own spend limit is used up for the current window.
- trial_cap_reachedAn agent trial key has used its whole trial budget.
- forbiddenThe credential is valid but may not do this.
- not_foundThe thing addressed by the URL does not exist for you.
- idempotency_conflictThe
Idempotency-Keyis already bound to a different request. - rate_limitedToo many requests in the current window.
- all_sources_failedThe call could not be answered, even after automatic retries.
- service_unavailableThis API cannot run in this deployment right now.
- timeoutThe request passed its deadline before it finished.
Notes
Paid posts only expose the free preview (contentStatus "truncated").
Newsletter bodies are copyrighted by their authors. Only content a logged-out reader can see is returned (paid posts are truncated). Customers must have the rights required for their use.
Generated from the PrimaryAPI catalog. Machine-readable contract: GET https://api.primaryapi.com/v1/apis/substack.posts.