> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scraperize.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Subreddit search

> Searches one subreddit like its own search page: posts (7 per page), media posts (images and videos) or comments (10 per page), sorted by relevance, hot, top, new or most comments (comments: relevance, top or new), over a time range (posts and media). Posts come with their title, link, author, time, score, comment count, matching snippet and thumbnail; comments with their text, author, time, link and the post they were left on (its title, score and comment count). Leave `query` empty to browse everything. Pass the returned `cursor` back (with the same subreddit and query) for the next page. NSFW communities return 403. Only publicly available data is returned.

> [!NOTE]
>
> **Cost: 1 credit** per successful request. Errors and cache hits (`cache_max_age`) are free.

> [accordion] Copy for AI assistant
>
> Paste this into ChatGPT, Claude or your coding assistant to generate working code for this endpoint (use the copy button).
>
> ```text Prompt
> I want to make an API call to /v1/reddit/subreddit/search. Here are the details:
>
> Endpoint: GET https://api.scraperize.com/v1/reddit/subreddit/search
> Description: Searches one subreddit like its own search page: posts (7 per page), media posts (images and videos) or comments (10 per page), sorted by relevance, hot, top, new or most comments (comments: relevance, top or new), over a time range (posts and media). Posts come with their title, link, author, time, score, comment count, matching snippet and thumbnail; comments with their text, author, time, link and the post they were left on (its title, score and comment count). Leave `query` empty to browse everything. Pass the returned `cursor` back (with the same subreddit and query) for the next page. NSFW communities return 403. Only publicly available data is returned.
>
> Required Headers:
> - x-api-key: Your API key
>
> Parameters:
> - subreddit (string) [required]: The subreddit's name, with or without `r/`.
> - query (string): What to search for. Empty matches everything.
> - type (select): `posts` (default), `comments` or `media` (image and video posts).
> - sort (select): `relevance` (default), `hot`, `top`, `new` or `comments` (most commented). For `type=comments` only `relevance`, `top` or `new`.
> - timeframe (select): Posts / media only: `all` (default), `day`, `week`, `month` or `year`.
> - cursor (string): The `cursor` from the previous page (it keeps the type, sort and time range). Omit for the first page.
> - cache_max_age (select): Optional. Return a cached result if one this age or newer exists — served for **0 credits** with `meta.cached=true` and `meta.cachedAt`. Otherwise a fresh scrape runs (**1 credit**) and refreshes the cache. Omit to always scrape fresh.
>
> Example Response:
> {
>   "data": {
>     "subreddit": "programming",
>     "query": "rust",
>     "type": "posts",
>     "sort": "relevance",
>     "timeframe": null,
>     "results": [
>       {
>         "position": 1,
>         "id": "1vwyjg2",
>         "url": "https://www.reddit.com/r/programming/comments/1vwyjg2/what_zig_felt_like_coming_from_rust/",
>         "title": "What Zig felt like, coming from Rust",
>         "subreddit": "programming",
>         "subredditId": "t5_2fwo",
>         "subredditIconUrl": "https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png?width=64&frame=1&auto=webp&s=2545f3c0332e412c8635f5f2a5868c0e857ef040",
>         "author": "BrewedDoritos",
>         "authorId": "t2_vu94uqi5",
>         "createdAt": "2026-08-24T10:06:30.683Z",
>         "score": 269,
>         "commentCount": 173,
>         "snippet": null,
>         "thumbnailUrl": null,
>         "thumbnailWidth": null,
>         "thumbnailHeight": null,
>         "isNsfw": false,
>         "isSpoiler": false
>       }
>     ],
>     "count": 7,
>     "cursor": "eyJrIjoici9wcm9ncmFtbWluZyIsInEiOiJydXN0IiwieSI6InBvc3RzIiwibyI6bnVsbCwidCI6bnVsbCwiYyI6ImV5SmpZVzVrYVdSaGRHVnpYM0psZEhWeWJtVmtJam9pZTF3aWMyVmpkR2x2Ymw4eFgzQnBj…",
>     "hasMore": true,
>     "fetchedAt": "2026-11-06T12:49:06.296Z"
>   },
>   "meta": {
>     "requestId": "req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f",
>     "creditsCharged": 1,
>     "creditsRemaining": 4999,
>     "cached": false
>   }
> }
>
> Please help me write code in my preferred programming language to make this API call and handle the response appropriately. Include error handling and best practices.
> ```


