# Substack Scraper - Posts, Metrics & New-Post Alerts (`lukehunter/substack-scraper`) Actor

Scrape public Substack archive metadata into flat post rows: title, subtitle, date, free/paid audience, word count, reactions, comments and author. New-post alerts can go to Discord, Telegram, Slack or any webhook. Never fetches paywalled bodies. $0.0015/post.

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

## Pricing

$1.50 / 1,000 posts

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, Metrics & New-Post Alerts

**For newsletter researchers, competitor analysts and content curators who want a publication's public post list as structured data.** Give it one or more Substack publication URLs (including custom domains) and get one row per post: title, subtitle, date, free/paid audience, word count, reactions, comment count and author. No login, cookies or proxies. Turn on **new-post alerts** (`onlyNewSinceLastRun`) and run it on a schedule to receive only posts you have not been given before.

Pay-per-result: **$0.0015 per post — 1,000 posts = $1.50.** You are charged only for rows that land in your dataset.

### Quick start

1. Open the **Input** tab and use the prefill below, or replace the URL with the publications you follow.
2. Click **Start**.
3. Open the dataset and export it as CSV, Excel, JSON or XML.

```json
{
  "publicationUrls": [
    "https://www.lennysnewsletter.com"
  ],
  "maxPagesPerSearch": 2,
  "maxItems": 20,
  "onlyNewSinceLastRun": false,
  "stateStoreName": "substack-scraper-seen-posts"
}
```

Pass publication home URLs in `publicationUrls` (up to 50). The Actor stays on the origin you supply and reads the public `/api/v1/archive` JSON, falling back to the public `/feed` only when the first archive request returns 404. `maxPagesPerSearch` defaults to 2 (range 1-10) and `maxItems` defaults to 100 (hard maximum 5,000), so `maxItems` doubles as your cost cap.

### Example output

One flat row per post. This row is produced by the Actor's parser from a captured Lenny's Newsletter archive response:

```json
{
  "id": "215694124",
  "url": "https://www.lennysnewsletter.com/p/all-of-the-lenny-and-friends-summit",
  "title": "All of the Lenny & Friends Summit talks are now online!",
  "subtitle": "Plus, some reflections and takeaways from the day",
  "postDate": "2026-09-29T13:15:57.512Z",
  "audience": "free",
  "wordcount": 1276,
  "reactions": 271,
  "commentCount": 6,
  "author": "Lenny Rachitsky"
}
```

Every row also carries `searchTerm`, `page`, `position`, `sourceUrl` and `scrapedAt`. Any value Substack does not publish is `null`; nothing is guessed.

### Use cases

- **Newsletter research:** export a publication's recent catalogue with audience, word count and engagement to see what topics and formats work.
- **Competitor monitoring:** watch rival newsletters on a schedule and get only newly published posts, with posting cadence, authors, reactions and comments.
- **Content curation:** build a weekly digest or reading list from the newsletters you follow, straight into a sheet, Slack or email.
- **Sponsorship and partnership scouting:** compare free-versus-paid mix and engagement across publications before you reach out.

### New-post alerts

1. Add your publication URLs, then set `onlyNewSinceLastRun` to `true`.
2. Click **Schedule** on the run page (or create one under **Schedules** in the Apify Console). Daily works well for most newsletters.
3. The first run is a baseline: it delivers (and charges for) the posts currently listed and remembers their ids per publication. Every later run delivers only ids it has not delivered before.
4. Add a webhook or integration (Slack, email via Zapier/Make, Google Sheets) on run success to forward the new rows.

A run with nothing new still succeeds with an empty dataset and costs nothing.

### Get new Substack post alerts in Discord, Telegram, Slack, Teams, Google Chat, your phone (ntfy/Pushover) or any app (webhook)

Want a **Substack new post alert** in Discord, Telegram or on your phone instead of checking a dataset? Add one or more destinations in the Actor's **Notifications (optional)** section and each run sends the posts it delivered. It is a **monitor that notifies you**: it only reads public publication archives, and it never subscribes, comments or logs in to Substack.

