Logo of ungh

ungh

无限制访问 GitHub API

无限访问 GitHub API

为什么选择 UNGH?

访问开源 GitHub 仓库的元数据应该快速、简便、直接。GitHub API 有速率限制,并且需要认证令牌来提高限制。即使使用 API 令牌,我们也需要在每次部署和应用程序的本地开发中共享或生成它,并且还要处理(增加的)速率限制和部署缓存。GitHub REST API 也因向后兼容性而复杂,其有效负载(不必要地)更大。

UNGH 提供了一个简化、缓存和匿名的层,让 GitHub API 更令人愉悦!

路线图

  • 托管 MVP 服务(由 Cloudflare Workers 和 KV 提供支持)
  • ungh JS 客户端发布到 NPM (#4)
  • 实现令牌池并开放令牌捐赠 (#5)
  • 将 API 标记为稳定

注意:此项目仍在开发中,API 可能会发生变化。

API

/repos/{owner}/{name}

GitHub 仓库信息。

示例: https://ungh.cc/repos/unjs/h3

{
  "repo": {
    "id": 313641207,
    "name": "h3",
    "repo": "unjs/h3",
    "description": "Minimal h(ttp) framework built for high performance and portability ⚡️",
    "createdAt": "2020-11-17T14:15:44Z",
    "updatedAt": "2022-11-05T21:38:43Z",
    "pushedAt": "2022-11-06T06:48:23Z",
    "stars": 1168,
    "watchers": 1168,
    "forks": 59,
    "defaultBranch": "main"
  }
}

/repos/{owner}/{name}/contributors

获取仓库贡献者。

示例: https://ungh.cc/repos/unjs/h3/contributors

{
  "contributors": [
    {
      "id": 5158436,
      "username": "pi0",
      "contributions": 243
    },
    {
      "id": 29139614,
      "username": "renovate[bot]",
      "contributions": 41
    }
  ]
}

/repos/{owner}/{name}/files/{branch}

获取特定分支上的仓库文件树。

示例: https://ungh.cc/repos/unjs/h3/files/main

{
  "meta": {
    "sha": "501f0c6e623ea827d47691046f3c7319f5ac4651"
  },
  "files": [
    {
      "path": "README.md",
      "mode": "100644",
      "sha": "4c2b9ce4bccd6e046cd71be1a8c5e53a62778858",
      "size": 5782
    }
  ]
}

/repos/{owner}/{name}/files/{branch}/{...path}

从仓库中获取文件内容。如果路径以 .md 结尾,将附加一个包含渲染标记的额外 html 字段。

示例: https://ungh.cc/repos/unjs/h3/files/main/README.md

{
  "meta": {
    "url": "https://raw.githubusercontent.com/unjs/h3/main/README.md"
  },
  "file": {
    "contents": "...",
    "html": "..."
  }
}

/repos/{owner}/{name}/readme

获取主分支上的仓库 README 文件(未缓存)

示例: https://ungh.cc/repos/unjs/h3/readme

{
  "html": "<p><a href=\"https://npmjs.net.cn/package/h3\" rel=\"nofollow\"><img...",
  "markdown": "[![npm downloads](https://img.shields.io...."
}

/repos/{owner}/{name}/releases

获取仓库版本发布。

示例: https://ungh.cc/repos/nuxt/framework/releases

{
  "releases": [
    {
      "id": 82066265,
      "tag": "v3.0.0-rc.13",
      "author": "pi0",
      "name": "v3.0.0-rc.13",
      "draft": false,
      "prerelease": false,
      "createdAt": "2022-11-04T11:37:49Z",
      "publishedAt": "2022-11-04T11:41:59Z",
      "markdown": "....",
      "html": "..."
    }
  ]
}

/repos/{owner}/{name}/releases/latest

获取仓库最新版本发布。

示例: https://ungh.cc/repos/nuxt/framework/releases/latest

{
  "release": {
    "id": 82066265,
    "tag": "v3.0.0-rc.13",
    "author": "pi0",
    "name": "v3.0.0-rc.13",
    "draft": false,
    "prerelease": false,
    "createdAt": "2022-11-04T11:37:49Z",
    "publishedAt": "2022-11-04T11:41:59Z",
    "markdown": "....",
    "html": "..."
  }
}

/repos/{owner}/{name}/branches

获取仓库的所有分支

示例: https://ungh.cc/repos/unjs/ungh/branches

{
  "branches": [
    {
      "name": "main",
      "commit": {
        "sha": "2eb6bff64caf0d18f082adde7606c4702513870b",
        "url": "https://api.github.com/repos/unjs/ungh/commits/2eb6bff64caf0d18f082adde7606c4702513870b"
      },
      "protected": true
    },
    {
      "name": "renovate/all-minor-patch",
      "commit": {
        "sha": "61140d05f66cd6b217f2475ad84e2d251ed7de05",
        "url": "https://api.github.com/repos/unjs/ungh/commits/61140d05f66cd6b217f2475ad84e2d251ed7de05"
      },
      "protected": false
    },
    {
      "name": "renovate/typescript-5.x",
      "commit": {
        "sha": "19b23fca2088722bbb41a7238bf8bd5272799718",
        "url": "https://api.github.com/repos/unjs/ungh/commits/19b23fca2088722bbb41a7238bf8bd5272799718"
      },
      "protected": false
    }
  ]
}

/orgs/{owner}

GitHub 组织信息。

示例: https://ungh.cc/orgs/unjs

{
  "org": {
    "id": 80154025,
    "name": "unjs",
    "description": "Unified JavaScript Tools"
  }
}

/orgs/{owner}/repos

GitHub 组织仓库概览。

示例: https://ungh.cc/orgs/unjs/repos

{
  "repos": [
    {
      "id": 97751746,
      "name": "redirect-ssl",
      "repo": "unjs/redirect-ssl",
      "description": "Connect/Express middleware to enforce https using is-https",
      "createdAt": "2017-07-19T19:04:11Z",
      "updatedAt": "2022-09-22T09:47:25Z",
      "pushedAt": "2022-04-08T20:29:48Z",
      "stars": 93,
      "watchers": 93,
      "forks": 14
    }
  ]
}

/stars/{repos}

获取一个或多个仓库或组织的点赞信息。

多个项目可以用 ,+ (空格)分隔。每个项目可以是 {owner}/{org} 来指定一个仓库,也可以是 {owner}/* 来指定所有组织仓库。

示例: https://ungh.cc/stars/nuxt/nuxt.js+nuxt/framework

{
  "totalStars": 51524,
  "stars": {
    "nuxt/nuxt.js": 41560,
    "nuxt/framework": 9964
  }
}

/users/{username}

通过用户名查找 GitHub 用户。

示例: https://ungh.cc/users/pi0

{
  "user": {
    "id": 5158436,
    "name": "Pooya Parsa",
    "twitter": null,
    "username": "pi0"
  }
}

/users/{username}/repos

获取用户仓库。

示例: https://ungh.cc/users/pi0/repos

{
  "repos": [
    {
      "id": 674019467,
      "name": "h3-on-edge",
      "description": "⚡️ Edge workers with straming powered by unjs/h3",
      "repo": "pi0/h3-on-edge",
      "stars": 51,
      "pushedAt": "2024-01-07T16:54:46Z",
      "createdAt": "2023-08-03T00:53:31Z",
      "updatedAt": "2024-01-04T17:20:53Z",
      "watchers": 51,
      "forks": 0,
      "defaultBranch": "main"
    }
  ]
}

/users/find/{query}

通过电子邮件或其他查询查找 GitHub 用户。

示例: https://ungh.cc/users/find/[email protected]

{
  "user": {
    "id": 5158436,
    "name": "Pooya Parsa",
    "twitter": null,
    "username": "pi0"
  }
}

💻 开发

  • 克隆此仓库
  • 使用 corepack enable 启用 Corepack (对于 Node.js < 16.10,请使用 npm i -g corepack
  • 使用 pnpm install 安装依赖项
  • 使用 pnpm dev 运行交互式测试

许可

用心制作 💛

根据 MIT 许可证发布。