• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

grubersjoe/github-contributions-api: A simple API that returns number of Github ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

grubersjoe/github-contributions-api

开源软件地址:

https://github.com/grubersjoe/github-contributions-api

开源编程语言:

TypeScript 98.4%

开源软件介绍:

GitHub Contributions API v4

CI

A simple API that returns number of GitHub contributions based on a users GitHub profile. This API is used by React GitHub Calendar (React component).

⚠️ Results are cached for one hour!

How to run

yarn
yarn start

For development:

yarn dev

Usage

Send a GET request to the API in the following format:

https://github-contributions-api.jogruber.de/v4/GITHUB_USERNAME

And you will receive an object with complete history of that user's contributions (total per year and for each day):

{
  "total": {
    "2020": 492,
    ...
  },
  "contributions": [
    {
      "date": "2020-01-01",
      "count": 0,
      "level": 0
    },
    {
      "date": "2020-01-02",
      "count": 9,
      "level": 4
    },
    {
      "date": "2020-01-03",
      "count": 5,
      "level": 2
    },
    ...
  ]
}

You can return the results as an object keyed by year, month and day by using the format=nested query parameter:

https://github-contributions-api.jogruber.de/v4/GITHUB_USERNAME?format=nested
{
  "2020": {
    "1": {
      "1": {
        "date": "2020-01-01",
        "count": 9,
        "level": 4
      },
      "2": {
        "date": "2020-01-02",
        "count": 5,
        "level": 2
      },
      "3": {
        "date": "2020-01-03",
        "count": 0,
        "level": 0
      },
      ...
    },
   ...
  }
}

The y query parameter

Use the y (year) query parameter to retrieve the data for a specific year, a set of years, the last year (GitHub's default view), or the data for all years (default when y parameter is omitted):

https://github-contributions-api.jogruber.de/v4/GITHUB_USERNAME?y=2020
https://github-contributions-api.jogruber.de/v4/GITHUB_USERNAME?y=2016&y=2017
https://github-contributions-api.jogruber.de/v4/GITHUB_USERNAME?y=last
https://github-contributions-api.jogruber.de/v4/GITHUB_USERNAME?y=all # default
{
  "total": {
    "2016": 249,
    "2017": 785
  },
  "contributions": [
    {
      "date": "2016-01-01",
      "count": 1,
      "level": 1
    },
    {
      "date": "2016-01-02",
      "count": 0,
      "level": 0
    },
    ...
  ]
}

Response interface

The responses are formally structured like this:

type Level = 0 | 1 | 2 | 3 | 4;

interface Contribution {
  date: string;
  count: number;
  level: Level;
}

interface Response {
  total: {
    [year: number]: number;
    [year: string]: number; // 'lastYear'
  };
  contributions: Array<Contribution>;
}

interface NestedResponse {
  total: {
    [year: number]: number;
    [year: string]: number; // 'lastYear;
  };
  contributions: {
    [year: number]: {
      [month: number]: {
        [day: number]: Contribution;
      };
    };
  };
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap