{
  "openapi": "3.0.1",
  "info": {
    "title": "Reddit Posts, Comments & Subreddit Analytics Scraper",
    "description": "Scrape Reddit posts, comments & subreddit analytics via JSON API. No browser, no login, no API key. Structured JSON for AI, research & monitoring.",
    "version": "1.0",
    "x-build-id": "eYtlTmqaM56YE0KzV"
  },
  "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.",
            "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 all-time best (use with timeFilter), 'rising' for gaining traction, 'comments' for most-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
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}