# Substack Newsletter, Archive & Comments Scraper (`pulse_extract/substack-newsletter-scraper`) Actor

Extract Substack newsletter posts, full clean text/Markdown content, engagement metrics, and comments from any publication or custom domain using Substack's cursor-paginated JSON API.

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

## Pricing

from $1.20 / 1,000 substack post returneds

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 Newsletter, Archive & Comments Scraper

Extract complete **Substack** newsletter archives, full clean article text, RAG-ready Markdown, engagement metrics (`reactionCount`, `commentCount`, `restacks`), and post comments from **any Substack publication**, **custom domain** (like `lennysnewsletter.com`), **single-post URL**, or **global keyword search**.

Unlike legacy scrapers breaking with HTTP 400 on Substack's retired `offset=` parameter, this Actor uses Substack's **2026 `nextCursor` pagination API** — running purely over fast HTTP/2 with zero browser and zero proxy costs.

***

### Key Features

- **Works Across All Substack Formats:** Custom domains (`https://www.lennysnewsletter.com`), `*.substack.com` subdomains, bare publication handles (`lennysnewsletter`), single post URLs (`/p/slug`), and global keyword searches (`searchQueries`).
- **2026 Cursor Pagination:** Paginates deep archives smoothly via `nextCursor` without HTTP 400 offset errors.
- **RAG & AI-Ready Markdown:** Strips subscribe/widget clutter cleanly and converts headings, lists, blockquotes, and code blocks into structured `contentMarkdown` alongside plain `contentText`.
- **Optional Comment Extraction:** Enable `includeComments: true` to fetch reader comments (`commentId`, `authorName`, `date`, `body`, `reactionCount`).
- **Pre-Push Filtering:** Filter by `audienceFilter` (`everyone` vs `only_paid`), `publishedWithinDays`, and `keywords` before records are pushed and billed.

***

### Example Input

```json
{
  "publications": [
    "https://www.lennysnewsletter.com",
    "https://newsletter.pragmaticengineer.com"
  ],
  "searchQueries": [],
  "sortBy": "new",
  "maxPostsPerSource": 20,
  "includeContent": true,
  "includeComments": false,
  "maxCommentsPerPost": 20,
  "keywords": [],
  "audienceFilter": "all",
  "publishedWithinDays": 0
}
```

***

### Example Output Item

```json
{
  "sourceInput": "https://www.lennysnewsletter.com",
  "publicationDomain": "www.lennysnewsletter.com",
  "publicationName": "www.lennysnewsletter.com",
  "postId": 224972682,
  "slug": "35-premium-tools-free-for-a-yearnow",
  "title": "35 premium tools free for a year",
  "subtitle": "...",
  "postType": "newsletter",
  "audience": "everyone",
  "isPaywalled": false,
  "publishedAt": "2026-11-17T18:02:02.477Z",
  "authors": ["Lenny Rachitsky"],
  "tags": [],
  "wordCount": 1752,
  "reactionCount": 208,
  "commentCount": 12,
  "restacks": 15,
  "canonicalUrl": "https://www.lennysnewsletter.com/p/35-premium-tools-free-for-a-yearnow",
  "coverImageUrl": "https://substackcdn.com/...",
  "contentText": "...",
  "contentMarkdown": "## ...",
  "scrapedAt": "2026-11-19T03:25:00+00:00"
}
```

***

### Pricing & Billing Transparency

This Actor uses **Pay-Per-Event (PPE)** billing:

- **Actor Start:** `$0.00005` per run.
- **Per Post Returned (`post-scraped`):** `$0.0012` per post (`$1.20 per 1,000 posts`).
- **Optional Comments (`comment-scraped`):** `$0.0004` per extracted comment (only charged when `includeComments` is `true`).

***

### Use Cases & Integrations

- **AI Knowledge Bases & Competitive Research:** Ingest full `contentMarkdown` archives of top industry newsletters into vector databases via **n8n**, **Make**, or **LangChain**.
- **Trend & Audience Monitoring:** Run weekly with `publishedWithinDays: 7` and `includeComments: true` to spot high-engagement topics and reader pain points.
- **AI Agents & MCP:** Connect through Apify's MCP server so Claude or Cursor can query newsletter insights cleanly.

***

### FAQ

**Can this bypass paid subscriber paywalls?**\
No. It extracts all public metadata and free preview/article bodies returned by Substack's public API; paywalled posts report `isPaywalled: true` and any public preview text.

# Actor input Schema

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

Accepts custom domains (https://www.lennysnewsletter.com), \*.substack.com URLs, bare handles (lennysnewsletter), or direct single-post URLs (https://.../p/slug).

## `searchQueries` (type: `array`):

Optional keywords to search across all public Substack posts.

## `sortBy` (type: `string`):

Sort publication archives by newest or top posts.

## `maxPostsPerSource` (type: `integer`):

Maximum number of posts to extract per publication URL or search query.

## `includeContent` (type: `boolean`):

Fetch each post's full HTML body and convert it into clean contentText and RAG-ready contentMarkdown.

## `includeComments` (type: `boolean`):

Fetch top comments for each post (triggers optional comment-scraped PPE billing per extracted comment).

## `maxCommentsPerPost` (type: `integer`):

Maximum comments extracted per post when Include Post Comments is enabled.

## `keywords` (type: `array`):

Keep posts matching at least one keyword (case-insensitive) in title, subtitle, or content.

## `audienceFilter` (type: `string`):

Filter posts by free ('everyone') vs paid-subscriber ('only_paid') access.

## `publishedWithinDays` (type: `integer`):

Keep only posts published within the last N days. Set to 0 to disable date filtering.

## Actor input object example

```json
{
  "publications": [
    "https://www.lennysnewsletter.com",
    "https://newsletter.pragmaticengineer.com"
  ],
  "searchQueries": [],
  "sortBy": "new",
  "maxPostsPerSource": 20,
  "includeContent": true,
  "includeComments": false,
  "maxCommentsPerPost": 20,
  "keywords": [],
  "audienceFilter": "all",
  "publishedWithinDays": 0
}
```

# Actor output Schema

## `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": [
        "https://www.lennysnewsletter.com",
        "https://newsletter.pragmaticengineer.com"
    ]
};

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pulse_extract/substack-newsletter-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/GakuX5TFZwMBAj9XK/builds/CLvaYUMd0urojyRQe/openapi.json