| Channel | Fill in | What you get |
|---|---|---|
| Discord | `discordWebhookUrl` | One card per post, 10 per message |
| Telegram | `telegramBotToken` + `telegramChatId` | Up to 10 posts per message, one line each |
| Slack | `slackWebhookUrl` | Block Kit message, up to 10 posts per message |
| Mattermost, Rocket.Chat | `slackCompatibleWebhookUrl` | Slack-style incoming webhook: a Markdown list (these apps do not render Slack Block Kit) |
| Microsoft Teams | `teamsWebhookUrl` | Adaptive Card from a Teams Workflows webhook, up to 10 posts per card |
| Google Chat | `googleChatWebhookUrl` | Card in a space, up to 10 posts per message |
| ntfy (phone push, no account) | `ntfyTopic` (optional `ntfyServer`, `ntfyToken`) | A push per post, up to 10, then one "...and N more" |
| Pushover (phone push) | `pushoverUserKey` + `pushoverAppToken` | A push per post, up to 10, then one "...and N more" |
| Any app: Zapier, Make, n8n, Pipedream, IFTTT, Home Assistant | `webhookUrl` | One JSON POST per run with every delivered row |

Fill in as many as you like; each channel works on its own and a failing one never stops the others.

#### Setup, channel by channel

- **Discord (1 minute):** Server Settings → Integrations → Webhooks → New Webhook → pick the channel → **Copy Webhook URL**.
- **Telegram (2 minutes):** chat with **@BotFather**, send `/newbot`, paste the token into `telegramBotToken`. Add the bot to the chat or channel (administrator for a channel; for a chat with yourself press **Start** on the bot). `telegramChatId` is a numeric id (`123456789`, or `-1001234567890` for a group or channel) or a public `@channelusername`.
- **Slack:** at api.slack.com/apps create an app (**From scratch**) → **Incoming Webhooks** → switch it on → **Add New Webhook to Workspace** → pick the channel → copy the `https://hooks.slack.com/services/...` URL.
- **Mattermost or Rocket.Chat:** create an **incoming webhook** in the app and paste its public `https://` URL into `slackCompatibleWebhookUrl`. It must be reachable from the internet: localhost, private IP addresses and `.local` / `.internal` names are rejected.
- **Microsoft Teams:** in the channel open **... → Workflows** → **Post to a channel when a webhook request is received** → finish the wizard and copy the URL (a host ending in `.logic.azure.com` or `.powerplatform.com`). The old "Office 365 connector" webhooks are retired and not supported.
- **Google Chat:** in the space open **Apps & integrations → Webhooks → Add webhook**, name it and copy the `https://chat.googleapis.com/v1/spaces/...` URL (needs a Google Workspace account that allows webhooks).
- **ntfy (free, no account):** install the ntfy app (or open ntfy.sh), subscribe to a topic with a long random name, and put the same name in `ntfyTopic`. Anyone who knows the topic can read it, so make it unguessable. Own server or a protected topic: set `ntfyServer` (public `https://` address) and `ntfyToken`.
- **Pushover:** copy your user key from pushover.net into `pushoverUserKey`, create an application at pushover.net/apps/build and put its API token in `pushoverAppToken`. Pushover itself is a separate paid app after its trial: check their pricing.
- **Any app (webhook):** paste the catch-hook URL from Zapier, Make, n8n, Pipedream, IFTTT or Home Assistant into `webhookUrl`. It must be a public `https://` address.

#### The recipe: a Substack new-post alert in five steps

1. Add the publication URLs you follow to `publicationUrls`.
2. Turn on `onlyNewSinceLastRun`.
3. Add your destination(s) from the table above.
4. Run it once. The first run is the baseline and sends the posts currently listed (up to `maxNotifications`).
5. Create a **Schedule** (daily works for most newsletters). From then on you only hear about posts it has not delivered before.

