openapi: 3.0.0
info:
  title: Reddit Subreddit About API
  description: |
    The Reddit Subreddit About API returns the details of one subreddit: its title, description, icon and banner, creation date, who can post in it, and the weekly visitors and contributions Reddit shows for it, along with every rule in the order Reddit lists them and the community's bookmarks. Reddit hides the weekly counts on some subreddits, and the response leaves them out then. An NSFW subreddit is returned only when `safe` is `off`.

    **Cross-linking**: pass `subreddit.name` from a Reddit Search API result as `subreddit`, and pass this API's `subreddit.name` to the Reddit Subreddit API as `subreddit` for its posts.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Reddit Subreddit About
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["reddit_subreddit_about"]
            default: "reddit_subreddit_about"
        - name: subreddit
          in: query
          required: true
          description: Name of the subreddit, such as `aww` or `r/aww`, or a link to it or to its about, rules or wiki page.
          schema:
            type: string
        - name: safe
          in: query
          required: false
          description: Set to `off` to return an NSFW subreddit.
          schema:
            type: string
            enum: ["active", "off"]
            default: "active"
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        error:
          type: string
          description: Error message explaining why no subreddit was returned.
        subreddit:
          $ref: '#/components/schemas/Subreddit'
        rules:
          type: array
          description: Rules of the subreddit in the order Reddit lists them.
          items:
            $ref: '#/components/schemas/Rule'
        bookmarks:
          type: array
          description: Bookmarks the subreddit shows, in the order Reddit lists them.
          items:
            $ref: '#/components/schemas/Bookmark'
        text_widgets:
          type: array
          description: Text boxes the moderators added to the subreddit's sidebar, in the order Reddit shows them.
          items:
            $ref: '#/components/schemas/TextWidget'
        related_communities:
          type: array
          description: Communities the moderators list in the subreddit's sidebar.
          items:
            $ref: '#/components/schemas/RelatedCommunity'
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: Unique identifier for the search request
        status:
          type: string
          description: Status of the search request
        created_at:
          type: string
          format: date-time
          description: Timestamp when the search was created
        request_time_taken:
          type: number
          description: Time taken to make the request in seconds
        parsing_time_taken:
          type: number
          description: Time taken to parse the results in seconds
        total_time_taken:
          type: number
          description: Total time taken for the search in seconds
        request_url:
          type: string
          description: Reddit URL of the subreddit's about page
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        subreddit:
          type: string
          description: Subreddit whose details were returned
        safe:
          type: string
          description: NSFW filter setting
    Subreddit:
      type: object
      required: [id, name, link, created_at]
      properties:
        id:
          type: string
          description: Reddit fullname of the subreddit, prefixed with `t5_`.
        name:
          type: string
          description: Name of the subreddit.
        title:
          type: string
          description: Title of the subreddit.
        link:
          type: string
          description: Link to the subreddit.
        description:
          type: string
          description: Public description of the subreddit.
        icon:
          type: string
          description: Icon image of the subreddit.
        created_at:
          type: string
          format: date-time
          description: Date the subreddit was created, in ISO 8601.
        is_nsfw:
          type: boolean
          description: Whether the subreddit is marked NSFW.
        is_quarantined:
          type: boolean
          description: Whether Reddit has quarantined the subreddit.
        weekly_visitors:
          type: integer
          description: Number of people who visited the subreddit in the past week.
        weekly_contributions:
          type: integer
          description: Number of posts and comments made in the subreddit in the past week.
        visibility:
          type: string
          enum: ["public", "restricted"]
          description: Who can post in the subreddit, `public` for anyone or `restricted` for approved users.
        banner:
          type: string
          description: Banner image of the subreddit.
    Rule:
      type: object
      required: [position, title]
      properties:
        position:
          type: integer
          description: Number Reddit gives the rule in the subreddit's list.
        title:
          type: string
          description: Short title of the rule.
        description:
          type: string
          description: Full text of the rule.
    Bookmark:
      type: object
      required: [title]
      properties:
        title:
          type: string
          description: Label of the bookmark.
        link:
          type: string
          description: Link the bookmark opens.
        links:
          type: array
          description: Links in the bookmark's menu, in the order Reddit lists them.
          items:
            $ref: '#/components/schemas/BookmarkLink'
    BookmarkLink:
      type: object
      required: [title, link]
      properties:
        title:
          type: string
          description: Label of the link.
        link:
          type: string
          description: Link the menu item opens.
    TextWidget:
      type: object
      required: [text]
      properties:
        title:
          type: string
          description: Title of the text box.
        text:
          type: string
          description: Text of the box.
        text_links:
          type: array
          description: Links to pages outside Reddit in the text of the box.
          items:
            type: string
    RelatedCommunity:
      type: object
      required: [position, name, link]
      properties:
        position:
          type: integer
          description: Position of the community in the list.
        id:
          type: string
          description: Reddit fullname of the community, prefixed with `t5_`.
        name:
          type: string
          description: Name of the community.
        link:
          type: string
          description: Link to the community on Reddit.
        icon:
          type: string
          description: Icon image of the community.
        subscribers:
          type: integer
          description: Number of members of the community.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
