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

# Reddit

> Fetch public Reddit profiles and recent post history.

# Reddit

**Base URL:** `https://drain.lat/api/v1/reddit`

<AccordionGroup>
  <Accordion title="GET /profile/:username" icon="user">
    Fetch a public Reddit user profile.

    ```
    GET /api/v1/reddit/profile/:username
    ```

    <ParamField path="username" type="string" required>
      The Reddit username to look up.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/reddit/profile/spez" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/reddit/profile/spez", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/reddit/profile/spez",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="username" type="string">Reddit username.</ResponseField>
    <ResponseField name="bio" type="string">Profile bio.</ResponseField>
    <ResponseField name="avatarUrl" type="string">Avatar image URL.</ResponseField>

    <ResponseField name="karma" type="object">
      <Expandable title="karma object">
        <ResponseField name="post" type="number">Post karma.</ResponseField>
        <ResponseField name="comment" type="number">Comment karma.</ResponseField>
        <ResponseField name="total" type="number">Total karma.</ResponseField>
        <ResponseField name="awardee" type="number">Awardee karma.</ResponseField>
        <ResponseField name="awarder" type="number">Awarder karma.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="isPremium" type="boolean">Whether the account has Reddit Premium.</ResponseField>
    <ResponseField name="isMod" type="boolean">Whether the account is a moderator.</ResponseField>
    <ResponseField name="isEmployee" type="boolean">Whether the account is a Reddit employee.</ResponseField>
    <ResponseField name="created" type="string">Account creation date (ISO 8601).</ResponseField>
    <ResponseField name="profileUrl" type="string">Link to the Reddit profile.</ResponseField>

    ```json Response theme={null}
    {
      "username": "spez",
      "bio": "CEO of Reddit.",
      "avatarUrl": "https://styles.redditmedia.com/t5_...",
      "karma": {
        "post": 142300,
        "comment": 98400,
        "total": 240700,
        "awardee": 12400,
        "awarder": 3200
      },
      "isPremium": true,
      "isMod": true,
      "isEmployee": true,
      "created": "2005-06-06T04:00:00.000Z",
      "profileUrl": "https://www.reddit.com/user/spez",
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /profile/:username/posts" icon="newspaper">
    Get the last 10 posts from a Reddit user.

    ```
    GET /api/v1/reddit/profile/:username/posts
    ```

    <ParamField path="username" type="string" required>
      The Reddit username.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/reddit/profile/spez/posts" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/reddit/profile/spez/posts", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/reddit/profile/spez/posts",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="username" type="string">Reddit username.</ResponseField>

    <ResponseField name="posts" type="array">
      <Expandable title="post object">
        <ResponseField name="id" type="string">Post ID.</ResponseField>
        <ResponseField name="title" type="string">Post title.</ResponseField>
        <ResponseField name="subreddit" type="string">Subreddit name.</ResponseField>
        <ResponseField name="score" type="number">Post score (upvotes minus downvotes).</ResponseField>
        <ResponseField name="upvoteRatio" type="number">Upvote ratio (0-1).</ResponseField>
        <ResponseField name="comments" type="number">Comment count.</ResponseField>
        <ResponseField name="thumbnailUrl" type="string">Thumbnail URL. `null` if no thumbnail.</ResponseField>
        <ResponseField name="url" type="string">Link to the post.</ResponseField>
        <ResponseField name="createdAt" type="string">Post date (ISO 8601).</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">Number of posts returned.</ResponseField>

    ```json Response theme={null}
    {
      "username": "spez",
      "posts": [
        {
          "id": "t3_abc123",
          "title": "Addressing your questions about the API changes",
          "subreddit": "reddit",
          "score": 48200,
          "upvoteRatio": 0.81,
          "comments": 14300,
          "thumbnailUrl": "https://b.thumbs.redditmedia.com/...",
          "url": "https://www.reddit.com/r/reddit/comments/abc123/",
          "createdAt": "2026-04-20T18:00:00.000Z"
        }
      ],
      "total": 10,
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /profile/:username/comments" icon="comment">
    Get a user's recent comments.

    ```
    GET /api/v1/reddit/profile/:username/comments
    ```

    <ParamField path="username" type="string" required>
      The Reddit username.
    </ParamField>

    <ParamField query="limit" type="number">
      Number of comments to return. Max `25`. Default `10`.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/reddit/profile/spez/comments?limit=10" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/reddit/profile/spez/comments?limit=10", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/reddit/profile/spez/comments",
          params={"limit": 10},
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="username" type="string">Reddit username.</ResponseField>

    <ResponseField name="comments" type="array">
      <Expandable title="comment object">
        <ResponseField name="id" type="string">Comment ID.</ResponseField>
        <ResponseField name="body" type="string">Comment text.</ResponseField>
        <ResponseField name="subreddit" type="string">Subreddit name.</ResponseField>
        <ResponseField name="postTitle" type="string">Title of the parent post.</ResponseField>
        <ResponseField name="permalink" type="string">Link to the comment.</ResponseField>
        <ResponseField name="score" type="number">Comment score.</ResponseField>
        <ResponseField name="created" type="string">Comment date (ISO 8601).</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">Number of comments returned.</ResponseField>

    ```json Response theme={null}
    {
      "username": "spez",
      "comments": [
        {
          "id": "abc123",
          "body": "Thanks for the feedback.",
          "subreddit": "announcements",
          "postTitle": "Reddit update",
          "permalink": "https://www.reddit.com/r/announcements/comments/abc/reddit_update/xyz",
          "score": 4200,
          "created": "2026-05-01T12:00:00.000Z"
        }
      ],
      "total": 10,
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /r/:subreddit" icon="circle-nodes">
    Get info about a subreddit.

    ```
    GET /api/v1/reddit/r/:subreddit
    ```

    <ParamField path="subreddit" type="string" required>
      The subreddit name (without `r/`).
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/reddit/r/funny" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/reddit/r/funny", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/reddit/r/funny",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="id" type="string">Subreddit ID.</ResponseField>
    <ResponseField name="name" type="string">Subreddit name.</ResponseField>
    <ResponseField name="title" type="string">Subreddit title.</ResponseField>
    <ResponseField name="description" type="string">Subreddit description.</ResponseField>
    <ResponseField name="subscribers" type="number">Subscriber count.</ResponseField>
    <ResponseField name="activeUsers" type="number">Currently active users.</ResponseField>
    <ResponseField name="isNsfw" type="boolean">Whether the subreddit is NSFW.</ResponseField>
    <ResponseField name="created" type="string">Creation date (ISO 8601).</ResponseField>
    <ResponseField name="iconUrl" type="string">Subreddit icon URL.</ResponseField>
    <ResponseField name="bannerUrl" type="string">Subreddit banner URL.</ResponseField>
    <ResponseField name="url" type="string">Link to the subreddit.</ResponseField>

    ```json Response theme={null}
    {
      "id": "2qh33",
      "name": "funny",
      "title": "funny",
      "description": "Welcome to r/funny",
      "subscribers": 58000000,
      "activeUsers": 12000,
      "isNsfw": false,
      "created": "2008-01-25T05:11:28.000Z",
      "iconUrl": "https://...",
      "bannerUrl": "https://...",
      "url": "https://www.reddit.com/r/funny",
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /r/:subreddit/posts" icon="newspaper">
    Get posts from a subreddit.

    ```
    GET /api/v1/reddit/r/:subreddit/posts
    ```

    <ParamField path="subreddit" type="string" required>
      The subreddit name (without `r/`).
    </ParamField>

    <ParamField query="sort" type="string">
      Sort order. Options: `hot`, `new`, `top`, `rising`. Default `hot`.
    </ParamField>

    <ParamField query="limit" type="number">
      Number of posts to return. Max `25`. Default `10`.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/reddit/r/funny/posts?sort=hot&limit=10" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/reddit/r/funny/posts?sort=hot&limit=10", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/reddit/r/funny/posts",
          params={"sort": "hot", "limit": 10},
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="subreddit" type="string">Subreddit name.</ResponseField>
    <ResponseField name="sort" type="string">Sort order used.</ResponseField>

    <ResponseField name="posts" type="array">
      <Expandable title="post object">
        <ResponseField name="id" type="string">Post ID.</ResponseField>
        <ResponseField name="title" type="string">Post title.</ResponseField>
        <ResponseField name="author" type="string">Post author username.</ResponseField>
        <ResponseField name="url" type="string">Post content URL.</ResponseField>
        <ResponseField name="permalink" type="string">Link to the Reddit post.</ResponseField>
        <ResponseField name="score" type="number">Post score.</ResponseField>
        <ResponseField name="upvoteRatio" type="number">Upvote ratio (0-1).</ResponseField>
        <ResponseField name="numComments" type="number">Comment count.</ResponseField>
        <ResponseField name="isVideo" type="boolean">Whether the post is a video.</ResponseField>
        <ResponseField name="thumbnail" type="string">Thumbnail URL.</ResponseField>
        <ResponseField name="created" type="string">Post date (ISO 8601).</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">Number of posts returned.</ResponseField>

    ```json Response theme={null}
    {
      "subreddit": "funny",
      "sort": "hot",
      "posts": [
        {
          "id": "abc123",
          "title": "My cat figured out how to open doors",
          "author": "user123",
          "url": "https://i.redd.it/abc.jpg",
          "permalink": "https://www.reddit.com/r/funny/comments/abc123/",
          "score": 98000,
          "upvoteRatio": 0.97,
          "numComments": 1200,
          "isVideo": false,
          "thumbnail": "https://...",
          "created": "2026-05-08T08:00:00.000Z"
        }
      ],
      "total": 10,
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>
</AccordionGroup>
