API reference · Substack
substack/posts
Integrate this model through SandBase's unified API, with production-ready schemas and examples.
Production endpoint
Send your first request
OpenAI-compatible endpoint with unified authentication and usage tracking.
POST
https://api.sandbase.ai/v1/api/substack/postsModel ID
substack/posts01
Input Schema
12 parameters · 1 required · 11 optional
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Required | Either a Substack publication URL / custom domain to fetch its recent posts (e.g. https://www.astralcodexten.com), OR a single post URL to fetch just that one article with full content (e.g. https://www.astralcodexten.com/p/your-book-review). |
limit | integer | Optional | Maximum number of recent posts to return when given a publication URL (1-100, default 25); ignored for a single post URL, which always returns that one post. You are billed per post returned, so a lower limit costs less. · Min: 1 · Max: 100 |
endDate | string | Optional | Only return posts published on or before this date, format YYYY-MM-DD (e.g. 2024-12-31). Applied within the most recent 'limit' posts scanned. |
onlyFree | boolean | Optional | Return only free (non-paywalled) posts (e.g. true). · Default: false |
startDate | string | Optional | Only return posts published on or after this date, format YYYY-MM-DD (e.g. 2024-01-01). Applied within the most recent 'limit' posts scanned, so raise 'limit' to reach older date ranges. |
contentType | string | Optional | Restrict to a single post type, or 'all' (e.g. newsletter). · Options: all, newsletter, podcast, thread · Default: "all" allnewsletterpodcastthread |
maxComments | integer | Optional | Maximum comments collected per post when 'includeComments' is true (0-500, default 20). Costs nothing extra (e.g. 50). · Min: 0 · Max: 500 |
minComments | integer | Optional | Only return posts with at least this many comments (e.g. 10). · Min: 0 |
minReactions | integer | Optional | Only return posts with at least this many reactions (e.g. 100). · Min: 0 |
minWordCount | integer | Optional | Only return posts with at least this many words, which filters out short notes and announcements (e.g. 1000). · Min: 0 |
includeContent | boolean | Optional | Include the full article body as text, HTML and Markdown. Set false for metadata only, which is faster (e.g. false). · Default: true |
includeComments | boolean | Optional | Include public comment threads and their direct replies on each post (e.g. true). · Default: false |
02
Output Schema
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the generation task |
status | string | Task status: pending, running, completed, failed, timeout |
model | string | Model used for the generation |
outputs | array | Array of output items |
outputs[].url | string | URL of the generated artifact |
outputs[].content_type | string | MIME type (e.g. image/png, video/mp4) |
error | object | null | Error details if failed, null on success |
error.type | string | Machine-readable error type code |
error.message | string | Human-readable error description |
03
Code Examples
Ready-to-run snippets
const apiKey = process.env.SANDBASE_API_KEY;
const response = await fetch("https://api.sandbase.ai/v1/api/substack/posts", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"url": "https://www.astralcodexten.com",
"limit": 3,
"onlyFree": false,
"contentType": "all",
"includeContent": true,
"includeComments": false
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());