{
  "openapi": "3.1.0",
  "info": {
    "title": "FetchLayer Reddit API — Community",
    "version": "1.0.0",
    "description": "Subreddit metadata, posts, and discovery."
  },
  "servers": [
    {
      "url": "https://api.fetchlayer.dev/reddit"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Send your FetchLayer key as Authorization: Bearer ss-your-key. No Reddit OAuth credentials are required."
      }
    }
  },
  "paths": {
    "/community-posts": {
      "post": {
        "operationId": "community-posts",
        "tags": [
          "Community"
        ],
        "summary": "Posts from any subreddit — hot, new, top, rising",
        "description": "Retrieve the current post feed for a subreddit. Supports sorting by hot, new, top, rising, and controversy.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subreddit": {
                    "type": "string",
                    "description": "Subreddit name (without r/)."
                  },
                  "sort": {
                    "type": "string",
                    "description": "Feed sort order.",
                    "example": "hot"
                  },
                  "limit": {
                    "type": "number",
                    "description": "Number of posts (max 100).",
                    "example": "25"
                  },
                  "time": {
                    "type": "string",
                    "description": "Time filter for top sort.",
                    "example": "all"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "subreddit"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "subreddit": "programming",
                    "sort": "top",
                    "limit": 10,
                    "time": "week"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "posts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "title": {
                            "type": "string",
                            "description": "Post title."
                          },
                          "author": {
                            "type": "string",
                            "description": "Author username."
                          },
                          "score": {
                            "type": "number",
                            "description": "Upvote score."
                          },
                          "numComments": {
                            "type": "number",
                            "description": "Comment count."
                          },
                          "permalink": {
                            "type": "string",
                            "description": "Relative permalink."
                          },
                          "createdUtc": {
                            "type": "number",
                            "description": "Unix timestamp."
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "additionalProperties": false
                },
                "examples": {
                  "default": {
                    "value": {
                      "posts": [
                        {
                          "title": "Example programming post",
                          "author": "coder123",
                          "score": 2500,
                          "numComments": 320,
                          "permalink": "/r/programming/comments/xyz/",
                          "createdUtc": 1718000000
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing Bearer token"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/community-details": {
      "post": {
        "operationId": "community-details",
        "tags": [
          "Community"
        ],
        "summary": "Subreddit metadata — subscribers, description, rules",
        "description": "Get detailed metadata about a subreddit including subscriber count, active users, description, rules, and moderation info.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subreddit": {
                    "type": "string",
                    "description": "Subreddit name (without r/)."
                  }
                },
                "additionalProperties": false,
                "required": [
                  "subreddit"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "subreddit": "programming"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Subreddit display name."
                    },
                    "title": {
                      "type": "string",
                      "description": "Subreddit title."
                    },
                    "description": {
                      "type": "string",
                      "description": "Sidebar/description text."
                    },
                    "subscribers": {
                      "type": "number",
                      "description": "Subscriber count."
                    },
                    "activeUsers": {
                      "type": "number",
                      "description": "Currently active users."
                    },
                    "createdUtc": {
                      "type": "number",
                      "description": "Creation timestamp."
                    },
                    "rules": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      },
                      "description": "Array of rule objects with title and description."
                    }
                  },
                  "additionalProperties": false
                },
                "examples": {
                  "default": {
                    "value": {
                      "name": "programming",
                      "title": "Programming",
                      "description": "Computer Programming",
                      "subscribers": 35000000,
                      "activeUsers": 45000,
                      "createdUtc": 1200000000,
                      "rules": [
                        {
                          "title": "No spam",
                          "description": "Self-promotion is not allowed."
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing Bearer token"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    }
  }
}