{
  "openapi": "3.1.0",
  "info": {
    "title": "FetchLayer Reddit API — Content",
    "version": "1.0.0",
    "description": "Retrieve posts, comments, and threaded discussions."
  },
  "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": {
    "/post": {
      "post": {
        "operationId": "post",
        "tags": [
          "Content"
        ],
        "summary": "Full post body + complete comment tree (paginated)",
        "description": "Retrieve a single post by its Reddit ID (t3_xxxxx) or full URL. Returns the post body, metadata, and paginated comments.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "postId": {
                    "type": "string",
                    "description": "Reddit post ID (e.g. t3_abc123) or full URL."
                  },
                  "sort": {
                    "type": "string",
                    "description": "Comment sort order.",
                    "example": "best"
                  },
                  "limit": {
                    "type": "number",
                    "description": "Max comments to return.",
                    "example": "100"
                  },
                  "depth": {
                    "type": "number",
                    "description": "How many levels of replies to include.",
                    "example": "3"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "postId"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "postId": "t3_abc123",
                    "sort": "top",
                    "limit": 50
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "post": {
                      "type": "object",
                      "properties": {
                        "title": {
                          "type": "string",
                          "description": "Post title."
                        },
                        "selftext": {
                          "type": "string",
                          "description": "Post body text (may be empty for link posts)."
                        },
                        "author": {
                          "type": "string",
                          "description": "Author username."
                        },
                        "score": {
                          "type": "number",
                          "description": "Upvote score."
                        },
                        "upvoteRatio": {
                          "type": "number",
                          "description": "Upvote ratio (0–1)."
                        },
                        "numComments": {
                          "type": "number",
                          "description": "Total comment count."
                        },
                        "url": {
                          "type": "string",
                          "description": "URL the post links to (if link post)."
                        },
                        "permalink": {
                          "type": "string",
                          "description": "Reddit permalink."
                        },
                        "createdUtc": {
                          "type": "number",
                          "description": "Unix timestamp."
                        },
                        "edited": {
                          "type": "boolean",
                          "description": "Whether the post was edited."
                        }
                      },
                      "additionalProperties": false
                    },
                    "comments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Comment ID."
                          },
                          "author": {
                            "type": "string",
                            "description": "Comment author."
                          },
                          "body": {
                            "type": "string",
                            "description": "Comment text."
                          },
                          "score": {
                            "type": "number",
                            "description": "Comment score."
                          },
                          "replies": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "additionalProperties": true
                            },
                            "description": "Nested reply objects."
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "additionalProperties": false
                },
                "examples": {
                  "default": {
                    "value": {
                      "post": {
                        "title": "Example post",
                        "selftext": "This is the post body...",
                        "author": "reddituser",
                        "score": 1500,
                        "upvoteRatio": 0.92,
                        "numComments": 87,
                        "url": "https://example.com",
                        "permalink": "/r/test/comments/abc123/example_post/",
                        "createdUtc": 1718000000,
                        "edited": false
                      },
                      "comments": [
                        {
                          "id": "c1",
                          "author": "user1",
                          "body": "Great post!",
                          "score": 42,
                          "replies": []
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing Bearer token"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/comment-permalink": {
      "post": {
        "operationId": "comment-permalink",
        "tags": [
          "Content"
        ],
        "summary": "Single comment with parent context and replies",
        "description": "Retrieve a specific comment by its ID, including parent post context and nested replies.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "commentId": {
                    "type": "string",
                    "description": "Comment ID (t1_xxxxx) or full permalink URL."
                  },
                  "depth": {
                    "type": "number",
                    "description": "How many levels of replies to include.",
                    "example": "3"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "commentId"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "commentId": "t1_xyz123",
                    "depth": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "comment": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Comment ID."
                        },
                        "author": {
                          "type": "string",
                          "description": "Author username."
                        },
                        "body": {
                          "type": "string",
                          "description": "Comment body."
                        },
                        "score": {
                          "type": "number",
                          "description": "Score."
                        },
                        "createdUtc": {
                          "type": "number",
                          "description": "Unix timestamp."
                        },
                        "replies": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": true
                          },
                          "description": "Nested replies."
                        }
                      },
                      "additionalProperties": false
                    },
                    "post": {
                      "type": "object",
                      "properties": {
                        "title": {
                          "type": "string",
                          "description": "Parent post title."
                        },
                        "permalink": {
                          "type": "string",
                          "description": "Parent post permalink."
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "additionalProperties": false
                },
                "examples": {
                  "default": {
                    "value": {
                      "comment": {
                        "id": "t1_xyz123",
                        "author": "user1",
                        "body": "This is a comment.",
                        "score": 100,
                        "createdUtc": 1718000000,
                        "replies": []
                      },
                      "post": {
                        "title": "Example post",
                        "permalink": "/r/test/comments/abc/example/"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing Bearer token"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    }
  }
}