> ## 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.

# GitHub

> Fetch public GitHub profiles, repositories, followers, following, and organizations.

# GitHub

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

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

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

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

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

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/profile/torvalds", {
        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/github/profile/torvalds",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="id" type="number">GitHub user ID.</ResponseField>
    <ResponseField name="username" type="string">GitHub username.</ResponseField>
    <ResponseField name="displayName" type="string">Display name.</ResponseField>
    <ResponseField name="bio" type="string">Profile bio.</ResponseField>
    <ResponseField name="company" type="string">Company listed on profile.</ResponseField>
    <ResponseField name="location" type="string">Location listed on profile.</ResponseField>
    <ResponseField name="email" type="string">Public email address.</ResponseField>
    <ResponseField name="website" type="string">Personal website URL.</ResponseField>
    <ResponseField name="avatarUrl" type="string">Avatar image URL.</ResponseField>
    <ResponseField name="profileUrl" type="string">Link to GitHub profile.</ResponseField>
    <ResponseField name="followers" type="number">Number of followers.</ResponseField>
    <ResponseField name="following" type="number">Number of accounts followed.</ResponseField>
    <ResponseField name="publicRepos" type="number">Number of public repositories.</ResponseField>
    <ResponseField name="publicGists" type="number">Number of public gists.</ResponseField>
    <ResponseField name="created" type="string">Account creation date.</ResponseField>
    <ResponseField name="updated" type="string">Last profile update date.</ResponseField>

    ```json Response theme={null}
    {
      "id": 1024025,
      "username": "torvalds",
      "displayName": "Linus Torvalds",
      "bio": "Just for fun",
      "company": "Linux Foundation",
      "location": "Portland, OR",
      "email": "",
      "website": "",
      "avatarUrl": "https://avatars.githubusercontent.com/u/1024025",
      "profileUrl": "https://github.com/torvalds",
      "followers": 234000,
      "following": 0,
      "publicRepos": 8,
      "publicGists": 0,
      "created": "2011-09-03T15:26:22Z",
      "updated": "2024-01-01T00:00:00Z",
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /profile/:username/repos" icon="code">
    Get a user's public repositories sorted by last updated.

    ```
    GET /api/v1/github/profile/:username/repos
    ```

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

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

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/profile/torvalds/repos", {
        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/github/profile/torvalds/repos",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

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

    <ResponseField name="repos" type="array">
      <Expandable title="repo object">
        <ResponseField name="id" type="number">Repository ID.</ResponseField>
        <ResponseField name="name" type="string">Repository name.</ResponseField>
        <ResponseField name="fullName" type="string">Full name including owner (e.g. `torvalds/linux`).</ResponseField>
        <ResponseField name="description" type="string">Repository description.</ResponseField>
        <ResponseField name="language" type="string">Primary programming language.</ResponseField>
        <ResponseField name="stars" type="number">Star count.</ResponseField>
        <ResponseField name="forks" type="number">Fork count.</ResponseField>
        <ResponseField name="watchers" type="number">Watcher count.</ResponseField>
        <ResponseField name="isPrivate" type="boolean">Whether the repo is private.</ResponseField>
        <ResponseField name="isFork" type="boolean">Whether the repo is a fork.</ResponseField>
        <ResponseField name="topics" type="array">List of topic tags.</ResponseField>
        <ResponseField name="url" type="string">Link to the repository.</ResponseField>
        <ResponseField name="created" type="string">Creation date.</ResponseField>
        <ResponseField name="updated" type="string">Last updated date.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">Total repos returned.</ResponseField>

    ```json Response theme={null}
    {
      "username": "torvalds",
      "repos": [
        {
          "id": 2325298,
          "name": "linux",
          "fullName": "torvalds/linux",
          "description": "Linux kernel source tree",
          "language": "C",
          "stars": 180000,
          "forks": 54000,
          "watchers": 180000,
          "isPrivate": false,
          "isFork": false,
          "topics": ["kernel", "linux"],
          "url": "https://github.com/torvalds/linux",
          "created": "2011-09-04T22:48:12Z",
          "updated": "2026-05-05T00:00:00Z"
        }
      ],
      "total": 8,
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```

    <Note>Returns up to 30 repositories per request.</Note>
  </Accordion>

  <Accordion title="GET /profile/:username/followers" icon="users">
    Get a user's GitHub followers.

    ```
    GET /api/v1/github/profile/:username/followers
    ```

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

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

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/profile/torvalds/followers", {
        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/github/profile/torvalds/followers",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    ```json Response theme={null}
    {
      "username": "torvalds",
      "followers": [
        {
          "id": 583231,
          "username": "octocat",
          "avatarUrl": "https://avatars.githubusercontent.com/u/583231",
          "profileUrl": "https://github.com/octocat"
        }
      ],
      "total": 30,
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```

    <Note>Returns up to 30 followers.</Note>
  </Accordion>

  <Accordion title="GET /profile/:username/following" icon="user-plus">
    Get the list of users a GitHub user follows.

    ```
    GET /api/v1/github/profile/:username/following
    ```

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

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

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/profile/torvalds/following", {
        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/github/profile/torvalds/following",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    ```json Response theme={null}
    {
      "username": "torvalds",
      "following": [
        {
          "id": 583231,
          "username": "octocat",
          "avatarUrl": "https://avatars.githubusercontent.com/u/583231",
          "profileUrl": "https://github.com/octocat"
        }
      ],
      "total": 0,
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```

    <Note>Returns up to 30 results.</Note>
  </Accordion>

  <Accordion title="GET /profile/:username/orgs" icon="building">
    Get the public organizations a GitHub user belongs to.

    ```
    GET /api/v1/github/profile/:username/orgs
    ```

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

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

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/profile/torvalds/orgs", {
        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/github/profile/torvalds/orgs",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    ```json Response theme={null}
    {
      "username": "torvalds",
      "orgs": [
        {
          "id": 1915493,
          "name": "torvalds",
          "description": "",
          "avatarUrl": "https://avatars.githubusercontent.com/u/1915493",
          "url": "https://github.com/torvalds"
        }
      ],
      "total": 1,
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /repo/:owner/:repo" icon="code-branch">
    Get info for a single GitHub repository.

    ```
    GET /api/v1/github/repo/:owner/:repo
    ```

    <ParamField path="owner" type="string" required>
      Repository owner (user or org).
    </ParamField>

    <ParamField path="repo" type="string" required>
      Repository name.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/github/repo/torvalds/linux" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/repo/torvalds/linux", {
        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/github/repo/torvalds/linux",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="id" type="number">Repository ID.</ResponseField>
    <ResponseField name="name" type="string">Repository name.</ResponseField>
    <ResponseField name="fullName" type="string">Full name including owner.</ResponseField>
    <ResponseField name="description" type="string">Repository description.</ResponseField>
    <ResponseField name="language" type="string">Primary language.</ResponseField>
    <ResponseField name="stars" type="number">Star count.</ResponseField>
    <ResponseField name="forks" type="number">Fork count.</ResponseField>
    <ResponseField name="openIssues" type="number">Open issue count.</ResponseField>
    <ResponseField name="isPrivate" type="boolean">Whether the repo is private.</ResponseField>
    <ResponseField name="isFork" type="boolean">Whether the repo is a fork.</ResponseField>
    <ResponseField name="isArchived" type="boolean">Whether the repo is archived.</ResponseField>
    <ResponseField name="topics" type="string[]">Topic tags.</ResponseField>
    <ResponseField name="license" type="string">License identifier.</ResponseField>
    <ResponseField name="defaultBranch" type="string">Default branch name.</ResponseField>

    <ResponseField name="owner" type="object">
      <Expandable title="owner object">
        <ResponseField name="id" type="number">Owner user ID.</ResponseField>
        <ResponseField name="username" type="string">Owner username.</ResponseField>
        <ResponseField name="avatarUrl" type="string">Owner avatar URL.</ResponseField>
      </Expandable>
    </ResponseField>

    ```json Response theme={null}
    {
      "id": 2325298,
      "name": "linux",
      "fullName": "torvalds/linux",
      "description": "Linux kernel source tree",
      "language": "C",
      "stars": 180000,
      "forks": 55000,
      "watchers": 180000,
      "openIssues": 0,
      "isPrivate": false,
      "isFork": false,
      "isArchived": false,
      "topics": ["kernel", "linux"],
      "license": "GPL-2.0",
      "defaultBranch": "master",
      "url": "https://github.com/torvalds/linux",
      "owner": {
        "id": 1024025,
        "username": "torvalds",
        "avatarUrl": "https://..."
      },
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /repo/:owner/:repo/commits" icon="clock-rotate-left">
    Get the last 20 commits for a repository.

    ```
    GET /api/v1/github/repo/:owner/:repo/commits
    ```

    <ParamField path="owner" type="string" required>
      Repository owner.
    </ParamField>

    <ParamField path="repo" type="string" required>
      Repository name.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/github/repo/torvalds/linux/commits" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/repo/torvalds/linux/commits", {
        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/github/repo/torvalds/linux/commits",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="owner" type="string">Repository owner.</ResponseField>
    <ResponseField name="repo" type="string">Repository name.</ResponseField>

    <ResponseField name="commits" type="array">
      <Expandable title="commit object">
        <ResponseField name="sha" type="string">Commit SHA (short).</ResponseField>
        <ResponseField name="message" type="string">Commit message.</ResponseField>
        <ResponseField name="author" type="string">Author name.</ResponseField>
        <ResponseField name="date" type="string">Commit date (ISO 8601).</ResponseField>
        <ResponseField name="url" type="string">Link to the commit.</ResponseField>
      </Expandable>
    </ResponseField>

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

    ```json Response theme={null}
    {
      "owner": "torvalds",
      "repo": "linux",
      "commits": [
        {
          "sha": "a1b2c3d",
          "message": "kernel: fix memory leak in net subsystem",
          "author": "Linus Torvalds",
          "date": "2026-05-07T18:00:00Z",
          "url": "https://github.com/torvalds/linux/commit/a1b2c3d"
        }
      ],
      "total": 20,
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /search" icon="magnifying-glass">
    Search GitHub repositories.

    ```
    GET /api/v1/github/search
    ```

    <ParamField query="q" type="string" required>
      Search query.
    </ParamField>

    <ParamField query="sort" type="string">
      Sort by `stars`, `forks`, or `updated`. Default `stars`.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/github/search?q=react&sort=stars" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/github/search?q=react&sort=stars", {
        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/github/search",
          params={"q": "react", "sort": "stars"},
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="query" type="string">The search query used.</ResponseField>

    <ResponseField name="repos" type="array">
      <Expandable title="repo object">
        <ResponseField name="id" type="number">Repository ID.</ResponseField>
        <ResponseField name="name" type="string">Repository name.</ResponseField>
        <ResponseField name="fullName" type="string">Full name including owner.</ResponseField>
        <ResponseField name="description" type="string">Repository description.</ResponseField>
        <ResponseField name="language" type="string">Primary language.</ResponseField>
        <ResponseField name="stars" type="number">Star count.</ResponseField>
        <ResponseField name="forks" type="number">Fork count.</ResponseField>
        <ResponseField name="url" type="string">Link to the repository.</ResponseField>
        <ResponseField name="owner" type="object">Owner username and avatar.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">Total matching results on GitHub.</ResponseField>

    ```json Response theme={null}
    {
      "query": "react",
      "repos": [
        {
          "id": 10270250,
          "name": "react",
          "fullName": "facebook/react",
          "description": "The library for web and native user interfaces.",
          "language": "JavaScript",
          "stars": 225000,
          "forks": 46000,
          "url": "https://github.com/facebook/react",
          "owner": {
            "username": "facebook",
            "avatarUrl": "https://..."
          }
        }
      ],
      "total": 125000,
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>
</AccordionGroup>
