{
  "openapi": "3.0.1",
  "info": {
    "title": "Substack Scraper — Posts, Markdown, Comments & Leaderboards",
    "description": "Extract Substack posts (clean LLM-ready Markdown & plain text), nested comments, and Bestseller/Rising category leaderboards with custom domain support. Fast pure-HTTP API, no proxies needed, MCP & Clay ready.",
    "version": "1.0",
    "x-build-id": "WfV8KfE7HdxzsApzP"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/shawn1905~substack-intelligence-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-shawn1905-substack-intelligence-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/shawn1905~substack-intelligence-scraper/runs": {
      "post": {
        "operationId": "runs-sync-shawn1905-substack-intelligence-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/shawn1905~substack-intelligence-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-shawn1905-substack-intelligence-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Scraping Mode",
            "enum": [
              "publication_posts",
              "post_urls",
              "category_leaderboard"
            ],
            "type": "string",
            "description": "Choose what to extract: posts from publications, specific post URLs, or Substack category leaderboards (great for B2B lead generation & newsletter discovery).",
            "default": "publication_posts"
          },
          "publications": {
            "title": "Publications (Subdomains, Handles, or Custom Domain URLs)",
            "type": "array",
            "description": "Used in 'publication_posts' mode. Accepts handles (e.g. 'stratechery'), *.substack.com URLs, or custom domains (e.g. 'https://www.lennysnewsletter.com', 'https://blog.bytebytego.com').",
            "items": {
              "type": "string"
            },
            "default": [
              "https://www.lennysnewsletter.com"
            ]
          },
          "postUrls": {
            "title": "Post URLs",
            "type": "array",
            "description": "Used in 'post_urls' mode. Direct links to Substack articles (e.g. 'https://blog.bytebytego.com/p/ep234-docker-vs-kubernetes').",
            "items": {
              "type": "string"
            }
          },
          "categories": {
            "title": "Leaderboard Categories",
            "type": "array",
            "description": "Used in 'category_leaderboard' mode. Category slugs or IDs such as 'technology', 'finance', 'business', 'culture', 'crypto', 'us-politics', 'food', 'sports', 'news', 'health'.",
            "items": {
              "type": "string"
            }
          },
          "leaderboardType": {
            "title": "Leaderboard Type",
            "enum": [
              "top",
              "rising"
            ],
            "type": "string",
            "description": "Used in 'category_leaderboard' mode: scrape top Bestsellers or Rising publications.",
            "default": "top"
          },
          "maxLeaderboardPages": {
            "title": "Max Leaderboard Pages per Category",
            "minimum": 1,
            "maximum": 40,
            "type": "integer",
            "description": "Each page returns ~25 publications (e.g., 4 pages = ~100 publications per category).",
            "default": 2
          },
          "sort": {
            "title": "Post Sort Order",
            "enum": [
              "new",
              "top"
            ],
            "type": "string",
            "description": "Sort order when scraping publication archives.",
            "default": "new"
          },
          "maxPostsPerPublication": {
            "title": "Max Posts per Publication",
            "minimum": 1,
            "maximum": 5000,
            "type": "integer",
            "description": "Maximum number of posts to retrieve per publication.",
            "default": 20
          },
          "publishedAfter": {
            "title": "Published After (ISO Date, optional)",
            "type": "string",
            "description": "Only include posts published on or after this date (YYYY-MM-DD). Stops pagination early in 'new' sort mode."
          },
          "keywordFilter": {
            "title": "Keyword Filter (optional)",
            "type": "string",
            "description": "Case-insensitive keyword filter applied to post title, subtitle, and slug."
          },
          "freeOnly": {
            "title": "Free Posts Only",
            "type": "boolean",
            "description": "If enabled, skip paywalled (only_paid) posts.",
            "default": false
          },
          "includeFullContent": {
            "title": "Include Full Article Content (Clean Markdown + Plain Text)",
            "type": "boolean",
            "description": "Fetch each post's full body and convert HTML into clean LLM/RAG-ready Markdown, plain text, and outbound links.",
            "default": true
          },
          "includeRawHtml": {
            "title": "Include Raw HTML",
            "type": "boolean",
            "description": "Also include the raw body_html field in output (off by default to keep datasets compact).",
            "default": false
          },
          "includeComments": {
            "title": "Include Comments & Replies",
            "type": "boolean",
            "description": "Fetch comments for each scraped post and push them as structured records (recordType: 'comment').",
            "default": false
          },
          "maxCommentsPerPost": {
            "title": "Max Comments per Post",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Maximum total comments (including nested replies) to collect per post when 'includeComments' is enabled.",
            "default": 50
          },
          "requestDelayMs": {
            "title": "Request Delay (ms)",
            "minimum": 0,
            "maximum": 5000,
            "type": "integer",
            "description": "Polite delay between consecutive HTTP requests to avoid rate limits.",
            "default": 250
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}