{
  "openapi": "3.0.1",
  "info": {
    "title": "Substack Scraper — Posts, Newsletters & Rankings",
    "description": "Official Substack public JSON API scraper & MCP tool. Extract full clean newsletter posts (cursor-paginated), paywall flags, likes/comments/restacks, author profiles, global search, and Paid/Rising/Trending category leaderboards. $1.50/1k, free count mode, zero proxy.",
    "version": "1.0",
    "x-build-id": "mrUVhS5Z8gcDM2Uar"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/yannabadie~substack-api-mcp/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-yannabadie-substack-api-mcp",
        "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/yannabadie~substack-api-mcp/runs": {
      "post": {
        "operationId": "runs-sync-yannabadie-substack-api-mcp",
        "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/yannabadie~substack-api-mcp/run-sync": {
      "post": {
        "operationId": "run-sync-yannabadie-substack-api-mcp",
        "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": {
          "mode": {
            "title": "Execution Mode",
            "enum": [
              "posts",
              "leaderboard",
              "search",
              "count"
            ],
            "type": "string",
            "description": "Choose 'posts' to extract articles from one or more Substack publications, 'leaderboard' to scrape ranked Paid/Rising/Trending newsletters by category, 'search' for global Substack post/publication search, or 'count' for a FREE ($0 record charge) preview.",
            "default": "posts"
          },
          "publications": {
            "title": "Substack Publications or Post URLs",
            "type": "array",
            "description": "Used in 'posts' (and 'count' with target='posts'). Accepts custom domains (https://www.lennysnewsletter.com), Substack subdomains (garymarcus.substack.com), bare handles (garymarcus), or direct post URLs (/p/slug).",
            "items": {
              "type": "string"
            },
            "default": [
              "https://www.lennysnewsletter.com"
            ]
          },
          "sortBy": {
            "title": "Archive Sort Order",
            "enum": [
              "new",
              "top"
            ],
            "type": "string",
            "description": "Sort order when fetching a publication archive ('new' = newest first, 'top' = most popular).",
            "default": "new"
          },
          "includeFullBody": {
            "title": "Include Full Plain-Text Post Body",
            "type": "boolean",
            "description": "Fetch full untruncated article HTML from /api/v1/posts/{slug} and convert to clean plain text (bodyText). Disable for ultra-fast metadata-only extraction.",
            "default": true
          },
          "onlyFreePosts": {
            "title": "Only Free (Non-Paywalled) Posts",
            "type": "boolean",
            "description": "Exclude paid-subscriber-only posts (audience = only_paid).",
            "default": false
          },
          "publishedAfter": {
            "title": "Published After (YYYY-MM-DD)",
            "type": "string",
            "description": "Optional ISO date cutoff for 'posts' mode (e.g. 2026-01-01). Stops pagination early when sortBy='new'.",
            "default": ""
          },
          "category": {
            "title": "Leaderboard Category",
            "type": "string",
            "description": "Used in 'leaderboard' mode. Substack category slug (e.g. technology, business, finance, culture, science, news, us-politics, climate, health, food, sports, design) or numeric category ID.",
            "default": "technology"
          },
          "ranking": {
            "title": "Leaderboard Ranking Type",
            "enum": [
              "paid",
              "rising",
              "trending",
              "top",
              "free",
              "all"
            ],
            "type": "string",
            "description": "Ranking tab for 'leaderboard' mode.",
            "default": "paid"
          },
          "query": {
            "title": "Search Query / Keyword Filter",
            "type": "string",
            "description": "Search query for 'search' mode (e.g. 'AI agents'), or optional case-insensitive keyword filter applied to title/subtitle/body in 'posts' mode.",
            "default": ""
          },
          "searchType": {
            "title": "Global Search Target",
            "enum": [
              "posts",
              "publications"
            ],
            "type": "string",
            "description": "Choose whether 'search' mode returns matching posts or matching publications.",
            "default": "posts"
          },
          "countTargetMode": {
            "title": "Count Mode Target",
            "enum": [
              "posts",
              "leaderboard",
              "search"
            ],
            "type": "string",
            "description": "Only used when mode='count': chooses which endpoint to preview for free.",
            "default": "posts"
          },
          "maxResults": {
            "title": "Maximum Records",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Maximum number of posts or publication records to return (1–2000).",
            "default": 20
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}