```json
{
  "publicationUrls": [
    "https://www.lennysnewsletter.com"
  ],
  "maxItems": 100,
  "onlyNewSinceLastRun": true,
  "discordWebhookUrl": "https://discord.com/api/webhooks/<id>/<token>",
  "ntfyTopic": "your-long-random-topic-name",
  "maxNotifications": 25
}
```

#### The generic webhook (`webhookUrl`)

Each run sends **one POST per 100 delivered rows** (so usually one) with this body, followed by whatever your tool does with it:

```json
{
  "source": "apify",
  "actor": "substack-scraper",
  "runId": "HG7ML7M8z78YcAPEB",
  "count": 2,
  "total": 2,
  "part": 1,
  "parts": 1,
  "items": [
    {
      "...": "the full dataset rows"
    }
  ]
}
```

`count` is the number of rows in this POST, `total` the number delivered in the run, and `part` / `parts` number the POSTs when a run delivers more than 100 rows. `maxNotifications` does not cap the webhook: your tool gets every delivered row. Your endpoint should answer with a 2xx status; redirects are not followed and a failure is reported in the run status, never retried in a loop.

#### What each message contains

Each post is announced as `New post: <title> — <author>` with the link, the subtitle, publication date, free or paid audience, word count, reactions and comment count when Substack publishes them, and the publication's host name. Anything Substack does not publish (for example the counts on the feed fallback) is left out. Discord gets a card per post, Telegram one line per post, Slack Block Kit sections, Teams an Adaptive Card, Google Chat a card, and ntfy/Pushover a push that opens the post. Link previews are off, and titles are escaped so a title can never inject formatting or mentions.

#### What to expect

- **Only delivered posts are sent.** A run that finds nothing new sends nothing, so there is no "no new posts" spam. Rows the run could not deliver (for example because your spending limit was reached) are not sent.
- **Without `onlyNewSinceLastRun`, every delivered row is sent**, so a scheduled plain run would repeat the same posts: use alert mode for alerts (the message then says "New post"; a plain run says "Post").
- **`maxNotifications` (default 25, max 100)** caps how many posts go to chat and phone channels per run (the webhook is not capped). The rest are still in the dataset and the status message says so. ntfy and Pushover send at most 10 individual pushes, then one "...and N more" summary.
- **Cost: notifications are free.** You pay only the usual price for delivered posts, exactly as without alerts. There is no extra charge for any channel.
- **Failures never fail the run.** A deleted webhook or an unreachable service leaves the run successful and the dataset complete, and the status message says what happened, for example `Notified: Discord 12, Slack 12, ntfy 10 (+summary). Teams failed (HTTP 404) - check the webhook URL.` The logs show the channel name and HTTP status only, never a URL or token.
- **Your URLs, tokens and ntfy topic are stored as secret inputs.** Anyone holding a webhook URL can post to that channel, so treat it like a password.
- **It is a monitor that notifies you.** It never subscribes, comments or logs in to Substack. The messages go only to the destinations you set up.
- **Nothing changes by default.** With no destination set, a run behaves exactly as before and the dataset rows are identical.

### Pricing

Pay-per-event: **$0.0015 per delivered post** — 1,000 posts = $1.50. Rows skipped by robots.txt, blocks, failed routes, or already-seen alert history are not delivered and are not charged. A run that returns nothing is not charged. Price changes follow Apify's notice rules; the Pricing tab always shows the rate you pay.

Notifications to Discord, Telegram, Slack, Teams, Google Chat, ntfy, Pushover and webhooks are free: you pay only for delivered posts, never for messages sent.

### Limitations

