问题描述
我一直在浏览GitHub API文档,但似乎找不到一种方法来获取为用户个人资料的贡献活动"部分和贡献图表提供支持的数据.有没有办法通过API做到这一点?
I've been poking through the GitHub API documentation and I can't seem to find a way to get the data that powers the "Contribution Activity" section and the contribution chart for a user's profile. Is there a way to get this through the API?
我知道有user/:user/events
和/recieved_events
个端点,但是这些端点主要由用户加注存储库组成.我对哪个存储库/什么commit/etc的实际信息不感兴趣,但是只对获取commit/issue/etc的时间序列(或类似的东西)感兴趣.构成个人资料页面的贡献图和活动部分的活动数据.理想情况下,无论哪个回购/回购隐私/等等,Github上所有活动的数量都是如此.
I know that there are user/:user/events
and /recieved_events
endpoints, but these seem to mostly consist of when the user stars repositories. I'm uninterested in the actual information of which repository/what commit/etc, but only interested in getting a time-series (or something like that) of commit/issue/etc. activity data that forms the contribution chart and activity portions of the profile page. Ideally numbers across all Github activity regardless of which repo/repo privacy/etc.
我要做的就是将其整合到我的Github页面网站中.
All I'm trying to do is incorporate this into my Github pages website.
推荐答案
可以使用Github GraphQL API提取大多数贡献数据- https://developer.github.com/v4/
Most contribution data can be fetched using Github GraphQL API - https://developer.github.com/v4/
我正在使用此方法来制作一个显示最后用户贡献列表的小部件.而且效果很好,并提供了许多过滤/分组的机会
I was using this method for doing a widget that shows the last user contributions list. And it works well and offers many of filtering/grouping opportunities
a.e您可以按天数获取贡献人数:
a.e you can get contribs count by day:
{
user(login: "orn0t") {
contributionsCollection {
contributionCalendar {
totalContributions
weeks {
contributionDays {
contributionCount
weekday
date
}
}
}
}
}
}
如果您正在寻找有效的代码示例:
If you're looking for working code examples:
您可以在Github上查看我的项目- https://github.com/orn0t/gh -contrib-widget .
you can view my project on Github - https://github.com/orn0t/gh-contrib-widget.
这篇关于从GitHub API获取用户活动统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!