# Substack Posts Scraper 📚 (`scrapers-hub/substack-posts-scraper`) Actor

Substack Posts scraper extracts publicly available newsletter posts, titles, authors, publication dates, tags, post URLs, and metadata 📰📊 Perfect for content research, trend analysis, competitive intelligence, and newsletter monitoring.

- **URL**: https://apify.com/scrapers-hub/substack-posts-scraper.md
- **Developed by:** [Scrapers Hub](https://apify.com/scrapers-hub) (community)
- **Categories:** News, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Substack Keyword Search Scraper

An [Apify](https://apify.com) actor that searches Substack posts by keyword and
exports the full post objects returned by Substack's search API.

### Input

```json
{
  "keywords": ["hi", "apify.com"],
  "maxItems": 50,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `keywords` | string\[] | Search terms matched against Substack publications. **Required.** |
| `maxItems` | integer | Max posts **per keyword**. `0` = unlimited. Default `50`. |

Proxy is handled internally (rotating US residential) and is not a user input.

> **Why residential proxies?** From datacenter IPs, Substack silently returns an
> empty `results` array (a soft block). Residential IPs return real posts.

### Output

Each dataset item is the full Substack post object from the search endpoint,
plus two added fields:

- `keyword` — the search term that surfaced this post.
- `scrapedAt` — ISO-8601 UTC timestamp of when it was scraped.
- `body_text` — plain-text version of `body_html` (only when `body_html` is present).

Example (trimmed):

```json
{
  "keyword": "hi",
  "id": 204336086,
  "title": "Jagged Edge (1985) Tonight",
  "canonical_url": "https://hinrg.substack.com/p/jagged-edge-1985-tonight",
  "post_date": "2026-07-01T15:01:19.284Z",
  "subtitle": "Let's talk about movies.",
  "reaction_count": 7,
  "scrapedAt": "2026-07-06T05:54:23.716Z"
}
```

### How it works

1. For each keyword, page through
   `https://substack.com/api/v1/post/search?query=<keyword>&page=<n>`.
2. HTTP is done with **`requests`**. If a response looks blocked
   (HTTP 403/429/503 or a Cloudflare challenge page), the request is retried
   through **`cloudscraper`**.
3. HTML fragments are cleaned to plain text with **`parsel`** + **`re`**.
4. Pagination stops when Substack reports `more: false`, a page has no new
   posts, or the per-keyword `maxItems` limit is hit.

### Run locally

```bash
pip install -r requirements.txt
apify run            # via the Apify CLI, or:
python -m src        # sets up the Actor from ./storage
```

# Actor input Schema

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

List of search terms. Each keyword is matched against Substack publications; posts are then pulled from every matching publication.

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

Maximum number of posts to scrape for EACH keyword. Set 0 for unlimited.

## Actor input object example

```json
{
  "keywords": [
    "hi",
    "apify.com"
  ],
  "maxItems": 50
}
```

# 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 = {
    "keywords": [
        "hi",
        "apify.com"
    ],
    "maxItems": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapers-hub/substack-posts-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 = {
    "keywords": [
        "hi",
        "apify.com",
    ],
    "maxItems": 50,
}

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

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

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

```

## CLI example

```bash
echo '{
  "keywords": [
    "hi",
    "apify.com"
  ],
  "maxItems": 50
}' |
apify call scrapers-hub/substack-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scrapers-hub/substack-posts-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/23mDac4LhE9no65Nh/builds/Z2ScUXth0Oy2S0Hqp/openapi.json
