https://github.com/brikaa/contributions-getter
A JavaScript/TypeScript library that gets all of the repositories a user has contributed to since their account's creation
https://github.com/brikaa/contributions-getter
github github-api javascript npm npm-package typescript
Last synced: about 1 month ago
JSON representation
A JavaScript/TypeScript library that gets all of the repositories a user has contributed to since their account's creation
- Host: GitHub
- URL: https://github.com/brikaa/contributions-getter
- Owner: Brikaa
- License: mit
- Created: 2023-07-01T18:13:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-18T15:29:38.000Z (almost 3 years ago)
- Last Synced: 2025-03-26T06:43:23.912Z (about 1 year ago)
- Topics: github, github-api, javascript, npm, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/contributions-getter
- Size: 268 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```typescript
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
```graphql
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`.