栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

GitHub Api用户和仓库常用接口

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

GitHub Api用户和仓库常用接口

准备工作

官方文档:https://docs.github.com/en/rest/reference

1、申请github api token

2、在请求header中添加Authorization和Accept,例如:

用户 用户集合 请求说明

显示所有github用户信息,默认按id递增。

NameTypeInDescription
acceptstringheaderSetting to application/vnd.github.v3+json is recommended.
sinceintegerqueryA user ID. only return users with an ID greater than this ID.
per_pageintegerqueryResults per page (max 100)Default: 30

请求url:https://api.github.com/users?since=100

返回响应

获取某个用户信息 请求说明
NameTypeInDescription
acceptstringheaderSetting to application/vnd.github.v3+json is recommended.
usernamestringpath

请求url:https://api.github.com/users/mojombo

返回响应

查看用户的关注/被关注 请求说明
https://api.github.com/users/USERNAME/following

请求url:https://api.github.com/users/mojombo/following

返回响应

仓库 仓库集合 请求说明

查看所有仓库

NameTypeInDescription
acceptstringheaderSetting to application/vnd.github.v3+json is recommended.
sinceintegerqueryA repository ID. only return repositories with an ID greater than this ID.

请求url:https://api.github.com/repositories?since=824

返回响应 列举仓库信息 请求说明

显示某组织所有的仓库信息

https://api.github.com/orgs/ORG/repos
NameTypeInDescription
acceptstringheaderSetting to application/vnd.github.v3+json is recommended.
orgstringpath
typestringquerySpecifies the types of repositories you want returned. Can be one of all, public, private, forks, sources, member, internal. Note: For GitHub AE, can be one of all, private, forks, sources, member, internal. Default: all. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, type can also be internal. However, the internal value is not yet supported when a GitHub App calls this API with an installation access token.
sortstringqueryCan be one of created, updated, pushed, full_name.Default: created
directionstringqueryCan be one of asc or desc. Default: when using full_name: asc, otherwise desc
per_pageintegerqueryResults per page (max 100)Default: 30
pageintegerqueryPage number of the results to fetch.Default: 1

请求url:https://api.github.com/orgs/nasa/repos?per_page=10

返回响应

仓库贡献人员 请求说明

查看某个仓库的贡献者名单

/repos/{owner}/{repo}/contributors

请求url:https://api.github.com/repos/nasa/osal/contributors

返回响应

仓库语言 请求说明

查看仓库中不同编程语言的使用量,单位为字节。

/repos/{owner}/{repo}/languages

请求url:https://api.github.com/repos/nasa/osal/languages

返回响应

仓库标签 请求说明

查看仓库中的所有标签

/repos/{owner}/{repo}/tags
NameTypeInDescription
acceptstringheaderSetting to application/vnd.github.v3+json is recommended.
ownerstringpath
repostringpath
per_pageintegerqueryResults per page (max 100)Default: 30
pageintegerqueryPage number of the results to fetch.Default: 1

请求url:https://api.github.com/repos/nasa/osal/tags

返回响应

仓库话题 请求说明

查看仓库中的所有话题

/repos/{owner}/{repo}/topics

请求url:https://api.github.com/repos/nasa/scrub/topics

返回响应

查看用户仓库 请求说明

查看某用户的所有仓库信息

/users/{username}/repos
NameTypeInDescription
acceptstringheaderSetting to application/vnd.github.v3+json is recommended.
usernamestringpath
typestringqueryCan be one of all, owner, member.Default: owner
sortstringqueryCan be one of created, updated, pushed, full_name.Default: full_name
directionstringqueryCan be one of asc or desc. Default: asc when using full_name, otherwise desc
per_pageintegerqueryResults per page (max 100)Default: 30
pageintegerqueryPage number of the results to fetch.Default: 1

请求url:https://api.github.com/users/JustinGOSSES/repos

返回响应

分支 请求说明

查看仓库的分支

/repos/{owner}/{repo}/branches
NameTypeInDescription
acceptstringheaderSetting to application/vnd.github.v3+json is recommended.
ownerstringpath
repostringpath
protectedbooleanquerySetting to true returns only protected branches. When set to false, only unprotected branches are returned. Omitting this parameter returns all branches.
per_pageintegerqueryResults per page (max 100)Default: 30
pageintegerqueryPage number of the results to fetch.Default: 1

请求url:https://api.github.com/repos/nasa/osal/branches

返回响应
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/314233.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号