API reference · Substack

substack/posts

Integrate this model through SandBase's unified API, with production-ready schemas and examples.

APISynchronousOpen model
Production endpoint

Send your first request

OpenAI-compatible endpoint with unified authentication and usage tracking.

POSThttps://api.sandbase.ai/v1/api/substack/posts
Model IDsubstack/posts
01

Input Schema

12 parameters · 1 required · 11 optional

ParameterTypeRequiredDescription
urlstringRequiredEither 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).
limitintegerOptionalMaximum 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
endDatestringOptionalOnly 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.
onlyFreebooleanOptionalReturn only free (non-paywalled) posts (e.g. true). · Default: false
startDatestringOptionalOnly 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.
contentTypestringOptionalRestrict to a single post type, or 'all' (e.g. newsletter). · Options: all, newsletter, podcast, thread · Default: "all"
allnewsletterpodcastthread
maxCommentsintegerOptionalMaximum comments collected per post when 'includeComments' is true (0-500, default 20). Costs nothing extra (e.g. 50). · Min: 0 · Max: 500
minCommentsintegerOptionalOnly return posts with at least this many comments (e.g. 10). · Min: 0
minReactionsintegerOptionalOnly return posts with at least this many reactions (e.g. 100). · Min: 0
minWordCountintegerOptionalOnly return posts with at least this many words, which filters out short notes and announcements (e.g. 1000). · Min: 0
includeContentbooleanOptionalInclude the full article body as text, HTML and Markdown. Set false for metadata only, which is faster (e.g. false). · Default: true
includeCommentsbooleanOptionalInclude public comment threads and their direct replies on each post (e.g. true). · Default: false
02

Output Schema

FieldTypeDescription
idstringUnique identifier for the generation task
statusstringTask status: pending, running, completed, failed, timeout
modelstringModel used for the generation
outputsarrayArray of output items
outputs[].urlstringURL of the generated artifact
outputs[].content_typestringMIME type (e.g. image/png, video/mp4)
errorobject | nullError details if failed, null on success
error.typestringMachine-readable error type code
error.messagestringHuman-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());