# Substack Scraper: Posts, Full Text & Newsletters (AI-Ready) (`datafaro/substack-scraper`) Actor

Get the latest posts from any Substack newsletter (custom domains too), one post as clean markdown, or publication info. Likes, comments, word count and paywall flag included. Small flat JSON plus a one-line summary, built for AI agents via MCP. Public data only, paywalls respected.

- **URL**: https://apify.com/datafaro/substack-scraper.md
- **Developed by:** [Datafaro](https://apify.com/datafaro) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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 Scraper: Posts, Full Text & Newsletters (AI-Ready)

Get the **latest posts from any Substack newsletter**, **one post as clean markdown**, or **publication info**, as small flat JSON built for AI agents (Claude, ChatGPT, MCP clients) and for research pipelines.

- Works with **any Substack publication**: `name`, `name.substack.com`, any URL on it, or a **custom domain** (`www.lennysnewsletter.com`).
- **Likes, comments, word count and a paywall flag** on every post.
- **Full text as clean markdown** (no HTML, no Substack buttons or widgets) when you want it, a ~300-character excerpt when you don't.
- **A one-line summary** plus all items in a single `OUTPUT` record, so an agent's `run-sync` call gets one compact answer.
- **Public data only. Paywalls are respected**: paid posts return the free preview Substack shows every visitor, flagged `isPaywalled: true`.
- No login, no cookies, no proxy. Typical run: **3 publications in under 5 seconds**.

### What can it do?

| Mode | You give | You get |
|---|---|---|
| `latest_posts` (default) | 1–20 publications | Their newest posts (up to 100 each), optionally since a date, optionally with full text |
| `post` | One post URL | That post with its full public text as markdown |
| `publication` | 1–20 publications | Name, author, description, custom domain, language, paid plans, creation date, newest post date |

### Input

All fields are optional. With an empty input `{}`, the Actor returns the latest posts of two sample publications, so you can see the output format right away.

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | string | `latest_posts` | `latest_posts`, `post` or `publication` |
| `publications` | string\[] | `[]` | 1–20 publications: `simonw`, `simonw.substack.com`, `https://simonw.substack.com/p/…`, or `www.lennysnewsletter.com` |
| `postUrl` | string | `""` | `post` mode: `https://name.substack.com/p/slug`, a custom-domain `/p/` link, or an `open.substack.com` / `substack.com` share link |
| `since` | string | `""` | `latest_posts`: only posts on or after this UTC date (`YYYY-MM-DD`) |
| `maxItemsPerPublication` | integer | `10` | `latest_posts`: 1–100 newest posts per publication |
| `includeFullText` | boolean | `false` | `latest_posts`: add the full public text as markdown in `text` |

Invalid input never crashes: the run fails with a message that says what to send instead (e.g. `mode "post" needs "postUrl", e.g. "https://simonw.substack.com/p/<post-slug>"`). Fields a mode doesn't use are ignored with a warning.

#### Examples

Latest 5 posts from three newsletters (one on a custom domain):

```json
{ "publications": ["simonw", "www.lennysnewsletter.com", "garymarcus"], "maxItemsPerPublication": 5 }
```

Everything a newsletter published since 1 November, with full text:

```json
{ "publications": ["www.oneusefulthing.org"], "since": "2026-11-01", "maxItemsPerPublication": 100, "includeFullText": true }
```

One post as markdown:

```json
{ "mode": "post", "postUrl": "https://simonw.substack.com/p/running-python-code-in-a-sandbox" }
```

Publication info:

```json
{ "mode": "publication", "publications": ["lenny", "simonw"] }
```

### Output

Each post is one flat dataset item:

```json
{
  "publication": "www.lennysnewsletter.com",
  "title": "State of the tech job market: late 2026",
  "subtitle": "PMs are winning, engineers are plateauing, designers are hurting, …",
  "url": "https://www.lennysnewsletter.com/p/state-of-the-tech-job-market-late",
  "author": "Lenny Rachitsky",
  "publishedAt": "2026-11-10T15:04:03Z",
  "isPaywalled": true,
  "wordCount": 2183,
  "excerpt": "👋 Hey there, I’m Lenny. Each week, I share deeply researched product, growth, and career advice. …",
  "text": null,
  "likes": 404,
  "comments": 42
}
```

- `text` is filled only with `includeFullText: true` (and always in `post` mode). It is clean markdown.
- `isPaywalled: true` means the full post needs a subscription; `text` and `excerpt` then hold only the free preview. `wordCount` is the full length.
- `likes`, `comments`, `wordCount` and `isPaywalled` come from Substack's own web API. If that is unavailable, the posts still come back from RSS with those fields `null` and a warning in `OUTPUT.warnings`.

A publication item (`publication` mode):

```json
{
  "publication": "www.lennysnewsletter.com",
  "name": "Lenny's Newsletter",
  "author": "Lenny Rachitsky",
  "description": "Deeply researched product, growth, and career advice for product leaders, founders, and ambitious builders.",
  "url": "https://www.lennysnewsletter.com",
  "substackUrl": "https://lenny.substack.com",
  "customDomain": "www.lennysnewsletter.com",
  "language": "en",
  "hasPaidSubscriptions": true,
  "createdAt": "2019-06-01T15:35:37Z",
  "latestPostAt": "2026-11-17T18:02:02Z",
  "postCount": null
}
```

An unknown publication or post becomes a **free** error item, and the run continues with the others:

```json
{ "input": "nosuchpub", "publication": "nosuchpub.substack.com", "error": "Publication not found" }
```

#### The `OUTPUT` record (for agents)

The default key-value store's `OUTPUT` holds everything in one JSON:

```json
{
  "summary": "15 posts from 3 publications, newest 2026-11-17; 2 paywalled (preview only)",
  "request": { "mode": "latest_posts", "publications": ["simonw.substack.com", "www.lennysnewsletter.com", "garymarcus.substack.com"], "since": null, "maxItemsPerPublication": 5, "includeFullText": false },
  "counts": { "ok": 15, "errors": 0 },
  "complete": true,
  "items": [ … ]
}
```

`complete: false` with a summary starting `PARTIAL:` means part of the request came back incomplete, and the summary says what: a publication Substack failed to serve (also in `error`), or posts missing engagement data or full text because Substack rate-limited its post API (e.g. `PARTIAL: 32 of 80 posts missing engagement data; …`, counts in `missingData`). What was fetched is still returned. If nothing at all could be fetched, the run **fails** with a clear message. It never reports an empty success.

### Speed

- A typical run (a few publications, `maxItemsPerPublication` ≤ 10) finishes in a few seconds.
- **Large full-text runs can take 1–2 minutes.** Substack rate-limits bursts of requests, and older posts' full text needs one request per post. The Actor waits the limit out instead of returning incomplete data.
- **For fast agent use, keep `maxItemsPerPublication` ≤ 10** (the default). Most AI agents wait about 30 seconds for an answer.

### Pricing

Pay per result: **$1.00 per 1,000 results** (a post or a publication), full text and engagement data included. There is no start fee beyond Apify's $0.00005 synthetic start event. Error items are free.

| Request | Results | Cost |
|---|---|---|
| Latest 10 posts of 3 newsletters | 30 | $0.03 |
| One post as markdown | 1 | $0.001 |
| 100 posts with full text | 100 | $0.10 |

Set a maximum charge per run in the Apify Console; the Actor stops cleanly when it is reached.

### Use with Claude / MCP

Add this Actor as a tool to Claude Desktop, Claude Code, Cursor or any MCP client through Apify's MCP server:

```
https://mcp.apify.com/?tools=datafaro/substack-scraper
```

Keep `maxItemsPerPublication` at 10 or less for quick answers. Then ask, for example: *"What did Simon Willison and Ethan Mollick write about this week? Summarize the main points."* The input fields have one-line descriptions written for LLMs, and `OUTPUT.summary` gives the agent a one-line answer before it reads the items.

Over the API (synchronous, returns `OUTPUT`):

```bash
curl -X POST "https://api.apify.com/v2/acts/datafaro~substack-scraper/run-sync?token=$APIFY_TOKEN&outputRecordKey=OUTPUT" \
  -H 'Content-Type: application/json' \
  -d '{"publications": ["simonw"], "maxItemsPerPublication": 3}'
```

### FAQ

**Where does the data come from?** Each publication's public RSS feed (`<publication>/feed`), which Substack publishes for machine reading, plus the public JSON that Substack's own website loads for engagement counts and older posts. No login, no cookies.

**Do you bypass paywalls?** No. Paid posts return only what any visitor sees without subscribing (title, subtitle, free preview, metadata) and are flagged `isPaywalled: true`.

**How far back can I go?** Up to 100 posts per publication per run. The newest ~20 come from RSS; older ones come from the publication archive. Posts filed under a publication's *sections* (for example some podcast series) appear only while they are among the newest ~20.

**Does it work with custom domains?** Yes: give the domain (`www.lennysnewsletter.com`) or the `name.substack.com` address; both resolve to the same publication. A bare domain that only exists on `www.` is retried there automatically.

**Why is `postCount` null?** Substack doesn't publish a total post count. The field is kept for a future version.

**What is not included (yet)?** Comment text, subscriber counts, search across all of Substack, Notes, podcasts/video files, and anything behind a login.

**Is scraping Substack legal?** This Actor reads only public, non-personal data that Substack serves to every visitor and via RSS. You are responsible for how you use it: respect the authors' copyright when republishing text.

**Something broke?** The Actor runs a self-test every day across all modes. If you hit a problem, open an issue on the Actor's Issues tab with the run link.

# Actor input Schema

## `mode` (type: `string`):

What to fetch: latest_posts (newest posts of 1-20 publications), post (one post by URL, with full public text as markdown), publication (name, author, description and details of 1-20 publications).

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

latest_posts, publication. 1 to 20 Substack publications as a name ("simonw"), name.substack.com, any URL on it, or a custom domain ("www.lennysnewsletter.com"). If empty, two sample publications are used.

## `postUrl` (type: `string`):

post only. A post link like https://name.substack.com/p/post-slug, a custom-domain /p/ link, or an open.substack.com / substack.com share link.

## `since` (type: `string`):

latest_posts only. Only posts published on or after this UTC date, YYYY-MM-DD. Empty = no date limit.

## `maxItemsPerPublication` (type: `integer`):

latest_posts only. Newest posts to return per publication, 1 to 100. You pay only for posts returned.

## `includeFullText` (type: `boolean`):

latest_posts only. Add each post's full public text as clean markdown in "text" (bigger output). Off = title, subtitle and a ~300-character excerpt. Paywalled posts only ever include the free preview. Mode post always includes text.

## `selfTest` (type: `boolean`):

Operator setting: ignore other fields, run a fixed health check across all modes, never charge, and fail the run if anything breaks.

## Actor input object example

```json
{
  "mode": "latest_posts",
  "publications": [
    "simonw",
    "www.lennysnewsletter.com"
  ],
  "postUrl": "",
  "since": "",
  "maxItemsPerPublication": 10,
  "includeFullText": false,
  "selfTest": false
}
```

# Actor output Schema

## `output` (type: `string`):

No description

## `results` (type: `string`):

No description

# 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": [
        "simonw",
        "www.lennysnewsletter.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("datafaro/substack-scraper").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": [
        "simonw",
        "www.lennysnewsletter.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("datafaro/substack-scraper").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": [
    "simonw",
    "www.lennysnewsletter.com"
  ]
}' |
apify call datafaro/substack-scraper --silent --output-dataset

```

## MCP server setup

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

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/Fx1j0iD02eaV34UFx/builds/dfxsHJMYjw23bRAnU/openapi.json
