Git Product home page Git Product logo

contributions-getter's Introduction

contributions-getter

A JavaScript/TypeScript library that gets all of the GitHub repositories a user has committed in since their account's creation

Example usage

import { getContributions } from "contributions-getter";

const contributions = await getContributions("github_token", "github_username");
console.log(JSON.stringify(contributions, null, 2));

Configuration

A third parameter can be supplied, which is the Config object. It can optionally contain:

  • monthsInterval: the interval of getting the contributions in months (defaults to 12 months).

    Note that the maximum repositories that can be shown in a certain time interval is 100 repositories, so if you have contributed to more than that within a time period you may consider decreasing the time period

    Note that decreasing the time period increases the number of requests that are sent to the GitHub API

  • fetchFn: the function that is used for sending the requests (defaults to fetch). This is mainly used for testing. This function has the same signature as fetch except only json, status and statusText are required in the response.

Example output

[
  {
    "startDate": "2022-07-06T08:34:06.813Z",
    "endDate": "2023-07-06T07:34:06.813Z",
    "repos": [
      {
        "commits": 168,
        "description": "Usage of principles learnt in the Software Design and Architecture course to create an abstract e-payment system",
        "name": "sda-assignment/sda-assignment",
        "primaryLanguage": "Java",
        "stars": 1,
        "url": "https://github.com/sda-assignment/sda-assignment",
        "commitsUrl": "https://github.com/sda-assignment/sda-assignment/commits?author=Brikaa&since=2022-07-06&until=2023-07-07",
        "isPrivate": false
      },
      ...
    ]
  },
  ...
]

Used GraphQL query

query getUser($login: String!, $from: DateTime, $to: DateTime) {
  user(login: $login) {
    contributionsCollection(from: $from, to: $to) {
      commitContributionsByRepository(maxRepositories: 100) {
        url
        contributions {
          totalCount
        }
        repository {
          isPrivate
          nameWithOwner
          url
          description
          stargazerCount
          primaryLanguage {
            name
          }
        }
      }
    }
  }
}

Testing

Create a file called token.txt in the root of the directory containing your GitHub token then run npm test or npm run coverage.

contributions-getter's People

Contributors

brikaa avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.