{
  "openapi": "3.0.1",
  "info": {
    "title": "Substack Scraper — Posts, Comments & Paraphrase with AI",
    "description": "Scrape Substack (substack.com) posts by keyword search, publication or post URL: title, author, date, full text, tags, reactions and comments with free sentiment, plus AI summaries. Cross-run caching returns only new posts. Export JSON, CSV, Excel or API.",
    "version": "1.0",
    "x-build-id": "Emb6i3qBGMjOrqdOH"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/confidential_gnat~substack-newsletter-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-confidential_gnat-substack-newsletter-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/confidential_gnat~substack-newsletter-scraper/runs": {
      "post": {
        "operationId": "runs-sync-confidential_gnat-substack-newsletter-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/confidential_gnat~substack-newsletter-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-confidential_gnat-substack-newsletter-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",
        "properties": {
          "startUrls": {
            "title": "Start URLs",
            "type": "array",
            "description": "Substack search, publication or post URLs. Accepts a substack.com search (https://substack.com/search/bitcoin), a publication home page or archive (https://astralcodexten.substack.com), and single post URLs (https://astralcodexten.substack.com/p/some-post). Publications on custom domains work too. Page type is detected automatically.",
            "default": [],
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "maxItems": {
            "title": "Max posts per start URL",
            "minimum": 0,
            "type": "integer",
            "description": "Maximum number of posts to scrape per start URL. Set to 0 for no limit.",
            "default": 5
          },
          "includePaywalled": {
            "title": "Include paywalled posts",
            "type": "boolean",
            "description": "Paid-subscriber posts return only a short public preview rather than the full text. Leave enabled to collect them with an isPaywalled flag, or disable to skip them entirely.",
            "default": true
          },
          "cacheProjectName": {
            "title": "Cache project name (scrape only new posts)",
            "type": "string",
            "description": "Scrape only new posts. Give this run a name (e.g. \"ai-newsletters\") and reuse it: every later run with the same name skips posts already collected and returns only newly published ones, so the same post is never scraped, enriched or billed twice. Ideal for scheduled monitoring. Leave empty to scrape everything every time."
          },
          "scrapeComments": {
            "title": "Scrape comments",
            "type": "boolean",
            "description": "Also collect each post's reader comments and replies, each classified as positive, negative, neutral or mixed. Sentiment classification is included at no extra charge.",
            "default": false
          },
          "maxCommentsPerPost": {
            "title": "Max comments per post",
            "minimum": 0,
            "type": "integer",
            "description": "Maximum comments (including replies) to collect per post, best comments first. Set to 0 for all comments.",
            "default": 5
          },
          "aiEnabled": {
            "title": "Enable AI enrichment",
            "type": "boolean",
            "description": "Enrich each post with an AI-generated summary, keywords, sentiment or paraphrase. Only runs on posts with a full body — paywalled previews are skipped and never charged.",
            "default": false
          },
          "aiFeatures": {
            "title": "AI features",
            "type": "array",
            "description": "Which enrichments to generate for each post.",
            "items": {
              "type": "string",
              "enum": [
                "summarize",
                "paraphrase",
                "keywords",
                "sentiment",
                "custom"
              ],
              "enumTitles": [
                "Summary",
                "Paraphrase",
                "Keywords",
                "Sentiment",
                "Custom instructions"
              ]
            },
            "default": [
              "summarize",
              "keywords",
              "sentiment"
            ]
          },
          "aiModels": {
            "title": "AI models",
            "type": "array",
            "description": "Models tried in order — the first that returns a usable result wins. A cheap primary with sturdier fallbacks behind it costs nothing extra on the happy path.",
            "items": {
              "type": "string",
              "enum": [
                "openai/gpt-4o-mini",
                "anthropic/claude-3.5-haiku",
                "google/gemini-2.0-flash-001",
                "meta-llama/llama-3.1-8b-instruct",
                "mistralai/mistral-small"
              ]
            },
            "default": [
              "openai/gpt-4o-mini"
            ]
          },
          "aiCustomInstructions": {
            "title": "Custom AI instructions",
            "maxLength": 2000,
            "type": "string",
            "description": "Used only when the 'custom' AI feature is selected. Describe what you want extracted from each post."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Proxy settings. Substack is reachable without a proxy, so proxies are disabled by default to keep runs cheap.",
            "default": {
              "useApifyProxy": true
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}