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

返回响应

![(https://img-blog.csdnimg.cn/4a8aad1b81db49068620a7f5ef2426ce.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQVVaUQ==,size_20,color_FFFFFF,t_70,g_se,x_16)

获取某个用户信息

请求说明
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

返回响应

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QQWSFV09-1633916354680)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008111711159.png)]

仓库

仓库集合

请求说明

查看所有仓库

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

返回响应[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jlwdv9Km-1633916354682)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008163636812.png)]

列举仓库信息

请求说明

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

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

返回响应

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LPYsDrJN-1633916354684)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008113248445.png)]

仓库贡献人员

请求说明

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

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

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

返回响应

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-hlVoq1Tr-1633916354685)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008154924553.png)]

仓库语言

请求说明

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

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

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

返回响应

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-KPxY8twr-1633916354686)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008155330250.png)]

仓库标签

请求说明

查看仓库中的所有标签

/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

返回响应

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-aA19fNS7-1633916354689)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008162955430.png)]

查看用户仓库

请求说明

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

/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

返回响应

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UQmgYKUU-1633916354690)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008164014330.png)]

分支

请求说明

查看仓库的分支

/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

返回响应
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sYhus1cp-1633916354691)(C:\Users\Dell\AppData\Roaming\Typora\typora-user-images\image-20211008165838831.png)]
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值