# Substack Leaderboard Scraper (`scrapers-hub/substack-leaderboard-scraper`) Actor

Substack Leaderboard Scraper Substack Leaderboard scraper extracts publicly available ranking data, newsletter names, authors, categories, subscriber indicators, and leaderboard metrics 🏆📰 Perfect for market research, creator discovery, trend analysis, and competitive intelligence.

- **URL**: https://apify.com/scrapers-hub/substack-leaderboard-scraper.md
- **Developed by:** [Scrapers Hub](https://apify.com/scrapers-hub) (community)
- **Categories:** Developer tools, News, Other
- **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 Leaderboard Scraper

Scrapes the **full publication object** for every newsletter on a Substack
category leaderboard (e.g. *Technology → paid*), in leaderboard rank order.

### How it works

1. Each leaderboard URL is parsed into a category **slug** and a ranking
   **type** — `https://substack.com/leaderboard/technology/paid` → `technology`, `paid`.
2. The slug is resolved to a numeric category id via
   `GET https://substack.com/api/v1/categories` (with a bundled fallback map).
3. Publications are read from the public leaderboard API, paginated 25 at a time:
   `GET https://substack.com/api/v1/category/public/{categoryId}/{type}?page=N&limit=25`.
   This endpoint already returns the complete publication object
   (`plans`, `theme`, `appTheme`, `contributors`, `logoPalette`, subscriber
   ranking details, …) — no per-publication request is needed.
4. Every publication is pushed to the dataset, enriched with `leaderboardUrl`,
   `leaderboardRank`, and `scrapedAt`.

### Networking

Built on the requested stack:

- **`requests`** — primary HTTP client.
- **`curl_cffi`** — automatic fallback with a real Chrome TLS fingerprint,
  used whenever `requests` returns a block/challenge (401/403/407/429/503 or a
  challenge page) or raises.
- **`regex`** — leaderboard-URL parsing and embedded-JSON (`window._preloads`) extraction.
- **`parsel`** — lightweight HTML parsing (page title / validation).

Apify Proxy is used by default; a pool of pre-rotated proxy URLs is cycled
across requests.

### Input

| Field | Type | Description |
|-------|------|-------------|
| `leaderboardUrls` | `string[]` | One or more `https://substack.com/leaderboard/<category>/<paid\|free>` URLs. **Required.** |
| `maxItems` | `integer` | Max publications to scrape in total. `0` = unlimited. Default `50`. |
| `proxyConfiguration` | `object` | Proxy settings. Default: Apify Proxy. |

```json
{
  "leaderboardUrls": ["https://substack.com/leaderboard/technology/paid"],
  "maxItems": 50,
  "proxyConfiguration": { "useApifyProxy": true }
}
```

### Output

One dataset item per publication — the full Substack publication object plus:

- `leaderboardUrl` — the source leaderboard URL.
- `leaderboardRank` — 1-based rank on that leaderboard.
- `scrapedAt` — ISO-8601 timestamp (`...Z`).

### Run locally

```bash
pip install -r requirements.txt
apify run       # requires the Apify CLI
```

# Actor input Schema

## `leaderboardUrls` (type: `array`):

One or more Substack leaderboard URLs, e.g. https://substack.com/leaderboard/technology/paid . The category slug and ranking type (paid / free) are read from the URL path.

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

Maximum number of publications to scrape in total (across all leaderboard URLs). Leave at 0 to scrape every available publication.

## Actor input object example

```json
{
  "leaderboardUrls": [
    "https://substack.com/leaderboard/technology/paid"
  ],
  "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 = {
    "leaderboardUrls": [
        "https://substack.com/leaderboard/technology/paid"
    ],
    "maxItems": 50
};

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

# Run the Actor and wait for it to finish
run = client.actor("scrapers-hub/substack-leaderboard-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 '{
  "leaderboardUrls": [
    "https://substack.com/leaderboard/technology/paid"
  ],
  "maxItems": 50
}' |
apify call scrapers-hub/substack-leaderboard-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/jS1f51IbHRM51wIee/builds/mueTlZ8xcgkzgLx9p/openapi.json