- **Metadata only, never post bodies.** The Actor does not fetch individual posts, so article text is not included. Paywalled posts appear as metadata rows (`audience` is `paid`), but their bodies are never requested, and private or subscriber feeds are never touched.
- **Robots.txt only.** Every path is checked against the publication's robots.txt first; a disallowed path is skipped, not bypassed. Requests are spaced about three seconds apart with an identifying User-Agent. No login, CAPTCHA solving or proxies.
- **Pages, not the full archive.** Each archive page returns 12 posts, so the default 2 pages gives about 24 posts per publication and the maximum of 10 pages about 120. Older posts beyond that are not retrieved.
- **Feed fallback has fewer fields.** If a publication's archive endpoint returns 404, the Actor uses its public `/feed` (a single response). Feed rows have `audience`, `wordcount`, `reactions` and `commentCount` set to `null` because the feed does not publish them.
- **Public publications on Substack's standard routes.** A publication that exposes neither the archive JSON nor a public feed produces no rows and is reported in the run status.
- **Engagement counts are a snapshot** taken at run time, as published by Substack.
- **Layout changes.** If Substack changes its public routes, the run reports a clear error instead of returning bad rows.

### Use it from your code, Make, Zapier or n8n

Built for automated pipelines: small runs, stable field names, one row per item, and you pay only for rows actually delivered.

**One API call that runs the Actor and returns the data** (replace `$APIFY_TOKEN` with your token from Apify Console → Settings → Integrations):

```bash
curl -s -X POST "https://api.apify.com/v2/acts/lukehunter~substack-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"publicationUrls": ["https://www.lennysnewsletter.com"], "maxPagesPerSearch": 2, "maxItems": 20}'
```

