2013-04-12 55 views

回答

37

考慮GitHub API for Users還沒有公開(對捐款電流流天數)的特定信息,您可能需要:

  • 刮它(提取它通過讀取用戶的GitHub的頁面)
    klampinghis answer(upvoted)提到,鏈接到廢料將是:
    https://github.com/users/<username>/contributions_calendar_data
    https://github.com/users/<username>/contributions
    (公共回購而已,雖然)

    SherlockStd有低於updated (May 2017) parsing code

    https://github-stats.com/api/user/streak/current/:username 
    
  • 試項目,其中使用https://github.com/users/<username>/contributions_calendar_data(如Marques Johanssonanswer上市,upvoted)

git-stats

https://github.com/akerl/githubchart

https://raw.github.com/k4rthik/git-cal/master/screenshots/img1.png

git-cal是在命令行上一個簡單的腳本來查看提交日曆(類似於GitHub的貢獻日曆)。
圖形中的每個塊對應一天,並用5種可能顏色中的一種進行着色,每種顏色代表當天提交的相對數量。

  • 或建立一個服務,它會報告,每一天,因爲這一天的任何新承諾,谷歌日曆(使用谷歌日曆API通過一個項目像nf/streak)。
    然後,您可以閱讀該信息並在您的博客中報告。

Google Calendar streak


您可以找到刮信息的各種例子:

如:

$.getJSON('https://github.com/users/' + location.pathname.replace(/\//g, '') + '/contributions_calendar_data', weekendWork); 

像:

leaderboard = members.map do |u| 
    user_stats = get("https://github.com/users/#{u}/contributions_calendar_data") 
    total = user_stats.map { |s| s[1] }.reduce(&:+) 
    [u, total] 
end 
  • ...(你的想法)
+0

過時,看看[我的評論](http://stackoverflow.com/questions/15978845/how-can-i-add-current-streak-of-contributions-from-github-to-my-blog/ 44007340#44007340) – SherlockStd

17

對於平的JSON數據的URL https://github.com/users/[username]/contributions_calendar_data [編輯:貌似這個URL不再工作)

有其產生的SVG,這是其他答案已經指出的URL。這就是: https://github.com/users/[username]/contributions

只需將URL替換爲您的github用戶名,並且您應該能夠看到圖表。請參閱其他答案以獲得更深入的解釋

+4

+1。接得好!我在我的回答中引用了它。 – VonC

+0

來的數據僅供公衆回購。 – AnkitG

+1

現在已經過時了嗎? –

2

如果您需要與GitHub圖表的外觀相匹配的內容,請查看這些使用https://github.com/users/<username>/contributions_calendar_data的項目,同時也應用基於Github邏輯的其他因素。

+0

+1。很好的發現。我在上面的答案中包含了這些項目以提高可見性。 – VonC

2

由於URL https://github.com/users/<username>/contributions_calendar_data不工作了,你必須從https://github.com/users/<username>/contributions解析SVG。

不幸的是,Github喜歡安全性,CORS在其服務器上被禁用。

爲了解決這個問題,我設置爲我的API,大家誰需要它,只是GET https://github-stats.com/api/user/streak/current/{username}(允許CORS),你會得到和回答諸如:

{ 
    "success":true, 
    "currentStreak": 3 
} 

https://github-stats.com將很快實現更多的統計數據端點:)

https://github.com/SherlockStd/github-stats.com/issues索要新的終結點,這將是一種樂趣,找到一個方法來實現它們!

+0

很好地完成。 +1。我在回答中包含了一條鏈接,提供更多的知名度。 – VonC

+0

@VonC謝謝! – SherlockStd

+0

但它實際上沒有工作,因爲CORS的,所以我部署一個服務器,這個我會發布的URL今晚 – SherlockStd