{
  "openapi": "3.1.0",
  "info": {
    "title": "FetchLayer Reddit API — Discover",
    "version": "1.0.0",
    "description": "Trending content and community exploration."
  },
  "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": {
    "/popular": {
      "post": {
        "operationId": "popular",
        "tags": [
          "Discover"
        ],
        "summary": "r/popular — trending posts across Reddit right now",
        "description": "Get the current r/popular feed. See what's trending across all of Reddit in real time.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "number",
                    "description": "Number of posts (max 100).",
                    "example": "25"
                  }
                },
                "additionalProperties": false
              },
              "examples": {
                "default": {
                  "value": {
                    "limit": 10
                  }
                }
              }
            }
          }
        },
        "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."
                          },
                          "subreddit": {
                            "type": "string",
                            "description": "Subreddit."
                          },
                          "author": {
                            "type": "string",
                            "description": "Author."
                          },
                          "score": {
                            "type": "number",
                            "description": "Score."
                          },
                          "numComments": {
                            "type": "number",
                            "description": "Comment count."
                          },
                          "permalink": {
                            "type": "string",
                            "description": "Permalink."
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "additionalProperties": false
                },
                "examples": {
                  "default": {
                    "value": {
                      "posts": [
                        {
                          "title": "Trending post",
                          "subreddit": "popular",
                          "author": "user123",
                          "score": 10000,
                          "numComments": 2000,
                          "permalink": "/r/popular/comments/xyz/"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing Bearer token"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/leaderboard": {
      "post": {
        "operationId": "leaderboard",
        "tags": [
          "Discover"
        ],
        "summary": "Trending communities leaderboard",
        "description": "Get a leaderboard of trending communities by subscriber growth, activity, or other metrics.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "number",
                    "description": "Number of communities.",
                    "example": "25"
                  }
                },
                "additionalProperties": false
              },
              "examples": {
                "default": {
                  "value": {
                    "limit": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "leaderboard": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "rank": {
                            "type": "number",
                            "description": "Rank position."
                          },
                          "name": {
                            "type": "string",
                            "description": "Subreddit name."
                          },
                          "subscribers": {
                            "type": "number",
                            "description": "Subscriber count."
                          },
                          "growth": {
                            "type": "number",
                            "description": "Growth percentage."
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "additionalProperties": false
                },
                "examples": {
                  "default": {
                    "value": {
                      "leaderboard": [
                        {
                          "rank": 1,
                          "name": "programming",
                          "subscribers": 35000000,
                          "growth": 2.5
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing Bearer token"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/explore": {
      "post": {
        "operationId": "explore",
        "tags": [
          "Discover"
        ],
        "summary": "Browse communities grouped by topic",
        "description": "Explore subreddits organized by topic/category. Returns a curated list of communities across different interests.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "category": {
                    "type": "string",
                    "description": "Topic category filter."
                  },
                  "limit": {
                    "type": "number",
                    "description": "Max results.",
                    "example": "50"
                  }
                },
                "additionalProperties": false
              },
              "examples": {
                "default": {
                  "value": {
                    "category": "technology",
                    "limit": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "Category name."
                          },
                          "communities": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "description": "Subreddit name."
                                },
                                "subscribers": {
                                  "type": "number",
                                  "description": "Subscriber count."
                                }
                              },
                              "additionalProperties": false
                            }
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "additionalProperties": false
                },
                "examples": {
                  "default": {
                    "value": {
                      "categories": [
                        {
                          "name": "technology",
                          "communities": [
                            {
                              "name": "programming",
                              "subscribers": 35000000
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing Bearer token"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    }
  }
}