**JavaScript** (`npm i apify-client`):

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('lukehunter~substack-scraper').call({
  "publicationUrls": [
    "https://www.lennysnewsletter.com"
  ],
  "maxPagesPerSearch": 2,
  "maxItems": 20
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

**Python** (`pip install apify-client`):

```python
import os
from apify_client import ApifyClient
client = ApifyClient(os.environ['APIFY_TOKEN'])
run = client.actor('lukehunter~substack-scraper').call(run_input={"publicationUrls": ["https://www.lennysnewsletter.com"], "maxPagesPerSearch": 2, "maxItems": 20})
items = client.dataset(run['defaultDatasetId']).list_items().items
```

**Schedules, webhooks and no-code tools:** save your input as a Task, add a Schedule (e.g. hourly or daily), and attach a webhook or one of the Integrations tab's connectors (Make, Zapier, n8n, Google Sheets, Slack) to push each run's results into your own system.

**Only new items each run:** set `"onlyNewSinceLastRun": true` on a scheduled Task and every run after the first delivers, and charges for, only items it hasn't delivered before for that same input. That makes it a ready-made change feed.

**Reliability:** an automated test runs this Actor's parser against the live site every day, and failures are fixed fast.

**Feedback:** an honest rating on the Store page, good or bad, helps others decide if this Actor fits their needs. Missing a field or found a problem? Open an issue on the Actor page.

### FAQ

**How much does it cost?** $0.0015 per delivered post, so 1,000 posts cost $1.50. `maxItems` is a hard cap on spend.

**Can I monitor a newsletter for new posts on a schedule?** Yes. Turn on `onlyNewSinceLastRun` and attach an Apify Schedule. The first run is a baseline; later runs deliver only unseen posts.

**Does it work with custom domains?** Yes. Use the publication's home URL, whether it is `name.substack.com` or its own domain; the Actor only builds the public archive and feed routes on that origin.

**Does it read paywalled content?** No. It lists paid posts as metadata only and never requests their bodies.

**What export formats are available?** Anything the Apify dataset supports: CSV, Excel, JSON, XML, RSS and HTML table, plus the API.

**Can I get Substack post alerts in Discord, Telegram, Slack or on my phone?** Yes. Set `discordWebhookUrl`, `telegramBotToken` + `telegramChatId`, `slackWebhookUrl`, `teamsWebhookUrl` or `googleChatWebhookUrl`, or use `ntfyTopic` (free, no account) or `pushoverUserKey` + `pushoverAppToken` for phone pushes. Mattermost and Rocket.Chat work through `slackCompatibleWebhookUrl`. With `onlyNewSinceLastRun` on and a schedule, each run sends only the posts it has not delivered before. Setup steps for each are in the alerts section above. Notifications cost nothing extra.

**Can I get Substack post alerts by email?** Not natively. There are two routes. (1) Set `webhookUrl` to a Zapier, Make or n8n catch hook and add an email or Gmail step: the webhook delivers every row as JSON, so the email can list the posts. (2) Apify's own run integrations and run notifications can email you when a run finishes, but they only send a link to the run or dataset, not the posts themselves. For instant alerts without building anything, Telegram, ntfy or Pushover reach your phone directly.

**Can I get Substack post alerts in WhatsApp?** Not natively, and we do not use unofficial WhatsApp APIs, which risk getting your number banned. The official route is the WhatsApp Business Platform (Cloud API) with its own business account, message templates and pricing: point `webhookUrl` at a Zapier, Make or n8n flow that calls it. For free phone alerts use Telegram or ntfy instead.

### More from this publisher

- **[Vinted Scraper & New Listing Alerts](https://apify.com/lukehunter/vinted-scraper)** — public Vinted search listings with new-item alerts.
- **[Vinted Cross-Country Prices](https://apify.com/lukehunter/vinted-cross-country-prices)** — compare public Vinted asking prices across countries.
- **[Reed Jobs Scraper](https://apify.com/lukehunter/reed-jobs-scraper)** — public UK job search listings.
- **[Jobindex Jobs Scraper](https://apify.com/lukehunter/jobindex-jobs-scraper)** — public Denmark job search listings.
- **[Pracuj.pl Jobs Scraper](https://apify.com/lukehunter/pracuj-jobs-scraper)** — public Poland job search listings.

# Actor input Schema

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

Public Substack publication home URLs, including custom domains. The Actor requests only /robots.txt, public /api/v1/archive pages, and /feed as a 404 fallback. Maximum 50.

## `maxPagesPerSearch` (type: `integer`):

Public archive pages to consider per publication, 1-10. The public feed fallback is a single response.

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

Hard cap on delivered post rows, 1-5000. You are charged only for delivered rows.

## `onlyNewSinceLastRun` (type: `boolean`):

When on, remember delivered post ids per publication and deliver only ids not seen on previous runs. The first run establishes the baseline.

## `stateStoreName` (type: `string`):

Named key-value store used only by new-post alert mode. Letters, numbers and hyphens only.

## `discordWebhookUrl` (type: `string`):

Post results to a Discord channel. In Discord: Server Settings -> Integrations -> Webhooks -> New Webhook -> choose the channel -> Copy Webhook URL. Looks like https://discord.com/api/webhooks/<id>/<token>. Leave empty to skip Discord.

## `telegramBotToken` (type: `string`):

Post results to Telegram. Create a bot by chatting with @BotFather on Telegram (send /newbot) and paste the token it gives you, e.g. 123456789:AA.... Needs "Telegram chat ID" below. Leave empty to skip Telegram.

## `telegramChatId` (type: `string`):

Where the bot should post: a numeric chat id (e.g. 123456789, or -1001234567890 for a group or channel) or a public @channelusername. The bot must be added to that chat or channel first (as an administrator for a channel), and for a private chat you must press Start on the bot. Needs "Telegram bot token" above.

## `slackWebhookUrl` (type: `string`):

Post results to a Slack channel (Block Kit cards, up to 10 per message). Create an incoming webhook at api.slack.com/apps -> Create New App -> Incoming Webhooks -> Add New Webhook to Workspace. Looks like https://hooks.slack.com/services/T000/B000/XXXX. Leave empty to skip Slack.

## `slackCompatibleWebhookUrl` (type: `string`):

Post results to a Mattermost or Rocket.Chat incoming webhook, which accept Slack-style webhook payloads. Must be a public https:// address (no localhost, private IP or .local/.internal hosts). These apps do not render Slack Block Kit, so they get a plain Markdown list. For real Slack use "Slack webhook URL" above. Leave empty to skip.

## `teamsWebhookUrl` (type: `string`):

Post results to a Teams channel as an Adaptive Card. In Teams: channel -> ... -> Workflows -> "Post to a channel when a webhook request is received" -> copy the URL. The host must end in .logic.azure.com or .powerplatform.com. The retired Office 365 connector webhooks are not supported. Leave empty to skip Teams.

## `googleChatWebhookUrl` (type: `string`):

Post results to a Google Chat space. In the space: Apps & integrations -> Webhooks -> Add webhook -> copy the URL. Looks like https://chat.googleapis.com/v1/spaces/<space>/messages?key=...\&token=.... Leave empty to skip Google Chat.

## `ntfyTopic` (type: `string`):

Get a phone push with no account via ntfy (ntfy.sh). Install the ntfy app, subscribe to a topic name, and enter the same name here. Anyone who knows the topic can read it, so pick a long, unguessable name (letters, numbers, - and \_). At most 10 individual pushes per run, then one "...and N more". Leave empty to skip ntfy.

## `ntfyServer` (type: `string`):

Only used with "ntfy topic". Leave as https://ntfy.sh, or enter the public https:// address of your own ntfy server.

## `ntfyToken` (type: `string`):

Only used with "ntfy topic", for a self-hosted server or a reserved topic that needs a login. An access token from ntfy (starts with tk\_). Leave empty for open topics.

## `pushoverUserKey` (type: `string`):

Get a phone push via Pushover. Your user key is shown on the Pushover dashboard (pushover.net). Needs "Pushover app token" below. At most 10 individual pushes per run, then one "...and N more". Leave empty to skip Pushover.

## `pushoverAppToken` (type: `string`):

The API token of a Pushover application you create at pushover.net/apps/build (name it after this Actor). Needs "Pushover user key" above.

## `webhookUrl` (type: `string`):

POST the delivered rows as JSON to any public https:// URL: {source, actor, runId, count, items}. At most 100 rows per POST; every delivered row is sent regardless of the max-notifications cap. Use it to route results to email, a spreadsheet or any app. Localhost, private IP and .local/.internal addresses are rejected. Leave empty to skip.

## `maxNotifications` (type: `integer`):

Caps how many results are sent to chat and phone channels per run (Discord, Telegram, Slack, Teams, Google Chat, ntfy, Pushover), 1-100, default 25. Extra results are still in the dataset. The generic webhook is not capped. Only used when a destination above is set.

## Actor input object example

```json
{
  "publicationUrls": [
    "https://www.lennysnewsletter.com"
  ],
  "maxPagesPerSearch": 2,
  "maxItems": 20,
  "onlyNewSinceLastRun": false,
  "stateStoreName": "substack-scraper-seen-posts",
  "ntfyServer": "https://ntfy.sh",
  "maxNotifications": 25
}
```

# Actor output Schema

## `items` (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 = {
    "publicationUrls": [
        "https://www.lennysnewsletter.com"
    ],
    "maxPagesPerSearch": 2,
    "maxItems": 20,
    "onlyNewSinceLastRun": false,
    "stateStoreName": "substack-scraper-seen-posts"
};

// Run the Actor and wait for it to finish
const run = await client.actor("lukehunter/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 = {
    "publicationUrls": ["https://www.lennysnewsletter.com"],
    "maxPagesPerSearch": 2,
    "maxItems": 20,
    "onlyNewSinceLastRun": False,
    "stateStoreName": "substack-scraper-seen-posts",
}

# Run the Actor and wait for it to finish
run = client.actor("lukehunter/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 '{
  "publicationUrls": [
    "https://www.lennysnewsletter.com"
  ],
  "maxPagesPerSearch": 2,
  "maxItems": 20,
  "onlyNewSinceLastRun": false,
  "stateStoreName": "substack-scraper-seen-posts"
}' |
apify call lukehunter/substack-scraper --silent --output-dataset

```

## MCP server setup

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