'Get the amount of commits published on a GitHub repository with Discord.js?
I have a simple GitHub command, that only displays some links to some pages on my repository. But I want to upgrade it. Is it possible to get the total amount of commits of a GH repo? And is there other data you can pull (contributors, files changed, latest version etc.)?
Solution 1:[1]
You can make a GET request to the GitHub rest api at the endpoint: api.github.com/repos/{owner}/{repo}/commits
Where the owner is the username of the owner of the repository, and the repo is the name of the repository. Using any library of choice to make HTTP requests will allow you to fetch a list of the repos, which of course you can take the length of to find the number of commits.
See GitHub docs here and,
See guide to using a rest api on discordjs
Edit: To get the rest of the information you listed, I'd recommend consulting the full list of rest api endpoints for GitHub apps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mansehaj Singh |
