# Substack Scraper — Posts, Newsletters & Rankings (`yannabadie/substack-api-mcp`) Actor

Official Substack public JSON API scraper & MCP tool. Extract full clean newsletter posts (cursor-paginated), paywall flags, likes/comments/restacks, author profiles, global search, and Paid/Rising/Trending category leaderboards. $1.50/1k, free count mode, zero proxy.

- **URL**: https://apify.com/yannabadie/substack-api-mcp.md
- **Developed by:** [Yann Abadie](https://apify.com/yannabadie) (community)
- **Categories:** News, Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 substack post or newsletter records

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, Newsletters & Rankings](https://raw.githubusercontent.com/yannabadie/yannabadie/main/assets/banner_substack_api.png)

## Substack Scraper — Posts, Newsletters & Rankings

Extract **Substack newsletter posts**, **clean full plain-text bodies**, **engagement metrics** (likes, comments, restacks), **author profiles**, **global search results**, and **Paid / Rising / Trending category leaderboards** directly from Substack's official public JSON API.

Built for **AI agents (MCP)**, **media intelligence**, **creator lead generation**, **newsletter monitoring**, and **market research** — running at **256 MB RAM** with **zero browser overhead** and **zero residential proxies**.

***

### Why Choose This Actor?

| Feature | This Actor (`substack-api-mcp`) | Typical Substack Scrapers |
|---|---|---|
| **Price per 1,000 records** | **$1.50 / 1k** (`$0.0015`/record) + `$0.005` start | $2.00 / 1k+ (often broken after 2026 API changes) |
| **Late-2026 Cursor Pagination** | Native `/api/v1/archive?cursor=...` (`offset` deprecated) | Breaks with HTTP 400 on `?offset=0` |
| **FREE `count` Preview Mode** | **$0 record charge** (check volume & top titles first) | Not available |
| **Category Leaderboards** | **6 ranking tabs**: `paid`, `rising`, `trending`, `top`, `free`, `all` across 35 categories | Posts only or Paid only |
| **Full Clean Plain-Text Body** | Full untruncated `body_html` parsed to clean `bodyText` (optional toggle) | Truncated snippet only or raw HTML |
| **Memory & Speed** | Pure Python 3.12 stdlib, **256 MB RAM**, ~300 ms/page | Heavy browser / proxy costs |
| **MCP Ready** | Native Apify MCP Server integration | Manual glue |

***

### 4 Execution Modes

#### 1. `posts` — Extract Publication Archives or Direct Post URLs

Accepts custom domains (`https://www.lennysnewsletter.com`), Substack subdomains (`garymarcus.substack.com`), bare handles (`garymarcus`, `@garymarcus`), or direct post URLs (`/p/slug`).

```json
{
  "mode": "posts",
  "publications": [
    "https://www.lennysnewsletter.com",
    "garymarcus.substack.com"
  ],
  "sortBy": "new",
  "includeFullBody": true,
  "onlyFreePosts": false,
  "publishedAfter": "2026-09-01",
  "maxResults": 20
}
```

#### 2. `leaderboard` — Top Paid, Rising & Trending Newsletters by Category

Resolves any Substack category slug (`technology`, `business`, `finance`, `culture`, `science`, `news`, `us-politics`, `world-politics`, `climate`, `health`, `food`, `sports`, `design`, `music`, `literature`, `fiction`, `fashion`, `art`, `faith`) or numeric category ID, and ranks top publications with subscriber bands (`334K+`, `Tens of thousands of paid subscribers`), custom domains, and author handles.

```json
{
  "mode": "leaderboard",
  "category": "technology",
  "ranking": "paid",
  "maxResults": 50
}
```

#### 3. `search` — Global Substack Posts or Publications Search

Search across all public Substack posts (`searchType: "posts"`) or discover newsletters by topic (`searchType: "publications"`).

```json
{
  "mode": "search",
  "query": "AI agents",
  "searchType": "posts",
  "includeFullBody": false,
  "maxResults": 25
}
```

#### 4. `count` — FREE Preview Mode (`$0` record charge)

Check availability, top 5 titles/newsletters, `hasMore`, and pricing **before** pulling a full dataset (`billable = 0`).

```json
{
  "mode": "count",
  "countTargetMode": "leaderboard",
  "category": "finance",
  "ranking": "paid"
}
```

***

### Sample Output Record (`posts` mode)

```json
{
  "recordKey": "post:224972682",
  "recordType": "post",
  "postId": "224972682",
  "publicationId": "10845",
  "publicationName": "Lenny's Newsletter",
  "publicationSubdomain": "lennysnewsletter",
  "publicationBaseUrl": "https://www.lennysnewsletter.com",
  "title": "35 premium tools free for a year...",
  "subtitle": "Over $40,000 in value, exclusively for subscribers",
  "slug": "35-premium-tools-free-for-a-yearnow",
  "url": "https://www.lennysnewsletter.com/p/35-premium-tools-free-for-a-yearnow",
  "postDate": "2026-11-17T18:02:02.477Z",
  "postType": "newsletter",
  "audience": "everyone",
  "isPaywalled": false,
  "wordCount": 1758,
  "likesCount": 220,
  "commentsCount": 13,
  "restacksCount": 2,
  "authorName": "Lenny Rachitsky",
  "authorHandle": "lenny",
  "bodyText": "Clean plain-text article body...",
  "excerpt": "Short preview snippet..."
}
```

***

### Pay-Per-Event Pricing

| Event | Price | Notes |
|---|---|---|
| `apify-actor-start` | `$0.005` | Charged once per Actor run |
| `substack-record` | `$0.0015` (`$1.50 / 1,000`) | Charged per emitted post or publication (`$0` in `count` mode) |

***

### Use with AI Agents (MCP)

Connect this Actor directly to Claude, Cursor, Windsurf, or any MCP client via the Apify MCP Server:

```text
https://mcp.apify.com/?actors=yannabadie/substack-api-mcp
```

***

### Explore Our Other Official Zero-Proxy API Actors

- [French Company Intelligence (SIRENE + BODACC + BOAMP)](https://apify.com/yannabadie/french-company-intelligence-mcp)
- [EU Public Tenders (TED Europa v3 + BOAMP)](https://apify.com/yannabadie/eu-public-tenders-ted-boamp)
- [ClinicalTrials.gov v2 API & Sponsor Contacts](https://apify.com/yannabadie/clinical-trials-api-mcp)
- [US NPI Healthcare Providers & Clinics (CMS Registry)](https://apify.com/yannabadie/npi-healthcare-providers-mcp)
- [PubMed & Europe PMC API — Papers, Emails & PDFs](https://apify.com/yannabadie/pubmed-europepmc-api-mcp)

# Actor input Schema

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

Choose 'posts' to extract articles from one or more Substack publications, 'leaderboard' to scrape ranked Paid/Rising/Trending newsletters by category, 'search' for global Substack post/publication search, or 'count' for a FREE ($0 record charge) preview.

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

Used in 'posts' (and 'count' with target='posts'). Accepts custom domains (https://www.lennysnewsletter.com), Substack subdomains (garymarcus.substack.com), bare handles (garymarcus), or direct post URLs (/p/slug).

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

Sort order when fetching a publication archive ('new' = newest first, 'top' = most popular).

## `includeFullBody` (type: `boolean`):

Fetch full untruncated article HTML from /api/v1/posts/{slug} and convert to clean plain text (bodyText). Disable for ultra-fast metadata-only extraction.

## `onlyFreePosts` (type: `boolean`):

Exclude paid-subscriber-only posts (audience = only_paid).

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

Optional ISO date cutoff for 'posts' mode (e.g. 2026-01-01). Stops pagination early when sortBy='new'.

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

Used in 'leaderboard' mode. Substack category slug (e.g. technology, business, finance, culture, science, news, us-politics, climate, health, food, sports, design) or numeric category ID.

## `ranking` (type: `string`):

Ranking tab for 'leaderboard' mode.

## `query` (type: `string`):

Search query for 'search' mode (e.g. 'AI agents'), or optional case-insensitive keyword filter applied to title/subtitle/body in 'posts' mode.

## `searchType` (type: `string`):

Choose whether 'search' mode returns matching posts or matching publications.

## `countTargetMode` (type: `string`):

Only used when mode='count': chooses which endpoint to preview for free.

## `maxResults` (type: `integer`):

Maximum number of posts or publication records to return (1–2000).

## Actor input object example

```json
{
  "mode": "posts",
  "publications": [
    "https://www.lennysnewsletter.com"
  ],
  "sortBy": "new",
  "includeFullBody": true,
  "onlyFreePosts": false,
  "publishedAfter": "",
  "category": "technology",
  "ranking": "paid",
  "query": "",
  "searchType": "posts",
  "countTargetMode": "posts",
  "maxResults": 20
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (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": "posts",
    "publications": [
        "https://www.lennysnewsletter.com"
    ],
    "category": "technology",
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("yannabadie/substack-api-mcp").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": "posts",
    "publications": ["https://www.lennysnewsletter.com"],
    "category": "technology",
    "maxResults": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("yannabadie/substack-api-mcp").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": "posts",
  "publications": [
    "https://www.lennysnewsletter.com"
  ],
  "category": "technology",
  "maxResults": 20
}' |
apify call yannabadie/substack-api-mcp --silent --output-dataset

```

## MCP server setup

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

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/xhhMaROoOkbcGR3Pt/builds/mrUVhS5Z8gcDM2Uar/openapi.json
