{
  "openapi": "3.0.1",
  "info": {
    "title": "Reddit Posts, Comments & Subreddit Analytics Scraper",
    "description": "Scrape public Reddit posts, comments, search results and subreddit stats as structured JSON for research, AI and brand monitoring. No Reddit account or API key needed.",
    "version": "1.1",
    "x-build-id": "flUhHXtnpvyggv139"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/khadinakbar~reddit-posts-comments-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-khadinakbar-reddit-posts-comments-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/khadinakbar~reddit-posts-comments-scraper/runs": {
      "post": {
        "operationId": "runs-sync-khadinakbar-reddit-posts-comments-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/khadinakbar~reddit-posts-comments-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-khadinakbar-reddit-posts-comments-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": {
          "subredditUrls": {
            "title": "Subreddit URLs or names",
            "type": "array",
            "description": "Use this field when the user provides specific subreddit names or URLs to scrape posts from. Accepts full URLs (e.g., 'https://reddit.com/r/MachineLearning') or shorthand names (e.g., 'r/MachineLearning' or just 'MachineLearning'). Can be a list of multiple subreddits. Do NOT use this when the user wants to search all of Reddit by keyword — use searchQuery for that. Example triggers: 'scrape posts from r/Python', 'get top posts from MachineLearning subreddit', 'analyze r/wallstreetbets'."
          },
          "searchQuery": {
            "title": "Search query (across all of Reddit)",
            "type": "string",
            "description": "Use this field when the user provides a keyword, topic, or phrase to search across all of Reddit (not a specific subreddit). To scope the search to one subreddit, also set the withinSubreddit field. Do NOT use this when the user provides a specific subreddit URL or name — use subredditUrls for that. Example triggers: 'search Reddit for AI news', 'find posts about climate change', 'monitor mentions of my brand name on Reddit', 'what are people saying about ChatGPT'."
          },
          "withinSubreddit": {
            "title": "Scope search to one subreddit",
            "type": "string",
            "description": "Optional. When set alongside searchQuery, restricts the search to a single subreddit instead of searching all of Reddit. Accepts a subreddit name with or without the r/ prefix (e.g., 'r/MachineLearning' or 'MachineLearning'). Example triggers: 'search r/Python for pandas tips', 'find posts about GPT-4 in r/artificial', 'search within a subreddit'."
          },
          "postUrls": {
            "title": "Specific post URLs (with full comment threads)",
            "type": "array",
            "description": "Use this field when the user provides direct links to specific Reddit posts and wants to extract the post content plus all comments. Example triggers: 'get all comments from this post: reddit.com/r/.../comments/...', 'scrape this Reddit thread', 'extract the discussion from this specific Reddit URL'."
          },
          "maxPosts": {
            "title": "Maximum posts to scrape",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Maximum number of posts to return. Each post counts as one result in your quota. Set lower values for quick tests, higher for bulk research. Note: comments are charged separately. Free Apify plan runs return up to 660 results per run.",
            "default": 25
          },
          "maxCommentsPerPost": {
            "title": "Maximum comments per post",
            "minimum": 0,
            "maximum": 500,
            "type": "integer",
            "description": "Maximum number of comments to extract per post. Each comment counts as one result. Includes nested replies up to the depth limit. Set to 0 to skip comment extraction entirely (faster).",
            "default": 25
          },
          "commentDepthLimit": {
            "title": "Comment nesting depth limit",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "Maximum nesting depth to extract for comment threads. 0 = top-level comments only. 1 = top-level + one reply level. Higher values include deeper nested replies. Leave blank or set to a high value (e.g., 10) to extract all depths. Useful for AI/LLM use cases where deeply nested threads add noise.",
            "default": 10
          },
          "postDateLimit": {
            "title": "Ignore posts older than (date)",
            "type": "string",
            "description": "Optional. If set, skips any post created before this date. Use ISO 8601 format: 'YYYY-MM-DD' or full datetime 'YYYY-MM-DDTHH:MM:SSZ'. Example: '2025-01-01' to only get posts from 2025 onward. Works with all scrape modes (subreddit, search, post URLs). Example triggers: 'only posts from this year', 'posts after January 2025', 'recent posts only'."
          },
          "includeComments": {
            "title": "Include comments",
            "type": "boolean",
            "description": "When enabled, the actor automatically fetches and returns full comment threads for each post. Disable to scrape posts only — much faster and uses fewer credits.",
            "default": true
          },
          "includeSubredditAnalytics": {
            "title": "Include subreddit analytics",
            "type": "boolean",
            "description": "When enabled, fetches subreddit metadata (subscriber count, active users, description, rules) for each subreddit. One analytics record per subreddit. Disable if you only need post data.",
            "default": true
          },
          "sortBy": {
            "title": "Sort posts by",
            "enum": [
              "hot",
              "new",
              "top",
              "rising",
              "comments",
              "relevance"
            ],
            "type": "string",
            "description": "How to sort posts when scraping a subreddit. Use 'hot' for trending posts, 'new' for latest posts, 'top' for highly scored posts (use with timeFilter), 'rising' for gaining traction, 'comments' for heavily discussed posts, 'relevance' for search results.",
            "default": "hot"
          },
          "timeFilter": {
            "title": "Time filter (for top/search)",
            "enum": [
              "hour",
              "day",
              "week",
              "month",
              "year",
              "all"
            ],
            "type": "string",
            "description": "Time window for filtering posts when sortBy is 'top' or when searching. Use 'hour' for posts from the last hour, 'day' for today, 'week', 'month', 'year', or 'all' for all time. Ignored for 'hot', 'new', 'rising', and 'comments' sorts.",
            "default": "all"
          },
          "includeNsfw": {
            "title": "Include NSFW posts",
            "type": "boolean",
            "description": "When enabled, includes posts marked as NSFW (Not Safe For Work) in the results. Disabled by default to keep results suitable for business use cases.",
            "default": false
          },
          "urls": {
            "title": "Any Reddit URLs",
            "type": "array",
            "description": "Optional. One list for any Reddit links: subreddit URLs, post or comment URLs, and search URLs (reddit.com/search?q=...). Each link is routed automatically. Use this when you have a mixed list; the specific fields below also work.",
            "items": {
              "type": "string"
            }
          },
          "searchQueries": {
            "title": "More search queries",
            "type": "array",
            "description": "Optional. Several keyword searches in one run, one per line (brand names, competitors, topics). Combined with the single search field. Results are de-duplicated across searches.",
            "items": {
              "type": "string"
            }
          },
          "postedAfter": {
            "title": "Only posts after (date)",
            "type": "string",
            "description": "Optional. Skips posts created before this date. ISO format 'YYYY-MM-DD' or full datetime. Replaces the older 'Ignore posts older than' field, which still works."
          },
          "postedBefore": {
            "title": "Only posts before (date)",
            "type": "string",
            "description": "Optional. Skips posts created at or after this date. ISO format 'YYYY-MM-DD'. Use with Only posts after to get an exact window."
          },
          "maxPostAgeHours": {
            "title": "Only posts from the last N hours",
            "minimum": 0,
            "maximum": 87600,
            "type": "integer",
            "description": "Optional. For example 24 keeps only posts from the last day. 0 means no limit.",
            "default": 0
          },
          "keywordFilter": {
            "title": "Keep only posts mentioning",
            "type": "array",
            "description": "Optional. Keep a post only if its title or text contains at least one of these words (case-insensitive). Filtered posts are skipped before comments are fetched, so they cost nothing.",
            "items": {
              "type": "string"
            }
          },
          "keywordMode": {
            "title": "Keyword match scope",
            "enum": [
              "any",
              "titleonly"
            ],
            "type": "string",
            "description": "'any' searches title and text; 'titleonly' searches the title only.",
            "default": "any"
          },
          "minScore": {
            "title": "Minimum post score",
            "type": "integer",
            "description": "Optional. Skip posts with fewer upvotes (net score) than this. 0 keeps everything.",
            "default": 0
          },
          "minComments": {
            "title": "Minimum comment count",
            "minimum": 0,
            "type": "integer",
            "description": "Optional. Skip posts with fewer comments than this. Useful for finding active discussions.",
            "default": 0
          },
          "flairFilter": {
            "title": "Only these flairs",
            "type": "array",
            "description": "Optional. Keep only posts whose flair contains one of these words (for example 'Discussion', 'Question').",
            "items": {
              "type": "string"
            }
          },
          "commentSort": {
            "title": "Comment order",
            "enum": [
              "best",
              "top",
              "new",
              "old"
            ],
            "type": "string",
            "description": "Order of the top-level comments kept per post: 'best' (Reddit default), 'top' (highest score), 'new' or 'old'.",
            "default": "best"
          },
          "feedback": {
            "title": "Feedback (optional, for AI agents)",
            "type": "string",
            "description": "Optional. Say what you needed and did not get (a missing field, filter or wrong result). It is saved in the run summary and read by the maintainer. Does not change the results."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}