您如何使用 GitHub API 获得用户今天做了多少贡献

How can you get how many contributions a user did today with the GitHub API

我正在制作一个非常简单的 chrome 扩展,它显示您今天在 GitHub 上所做的贡献数量。我怎样才能得到那个号码?

您可以将 Github GraphQL API to request contributionsCollection 与日期范围一起使用:

query { 
  viewer { 
    contributionsCollection(from:"2020-05-05T00:00:00Z", to:"2020-05-05T00:00:00Z") {
      contributionCalendar{
        totalContributions
      }
    }
  }
}

对于特定用户:

query { 
  user(login:"krissemicolon") { 
    contributionsCollection(from:"2020-06-01T00:00:00Z", to:"2020-06-01T00:00:00Z") {
      contributionCalendar{
        totalContributions
      }
    }
  }
}

如果无法使用 graphql API,您还可以解析日历 svg,结帐 this