# Substack Scraper (`solarg/substack-scraper`) Actor

Scrape posts and newsletter details from any Substack publication, including custom domains. Find newsletters by keyword. No login needed.

- **URL**: https://apify.com/solarg/substack-scraper.md
- **Developed by:** [Solar G](https://apify.com/solarg) (community)
- **Categories:** News, Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 post scrapeds

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

Scrapes posts and publication details from Substack newsletters, including those on custom domains. No login is required.

### Input

| Field | Description |
|---|---|
| `publications` | Subdomains (`lenny`), Substack URLs (`https://lenny.substack.com`) or custom domains (`www.lennysnewsletter.com`). |
| `maxPostsPerPublication` | Newest first. Default 50. Set to 0 to return publication records only. |
| `postedAfter` | Optional. Stop at posts older than this date. |
| `includeContent` | Include post text and HTML. Default `true`. |
| `includePublicationInfo` | Include one record per publication. Default `true`. |

```json
{
  "publications": ["https://www.lennysnewsletter.com", "astralcodexten"],
  "maxPostsPerPublication": 100,
  "postedAfter": "2026-01-01"
}
```

### Output

Each item has a `type` of `post`, `publication` or `error`.

**Post**

```json
{
  "type": "post",
  "publicationUrl": "https://www.lennysnewsletter.com",
  "id": 219482066,
  "title": "How to tell if a startup has a moat",
  "subtitle": "A framework for assessing whether the company you're considering joining is built to last",
  "url": "https://www.lennysnewsletter.com/p/how-to-tell-if-a-startup-has-a-moat",
  "date": "2026-10-13T12:45:41.160Z",
  "postType": "newsletter",
  "audience": "only_paid",
  "isPaywalled": true,
  "wordcount": 4153,
  "reactionCount": 352,
  "commentCount": 2,
  "restacks": 18,
  "authors": [{ "name": "Dan Hockenmaier", "handle": "danhock", "id": 2607892 }],
  "tags": ["Career"],
  "coverImage": "https://substackcdn.com/...",
  "podcastUrl": null,
  "contentText": "...",
  "contentHtml": "..."
}
```

**Publication**

```json
{
  "type": "publication",
  "name": "Lenny's Newsletter",
  "url": "https://www.lennysnewsletter.com",
  "subdomain": "lenny",
  "customDomain": "www.lennysnewsletter.com",
  "description": "Deeply researched product, growth, and career advice...",
  "language": "en",
  "hasPaidPlans": true,
  "paidPlans": [{ "interval": "month", "amount": 20, "currency": "usd" }],
  "rankingDetail": "Tens of thousands of paid subscribers",
  "createdAt": "2019-..."
}
```

### API usage

Run the Actor and get results in one request:

```bash
curl -X POST "https://api.apify.com/v2/acts/solarg~substack-scraper/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"publications": ["lenny"], "maxPostsPerPublication": 50}'
```

With the JavaScript client:

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
const run = await client.actor('solarg/substack-scraper').call({"publications": ["lenny"], "maxPostsPerPublication": 50});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

With Python:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("solarg/substack-scraper").call(run_input={"publications": ["lenny"], "maxPostsPerPublication": 50})
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

You can also schedule runs in Apify Console and send results to Google Sheets, Slack, webhooks, Zapier, Make or n8n through Apify's integrations.

### Pricing

- $1.00 per 1,000 posts (content included)
- $0.002 per publication record

Platform usage is included in the price.

### Limitations

- Paid posts return only the free preview that Substack shows publicly. Paywalled content isn't accessed.
- Comments are not included.

### Notes

Report problems in the Issues tab.

# Actor input Schema

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

Substack subdomains (lenny), URLs (https://lenny.substack.com) or custom domains (www.lennysnewsletter.com).

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

Newest first.

## `postedAfter` (type: `string`):

Stop at posts older than this date (YYYY-MM-DD).

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

Add full text and HTML of each post. For paid posts only the public preview is available.

## `includePublicationInfo` (type: `boolean`):

Add one record per publication with name, description, language, logo and paid plan prices.

## Actor input object example

```json
{
  "publications": [
    "https://www.lennysnewsletter.com"
  ],
  "maxPostsPerPublication": 20,
  "includeContent": true,
  "includePublicationInfo": true
}
```

# Actor output Schema

## `results` (type: `string`):

All scraped items in the default dataset.

# 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"
    ],
    "maxPostsPerPublication": 20
};

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

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

```

## MCP server setup

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