## OpenAPI

````yaml /api-reference/openapi.json get /v1/reddit/subreddit/search
openapi: 3.0.3
info:
  title: Scraperize API
  version: 1.0.0
  description: >-
    Extract public data from social media platforms as clean JSON. Endpoints are
    split by platform and by what they return, e.g. `GET /v1/twitter/tweet`.


    ## Authentication

    Send your API key in the `x-api-key` header (or `Authorization: Bearer
    <key>`). Create keys in your dashboard.


    ## Credits

    Each successful live scrape costs **1 credit**. Credits are prepaid and
    never expire.


    ## Caching

    Every endpoint accepts an optional `cache_max_age`
    (`1d`|`3d`|`7d`|`14d`|`30d`). A cache hit within that window is returned for
    **0 credits**.


    ## Responses

    Success returns `{ "data": …, "meta": { "requestId", … } }`. Errors return
    `{ "error": { "code", "message", "requestId" } }` with a matching HTTP
    status. `meta` on a scrape carries `creditsCharged`, `creditsRemaining`,
    `cached`, and (on a hit) `cachedAt`.


    ## Rate limits

    Requests are limited per team per minute; over the limit returns `429` with
    a `Retry-After` header.
servers:
  - url: https://api.scraperize.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Twitter
    description: Twitter / X scraping endpoints
  - name: Facebook
    description: Facebook scraping endpoints
  - name: Linkme
    description: Linkme (link.me) scraping endpoints
  - name: Amazon
    description: Amazon (creator shop / storefront) scraping endpoints
  - name: Linkbio
    description: Linkbio (lnk.bio) scraping endpoints
  - name: Pillar
    description: Pillar (pillar.io) scraping endpoints
  - name: Komi
    description: Komi (komi.io) scraping endpoints
  - name: Linktree
    description: Linktree (linktr.ee) scraping endpoints
  - name: Kick
    description: Kick (kick.com) scraping endpoints
  - name: Snapchat
    description: Snapchat (snapchat.com) scraping endpoints
  - name: Telegram
    description: Telegram (t.me) scraping endpoints
  - name: LinkedIn
    description: LinkedIn scraping endpoints
  - name: Twitch
    description: Twitch scraping endpoints
  - name: TikTok
    description: TikTok (tiktok.com) scraping endpoints
  - name: Instagram
    description: Instagram scraping endpoints
  - name: Lagos Life
    description: Lagos Life scraping endpoints
  - name: Bluesky
    description: Bluesky (bsky.app) scraping endpoints
  - name: Threads
    description: Threads (threads.com) scraping endpoints
  - name: Reddit
    description: Reddit (reddit.com) scraping endpoints
  - name: Rumble
    description: Rumble (rumble.com) scraping endpoints
  - name: Truth Social
    description: Truth Social (truthsocial.com) scraping endpoints
  - name: YouTube
    description: YouTube (youtube.com) scraping endpoints
