# Substack Scraper — Posts, Markdown, Comments & Leaderboards (`shawn1905/substack-intelligence-scraper`) Actor

Extract Substack posts (clean LLM-ready Markdown & plain text), nested comments, and Bestseller/Rising category leaderboards with custom domain support. Fast pure-HTTP API, no proxies needed, MCP & Clay ready.

- **URL**: https://apify.com/shawn1905/substack-intelligence-scraper.md
- **Developed by:** [FENG LI](https://apify.com/shawn1905) (community)
- **Categories:** News, Lead generation, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 post metadata

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 Intelligence Scraper — Posts, Clean Markdown, Comments & Leaderboards

Fast, lightweight, **no-browser / no-proxy** Substack scraper built for **AI & RAG pipelines, Clay & n8n lead enrichment, market intelligence, and MCP agents**.

Unlike brittle browser scrapers that break on Substack's updated cursor pagination or charge heavy start fees, this Actor speaks directly to Substack's modern public JSON API (`nextCursor` pagination) across **both `*.substack.com` subdomains and custom domains** (e.g., `lennysnewsletter.com`, `blog.bytebytego.com`).

***

### Key Capabilities

1. **Publication Archives (`publication_posts`)**
   - Works with Substack handles (`stratechery`), subdomains, and custom domains (`https://www.lennysnewsletter.com`).
   - Modern cursor pagination (no HTTP 400 pagination crashes).
   - Supports `new` and `top` sorting, `publishedAfter` date cutoff (with early stop), `freeOnly` filter, and keyword filtering.
   - Converts raw HTML into **clean LLM/RAG-ready Markdown** (stripping Substack subscribe widgets and buttons), plain text, reading time, and extracted outbound links.
2. **Direct Post Extraction (`post_urls`)**
   - Pass any list of `/p/<slug>` URLs to get full clean Markdown, structured metadata, paywall flags, tags, author bios, and optional nested comments.
3. **Bestseller & Rising Category Leaderboards (`category_leaderboard`)**
   - Scrape all 35+ Substack categories (`technology`, `finance`, `business`, `culture`, `crypto`, `us-politics`, `sports`, `food`, `news`, etc.).
   - Outputs **Clay / CRM / Sponsorship Outreach ready** flat rows: publication name, custom domain, author name & handle, bestseller tier, subscriber magnitude hint, Twitter handle, support email, podcast RSS feed, and description.
4. **Nested Comments & Replies**
   - Optionally extract threaded comments with `parentCommentId`, `depth`, `reactionCount`, and `isAuthorReply`.

***

### Transparent Pay-Per-Event Pricing (No Start Fee)

| Event | Price | Equivalent per 1,000 items |
| --- | --- | --- |
| **Leaderboard Publication** (`publication-leaderboard-item`) | `$0.001` | `$1.00 / 1K` |
| **Post Metadata Only** (`post-metadata`) | `$0.001` | `$1.00 / 1K` |
| **Post with Full Clean Markdown & Text** (`post-full-content`) | `$0.0015` | `$1.50 / 1K` |
| **Comment / Reply** (`comment-item`) | `$0.0005` | `$0.50 / 1K` |

- **No Actor start fee.**
- **Ultra-low platform compute footprint** (runs cleanly on 256 MB RAM with pure HTTP requests — no residential proxies required).

***

### Input Examples

#### 1. Scrape Latest Posts with Clean Markdown (for AI / RAG / Newsletter Monitoring)

```json
{
  "mode": "publication_posts",
  "publications": [
    "https://www.lennysnewsletter.com",
    "https://blog.bytebytego.com"
  ],
  "sort": "new",
  "maxPostsPerPublication": 25,
  "publishedAfter": "2026-01-01",
  "includeFullContent": true,
  "includeComments": false
}
```

#### 2. Scrape Category Leaderboards (for Clay / n8n B2B Lead Gen & Sponsorships)

```json
{
  "mode": "category_leaderboard",
  "categories": ["technology", "finance", "business"],
  "leaderboardType": "top",
  "maxLeaderboardPages": 4
}
```

#### 3. Extract Specific Posts + Nested Comments

```json
{
  "mode": "post_urls",
  "postUrls": [
    "https://blog.bytebytego.com/p/ep234-docker-vs-kubernetes"
  ],
  "includeFullContent": true,
  "includeComments": true,
  "maxCommentsPerPost": 100
}
```

***

### Output Examples

#### Post Record (`recordType: "post"`)

```json
{
  "recordType": "post",
  "postId": 225831071,
  "publicationBaseUrl": "https://blog.bytebytego.com",
  "title": "EP234: Docker vs Kubernetes",
  "slug": "ep234-docker-vs-kubernetes",
  "url": "https://blog.bytebytego.com/p/ep234-docker-vs-kubernetes",
  "postDate": "2026-11-21T16:31:20.162Z",
  "audience": "everyone",
  "isPaywalled": false,
  "authorName": "Alex Xu",
  "wordCount": 1257,
  "readingTimeMinutes": 6,
  "reactionCount": 221,
  "commentCount": 4,
  "bodyMarkdown": "## Docker vs Kubernetes...",
  "bodyText": "Docker vs Kubernetes...",
  "outboundLinks": ["https://..."]
}
```

#### Leaderboard Record (`recordType: "leaderboard_publication"`)

```json
{
  "recordType": "leaderboard_publication",
  "categorySlug": "technology",
  "categoryName": "Technology",
  "leaderboardType": "top",
  "rank": 1,
  "publicationName": "ByteByteGo Newsletter",
  "subdomain": "bytebytego",
  "customDomain": "blog.bytebytego.com",
  "url": "https://blog.bytebytego.com",
  "authorName": "Alex Xu",
  "authorHandle": "bytebytego",
  "bestsellerTier": 10000,
  "subscriberCountHint": "1,000,000+",
  "twitterHandle": "alexxubyte"
}
```

***

### Integrations: MCP (Claude / Cursor), n8n, Make & Clay

- **AI Agents via Apify MCP**: Connect directly through `https://mcp.apify.com/` so Claude, Cursor, or custom AI agents can fetch clean Substack Markdown articles and leaderboard data on demand.
- **n8n & Make.com**: Trigger scheduled runs using the official `@apify/n8n-nodes-apify` node to monitor competitor newsletters or build automated weekly AI digests.
- **Clay**: Run `category_leaderboard` mode and map `customDomain`, `authorName`, `twitterHandle`, and `supportEmail` directly into your enrichment table.

# Actor input Schema

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

Choose what to extract: posts from publications, specific post URLs, or Substack category leaderboards (great for B2B lead generation & newsletter discovery).

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

Used in 'publication_posts' mode. Accepts handles (e.g. 'stratechery'), \*.substack.com URLs, or custom domains (e.g. 'https://www.lennysnewsletter.com', 'https://blog.bytebytego.com').

## `postUrls` (type: `array`):

Used in 'post_urls' mode. Direct links to Substack articles (e.g. 'https://blog.bytebytego.com/p/ep234-docker-vs-kubernetes').

## `categories` (type: `array`):

Used in 'category_leaderboard' mode. Category slugs or IDs such as 'technology', 'finance', 'business', 'culture', 'crypto', 'us-politics', 'food', 'sports', 'news', 'health'.

## `leaderboardType` (type: `string`):

Used in 'category_leaderboard' mode: scrape top Bestsellers or Rising publications.

## `maxLeaderboardPages` (type: `integer`):

Each page returns ~25 publications (e.g., 4 pages = ~100 publications per category).

## `sort` (type: `string`):

Sort order when scraping publication archives.

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

Maximum number of posts to retrieve per publication.

## `publishedAfter` (type: `string`):

Only include posts published on or after this date (YYYY-MM-DD). Stops pagination early in 'new' sort mode.

## `keywordFilter` (type: `string`):

Case-insensitive keyword filter applied to post title, subtitle, and slug.

## `freeOnly` (type: `boolean`):

If enabled, skip paywalled (only_paid) posts.

## `includeFullContent` (type: `boolean`):

Fetch each post's full body and convert HTML into clean LLM/RAG-ready Markdown, plain text, and outbound links.

## `includeRawHtml` (type: `boolean`):

Also include the raw body_html field in output (off by default to keep datasets compact).

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

Fetch comments for each scraped post and push them as structured records (recordType: 'comment').

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

Maximum total comments (including nested replies) to collect per post when 'includeComments' is enabled.

## `requestDelayMs` (type: `integer`):

Polite delay between consecutive HTTP requests to avoid rate limits.

## Actor input object example

```json
{
  "mode": "publication_posts",
  "publications": [
    "https://www.lennysnewsletter.com"
  ],
  "categories": [
    "technology"
  ],
  "leaderboardType": "top",
  "maxLeaderboardPages": 2,
  "sort": "new",
  "maxPostsPerPublication": 20,
  "freeOnly": false,
  "includeFullContent": true,
  "includeRawHtml": false,
  "includeComments": false,
  "maxCommentsPerPost": 50,
  "requestDelayMs": 250
}
```

# Actor output Schema

## `overview` (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"
    ],
    "categories": [
        "technology"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("shawn1905/substack-intelligence-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"],
    "categories": ["technology"],
}

# Run the Actor and wait for it to finish
run = client.actor("shawn1905/substack-intelligence-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"
  ],
  "categories": [
    "technology"
  ]
}' |
apify call shawn1905/substack-intelligence-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,shawn1905/substack-intelligence-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/3eoWVLGub1fhBozYH/builds/WfV8KfE7HdxzsApzP/openapi.json
