# Substack Posts API - Newsletter Archive, Likes & Authors (`stas_k/substack-posts-api`) Actor

A publication that does not exist should never look like a paid row. Send a Substack host or subdomain and get title, subtitle, url, date, authors, likes, comments and word count; a host that never answered comes back free with the reason.

- **URL**: https://apify.com/stas_k/substack-posts-api.md
- **Developed by:** [Stas K](https://apify.com/stas_k) (community)
- **Categories:** Social media, Developer tools, SEO tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.30 / 1,000 posts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Substack Posts API - Newsletter Archive, Likes and Authors

A publication that does not exist should never look like a paid row. Send a Substack host
or subdomain, get its posts back, and a host that never answered comes back free with the
reason instead of an empty row and a charge.

### What it returns

One row per post:

- `publication`, `postId`, `title`, `subtitle`, `url`, `publishedAt`, `authors` (a list of
  byline names), `section`, `type`, `audience`, `likes` (`reaction_count` as the archive
  reports it), `comments`, `wordCount`, `language`, `coverImage`, `description`;
- `previewText` when `includeBodyText` is on: the public preview the archive returns for
  every post. The full body is not in the archive answer and is not sold.

Every other row is a status row: `actorInput`, `actorIndex`, `status`, `reason`,
`billable: false`, and no post fields at all. A free row cannot be mistaken for data.

### Input

`publications` is a list: a custom domain such as `www.thefp.com`, a full url, or a bare
subdomain such as `platformer`, which becomes `platformer.substack.com`. `maxPostsPerPublication`
is 1 to 500 and defaults to 50. `includeBodyText` adds the preview text.

### What is free and what is charged

Charged once per post that was actually delivered:

- a publication the source does not know (HTTP 404) comes back `NOT_FOUND` and free. A
  custom domain that answers 404 is tried once as `<label>.substack.com` before that
  verdict, and a redirect is followed, because a copied address is often not the address
  the archive lives on. A redirect that leaves public https, or points to a path only,
  closes that road and the substack road is tried instead, so it is never called a
  network error;
- a host that does not resolve, a timeout, or a refusal (401, 403, 429, 5xx) comes back
  `NOT_CHECKED_ERROR` with the reason in words, and free;
- a host that is not a host at all (`not a host`) comes back `INVALID_INPUT` and free;
- the same publication sent twice, or the same post seen twice, comes back `DUPLICATE`
  and free. A Substack post id is unique across the platform, so a post that appears in
  two of the publications of one run is delivered once;
- a publication that published nothing is a successful run with zero rows sold, not a
  failure: it gets one free `EMPTY` row saying that the archive answered normally and holds
  no post, and the run summary counts it in `publicationsEmpty`.

When the run is stopped by the clock, by the spending limit or by an unreadable price,
the remaining publications get a status row naming which of those stopped the run, and they
are free. Posts past `maxPostsPerPublication` are simply not read: nothing is claimed about
them.

### Money, honestly

The price is per delivered post; see the Price section of the card. The lowest spending
limit you can set per run is $0.05, and a run of 20 posts stays well under it.

The archive answer is what it is: the archive gives a preview of the body, not the whole
post. If a post arrives without an id it is not sold; the row says so and is free.

### What this actor does not do

- It does not read the full text of an article: the archive endpoint does not carry it.
- It does not read paid-only posts behind a subscription: it sees what a visitor sees.
- It does not search Substack for a topic. It reads the archive of the publications you
  name, and nothing else.

### Source

Substack's own public archive endpoint, `https://<publication>/api/v1/archive`. No key, no
account, no proxy, and no browser: one GET per page, 25 posts per page, newest first. The
endpoint answers HTTP 400 to a bigger `limit`, so 25 is the page and a default of 50 posts
is read as two pages.

### Notes on counters

The run summary reports `requested`, `publicationsRead`, `publicationsFailed`,
`publicationsNotFound`, `publicationsEmpty`, `postsSeen`, `postsDelivered`, `rowsWritten`,
`chargedEvents`, `deliveredUncharged`, `deliveredUnverified`, `chargeUncertain`,
`writeErrors`, `byStatus`, `counterMismatch`, `billingActive`, `stopReason`, `datasetNote`
and `firstFailure`.
The summary lands in the default key-value store twice: as `RUN_SUMMARY-<runId>` and as
`RUN_SUMMARY`.

A paid write and its charge happen in one call. If that call raises, the dataset counter is
read again (three times, taking the maximum) to tell a refused write from a failed charge.
When the counter cannot be read, the summary says that delivery and the charge are both
unknown instead of claiming that nothing happened.

# Actor input Schema

## `publications` (type: `array`):

Substack publications: a host such as www.thefp.com or a bare subdomain such as platformer.

## `maxPostsPerPublication` (type: `integer`):

How many posts to sell per publication. Default 50, maximum 500.

## `includeBodyText` (type: `boolean`):

Add the public preview text the archive returns for every post. Off by default.

## Actor input object example

```json
{
  "publications": [
    "www.thefp.com",
    "platformer.substack.com"
  ],
  "maxPostsPerPublication": 50,
  "includeBodyText": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

One row per post. Paid rows carry the post fields and billable true; every other row is a free status row with a reason and no post data.

## `summary` (type: `string`):

Counters of the run: requested, postsDelivered, rowsWritten, chargedEvents, deliveredUncharged, deliveredUnverified, chargeUncertain, writeErrors, publicationsEmpty, byStatus, counterMismatch, billingActive, stopReason, datasetNote and firstFailure. It also lands in the default store as RUN_SUMMARY.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "publications": [
        "www.thefp.com",
        "platformer.substack.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("stas_k/substack-posts-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "publications": [
        "www.thefp.com",
        "platformer.substack.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("stas_k/substack-posts-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "publications": [
    "www.thefp.com",
    "platformer.substack.com"
  ]
}' |
apify call stas_k/substack-posts-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,stas_k/substack-posts-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/kxN9Rw1upLyb9dXhn/builds/gC9ONJA9i7gKhieOG/openapi.json
