# Substack Scraper — Posts, Newsletters, Leaderboards & Notes (`qilu/substack-all-in-one-scraper`) Actor

Scrape Substack leaderboards, newsletters, full article text & Markdown, comments, and keyword search (posts & Notes) via public JSON APIs. No login, no cookies, zero browser overhead.

- **URL**: https://apify.com/qilu/substack-all-in-one-scraper.md
- **Developed by:** [Qilu Zhang](https://apify.com/qilu) (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.05 / 1,000 substack records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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, Newsletters, Leaderboards & Notes

Fast, reliable, zero-login data extraction for **Substack** powered directly by public JSON endpoints.

- **No login, no cookies, no browser overhead** — runs on 256 MB memory and finishes in seconds.
- **All-in-one coverage**: Category leaderboards (Top Paid & Rising), any publication's full post archive (including custom domains), clean full-article plain text & Markdown, comments, and global keyword search across posts and Substack Notes.
- **Built for AI/LLM corpus building, newsletter outreach, market research, and content intelligence**.

***

### Key Features

1. **Category Leaderboards (`mode: "leaderboard"`)**
   Extract Top Paid (Bestsellers) or Rising/Trending newsletters across all 35+ Substack categories (`technology`, `business`, `finance`, `us-politics`, `culture`, `crypto`, `food`, `health`, `education`, etc.) — complete with author name, handle, X/Twitter URL, subscriber tier estimates, and custom domains.
2. **Publication Posts & Full Articles (`mode: "posts"`)**
   Pass any Substack URL (`https://www.oneusefulthing.org`, `https://newsletter.pragmaticengineer.com`, `https://lennysnewsletter.substack.com`, or individual `/p/slug` post links). Supports `new` / `top` sorting, free vs paid filtering, optional **clean plain text + Markdown** extraction (`includeFullText: true`), and optional **top comments** (`includeComments: true`).
3. **Global Keyword Search (`mode: "search"`)**
   Search across all Substack posts and Notes by keyword (e.g. `artificial intelligence`, `semiconductors`, `venture capital`) with automatic cursor pagination.
4. **Fair Pay-Per-Event Pricing**
   You only pay for valid records actually delivered. Empty searches and filtered-out items are **100% free**.

***

### Pricing (Pay-Per-Event)

| Event | Price | Description |
| :--- | :--- | :--- |
| `substack-item` | **$0.0015 / item** ($1.50 per 1,000) | One leaderboard newsletter, post metadata record, or Note |
| `full-article` | **$0.0015 / article** ($1.50 per 1,000) | Optional add-on when `includeFullText` is enabled |
| `comment-record` | **$0.0005 / comment** ($0.50 per 1,000) | Optional add-on when `includeComments` is enabled |

> Free Apify accounts can preview up to **20 items** per run. Paid Apify plans unlock up to **5,000 items** per run.

***

### Input Examples

#### 1. Top 25 Technology Bestsellers (Default)

```json
{
  "mode": "leaderboard",
  "category": "technology",
  "leaderboardType": "paid",
  "maxItems": 25
}
```

#### 2. Scrape Full Markdown Articles + Comments from Newsletters

```json
{
  "mode": "posts",
  "publicationUrls": [
    "https://www.oneusefulthing.org",
    "https://newsletter.pragmaticengineer.com"
  ],
  "postSort": "new",
  "audienceFilter": "free_only",
  "includeFullText": true,
  "includeComments": true,
  "maxCommentsPerPost": 15,
  "maxItems": 30
}
```

#### 3. Global Keyword Search (Posts & Notes)

```json
{
  "mode": "search",
  "searchQuery": "artificial intelligence",
  "searchContentType": "all",
  "maxItems": 50
}
```

***

### Sample Output

#### Leaderboard Newsletter (`recordType: "publication"`)

```json
{
  "recordType": "publication",
  "rank": 1,
  "category": "Technology",
  "categorySlug": "technology",
  "leaderboardType": "paid",
  "publicationId": "6349492",
  "publicationName": "SemiAnalysis",
  "subdomain": "semianalysis",
  "customDomain": "newsletter.semianalysis.com",
  "authorName": "Dylan Patel",
  "authorHandle": "dylan522p",
  "paidSubscriberEstimate": "Tens of thousands of paid subscribers",
  "subscriberEstimate": "Hundreds of thousands of subscribers",
  "bestsellerTier": 10000,
  "paymentsEnabled": true,
  "url": "https://newsletter.semianalysis.com",
  "scrapedAt": "2026-11-23T14:00:00Z"
}
```

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

```json
{
  "recordType": "post",
  "postId": "225681495",
  "slug": "fable-52-and-jagged-agi",
  "publicationName": "One Useful Thing",
  "title": "Fable 52 and Jagged AGI",
  "subtitle": "What new AI capabilities mean for work",
  "authorName": "Ethan Mollick",
  "authorHandle": "oneusefulthing",
  "audience": "everyone",
  "isPaid": false,
  "wordCount": 2410,
  "likesCount": 512,
  "commentsCount": 169,
  "restacksCount": 84,
  "publishedAt": "2026-11-09T19:00:00Z",
  "bodyText": "...",
  "bodyMarkdown": "...",
  "url": "https://www.oneusefulthing.org/p/fable-52-and-jagged-agi",
  "scrapedAt": "2026-11-23T14:00:00Z"
}
```

# Actor input Schema

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

Choose what to extract: category leaderboards, posts from specific Substack newsletters/URLs, or global keyword search across posts and Notes.

## `category` (type: `string`):

Used in 'leaderboard' mode. Category slug or name (e.g. 'technology', 'business', 'finance', 'us-politics', 'culture', 'crypto', 'food', 'health', 'sports', 'education', 'international', 'climate').

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

Used in 'leaderboard' mode. Choose between Top Paid (Bestsellers) or Rising / Trending newsletters.

## `publicationUrls` (type: `array`):

Used in 'posts' mode. Enter Substack newsletter URLs (e.g. 'https://www.oneusefulthing.org', 'https://newsletter.pragmaticengineer.com', 'https://lennysnewsletter.substack.com') or individual post URLs ('.../p/post-slug').

## `postSort` (type: `string`):

Used in 'posts' mode when scraping a newsletter archive.

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

Filter posts by access level.

## `searchQuery` (type: `string`):

Required in 'search' mode; optional keyword filter in 'posts' mode. Example: 'artificial intelligence', 'semiconductors', 'SaaS'.

## `searchContentType` (type: `string`):

Used in 'search' mode. Choose whether to return articles, Substack Notes, or both.

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

Fetch full public article HTML and convert it into clean plain text and Markdown (great for LLMs, RAG, and research). Paid posts return their public preview.

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

Fetch top comments for each scraped post (applies to 'posts' and 'search' modes).

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

Maximum number of comments to attach per post when Include Post Comments is enabled.

## `maxItems` (type: `integer`):

Maximum number of newsletters, posts, or search results to extract. Free Apify plans are capped at 20 preview items.

## Actor input object example

```json
{
  "mode": "leaderboard",
  "category": "technology",
  "leaderboardType": "paid",
  "publicationUrls": [
    "https://www.oneusefulthing.org"
  ],
  "postSort": "new",
  "audienceFilter": "all",
  "searchQuery": "",
  "searchContentType": "all",
  "includeFullText": false,
  "includeComments": false,
  "maxCommentsPerPost": 20,
  "maxItems": 25
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `publications` (type: `string`):

No description

## `posts` (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 = {
    "mode": "leaderboard",
    "category": "technology",
    "leaderboardType": "paid",
    "publicationUrls": [
        "https://www.oneusefulthing.org"
    ],
    "includeFullText": false,
    "includeComments": false,
    "maxItems": 25
};

// Run the Actor and wait for it to finish
const run = await client.actor("qilu/substack-all-in-one-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 = {
    "mode": "leaderboard",
    "category": "technology",
    "leaderboardType": "paid",
    "publicationUrls": ["https://www.oneusefulthing.org"],
    "includeFullText": False,
    "includeComments": False,
    "maxItems": 25,
}

# Run the Actor and wait for it to finish
run = client.actor("qilu/substack-all-in-one-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 '{
  "mode": "leaderboard",
  "category": "technology",
  "leaderboardType": "paid",
  "publicationUrls": [
    "https://www.oneusefulthing.org"
  ],
  "includeFullText": false,
  "includeComments": false,
  "maxItems": 25
}' |
apify call qilu/substack-all-in-one-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,qilu/substack-all-in-one-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/5xAYxVzvVX6LF3wWK/builds/HUGaFTUyHkiBCIXvB/openapi.json