paths:
  /v1/reddit/subreddit/search:
    get:
      tags:
        - Reddit
      summary: Subreddit search
      description: >-
        Searches one subreddit like its own search page: posts (7 per page),
        media posts (images and videos) or comments (10 per page), sorted by
        relevance, hot, top, new or most comments (comments: relevance, top or
        new), over a time range (posts and media). Posts come with their title,
        link, author, time, score, comment count, matching snippet and
        thumbnail; comments with their text, author, time, link and the post
        they were left on (its title, score and comment count). Leave `query`
        empty to browse everything. Pass the returned `cursor` back (with the
        same subreddit and query) for the next page. NSFW communities return
        403. Only publicly available data is returned.
      parameters:
        - name: subreddit
          in: query
          required: true
          description: The subreddit's name, with or without `r/`.
          schema:
            type: string
          example: programming
        - name: query
          in: query
          required: false
          description: What to search for. Empty matches everything.
          schema:
            type: string
          example: rust
        - name: type
          in: query
          required: false
          description: '`posts` (default), `comments` or `media` (image and video posts).'
          schema:
            type: string
            enum:
              - posts
              - comments
              - media
            default: posts
        - name: sort
          in: query
          required: false
          description: >-
            `relevance` (default), `hot`, `top`, `new` or `comments` (most
            commented). For `type=comments` only `relevance`, `top` or `new`.
          schema:
            type: string
            enum:
              - relevance
              - hot
              - top
              - new
              - comments
            default: relevance
        - name: timeframe
          in: query
          required: false
          description: >-
            Posts / media only: `all` (default), `day`, `week`, `month` or
            `year`.
          schema:
            type: string
            enum:
              - all
              - day
              - week
              - month
              - year
        - name: cursor
          in: query
          required: false
          description: >-
            The `cursor` from the previous page (it keeps the type, sort and
            time range). Omit for the first page.
          schema:
            type: string
        - name: cache_max_age
          in: query
          required: false
          description: >-
            Optional. Return a cached result if one this age or newer exists —
            served for **0 credits** with `meta.cached=true` and
            `meta.cachedAt`. Otherwise a fresh scrape runs (**1 credit**) and
            refreshes the cache. Omit to always scrape fresh.
          schema:
            type: string
            enum:
              - 1d
              - 3d
              - 7d
              - 14d
              - 30d
          example: 7d
      responses:
        '200':
          description: One page of results (empty when nothing matches).
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      subreddit:
                        type: string
                      query:
                        type: string
                      type:
                        type: string
                      sort:
                        type: string
                      timeframe:
                        type: string
                        nullable: true
                      results:
                        type: array
                        items:
                          type: object
                      count:
                        type: integer
                      cursor:
                        type: string
                        nullable: true
                      hasMore:
                        type: boolean
                      fetchedAt:
                        type: string
                        format: date-time
                  meta:
                    type: object
                    description: >-
                      requestId + credit/caching metadata (creditsCharged,
                      creditsRemaining, cached, cachedAt).
                required:
                  - data
                  - meta
              example:
                data:
                  subreddit: programming
                  query: rust
                  type: posts
                  sort: relevance
                  timeframe: null
                  results:
                    - position: 1
                      id: 1vwyjg2
                      url: >-
                        https://www.reddit.com/r/programming/comments/1vwyjg2/what_zig_felt_like_coming_from_rust/
                      title: What Zig felt like, coming from Rust
                      subreddit: programming
                      subredditId: t5_2fwo
                      subredditIconUrl: >-
                        https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png?width=64&frame=1&auto=webp&s=2545f3c0332e412c8635f5f2a5868c0e857ef040
                      author: BrewedDoritos
                      authorId: t2_vu94uqi5
                      createdAt: '2026-08-24T10:06:30.683Z'
                      score: 269
                      commentCount: 173
                      snippet: null
                      thumbnailUrl: null
                      thumbnailWidth: null
                      thumbnailHeight: null
                      isNsfw: false
                      isSpoiler: false
                    - position: 2
                      id: 1x2et1j
                      url: >-
                        https://www.reddit.com/r/programming/comments/1x2et1j/rewriting_an_entire_ui_in_rust/
                      title: Rewriting an entire UI in Rust
                      subreddit: programming
                      subredditId: t5_2fwo
                      subredditIconUrl: >-
                        https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png?width=64&frame=1&auto=webp&s=2545f3c0332e412c8635f5f2a5868c0e857ef040
                      author: SpecialBread_
                      authorId: t2_205stvhcmj
                      createdAt: '2026-10-10T13:03:29.396Z'
                      score: 26
                      commentCount: 16
                      snippet: null
                      thumbnailUrl: null
                      thumbnailWidth: null
                      thumbnailHeight: null
                      isNsfw: false
                      isSpoiler: false
                    - position: 3
                      id: 1r97is7
                      url: >-
                        https://www.reddit.com/r/programming/comments/1r97is7/farewell_rust/
                      title: Farewell, Rust
                      subreddit: programming
                      subredditId: t5_2fwo
                      subredditIconUrl: >-
                        https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png?width=64&frame=1&auto=webp&s=2545f3c0332e412c8635f5f2a5868c0e857ef040
                      author: skwee357
                      authorId: t2_fv2di
                      createdAt: '2026-02-19T18:43:04.895Z'
                      score: 203
                      commentCount: 230
                      snippet: null
                      thumbnailUrl: null
                      thumbnailWidth: null
                      thumbnailHeight: null
                      isNsfw: false
                      isSpoiler: false
                  count: 7
                  cursor: >-
                    eyJrIjoici9wcm9ncmFtbWluZyIsInEiOiJydXN0IiwieSI6InBvc3RzIiwibyI6bnVsbCwidCI6bnVsbCwiYyI6ImV5SmpZVzVrYVdSaGRHVnpYM0psZEhWeWJtVmtJam9pZTF3aWMyVmpkR2x2Ymw4eFgzQnBjR1ZzYVc1bFh6QmZaMnh2WW1Gc1gyMXZaR2xtYVdWeWMxd2lPbHdpTVZ3aUxGd2ljMlZqZEdsdmJsOHhYM0JwY0dWc2FXNWxYekZmYkc5allXeGZiVzlrYVdacFpYSnpYQ0k2WENJeVhDSXNYQ0p6WldOMGFXOXVYekpmY0dsd1pXeHBibVZmTjE5elkyOXdaVjl6ZDJsMFkyaGxjbHdpT2x3aU1Gd2lMRndpYzJWamRHbHZibDh5WDNCcGNHVnNhVzVsWHpoZlpIbHVZVzFwWTE4d1gzQnZjM1JmYzJWaGNtTm9YQ0k2WENJM1hDSXNYQ0p6WldOMGFXOXVYek5mY0dsd1pXeHBibVZmTUY5emFXUmxZbUZ5WDJOdmJXMTFibWwwZVY5cGJtWnZYQ0k2WENJd1hDSjlJaXdpWlhod1pYSnBaVzVqWlY5elpXeGxZM1JwYjI0aU9pSndiM04wYzE5Mk1pSXNJbVY0Y0dWeWFXVnVZMlZmZG1WeWMybHZiaUk2SW1OdmJXMTFibWwwZVNJc0luTmxZM1JwYjI1Zk1sOXdhWEJsYkdsdVpWODRYMlI1Ym1GdGFXTmZNRjl3YjNOMFgzTmxZWEpqYUNJNklqY2lmUT09In0
                  hasMore: true
                  fetchedAt: '2026-11-06T12:49:06.296Z'
                meta:
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
                  creditsCharged: 1
                  creditsRemaining: 4999
                  cached: false
        '400':
          description: Invalid or expired cursor (or one for another subreddit or query).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: BAD_REQUEST
                  message: The request was invalid.
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
        '401':
          description: Missing, invalid, or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: UNAUTHORIZED
                  message: API key required — pass it in the `x-api-key` header.
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
        '402':
          description: Not enough credits for this request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: INSUFFICIENT_CREDITS
                  message: >-
                    This request costs 1 credit, but your balance is 0. Top up
                    to continue.
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
        '403':
          description: An NSFW (18+) subreddit — Reddit only shows it to signed-in adults.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            No public subreddit with that name (it may not exist, be private or
            banned).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: NOT_FOUND
                  message: >-
                    The requested content was not found (it may not exist, be
                    deleted, or be private).
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
        '422':
          description: >-
            Invalid query parameters (a sort or time range the chosen type has
            no option for).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: VALIDATION_ERROR
                  message: Request validation failed
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
                  details:
                    - path: url
                      message: url is required
        '429':
          description: Over the per-minute rate limit — honour `Retry-After`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: RATE_LIMITED
                  message: >-
                    Rate limit exceeded — max 100 requests per 60s. Retry in
                    ~30s.
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
        '503':
          description: >-
            Temporarily unavailable — retry after `Retry-After`. `error.code`
            tells you why: `UPSTREAM_BLOCKED` (the source blocked this request),
            `EXTRACTION_FAILED` (the source returned unexpected data),
            `PLATFORM_UNAVAILABLE` (the source is down), or
            `SERVICE_UNAVAILABLE` (we are at capacity).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: UPSTREAM_BLOCKED
                  message: >-
                    The source is temporarily unavailable. Please try again
                    shortly.
                  requestId: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: NOT_FOUND
            message:
              type: string
              example: The requested content was not found.
            requestId:
              type: string
              example: req_8f0c2b7e-1a2b-4c3d-9e8f-0a1b2c3d4e5f
            details:
              type: array
              items:
                type: object
              description: Present on validation errors.
          required:
            - code
            - message
            - requestId
      required:
        - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your API key. Send it in the `x-api-key` header (or `Authorization:
        Bearer <key>`). Create and manage keys from your dashboard.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.