-
Notifications
You must be signed in to change notification settings - Fork 5
GitHub REST API Starting Guide
GitHub API allows users to interact with GitHub by creating and managing repositories, branches, issues, pull requests, and etc. And also by using the Authenticating Tokens user can do some more advanced actions.
Before Starting You must have proper authentications. The easiest and basic way is to create a Personal access token. You can do that by following the below steps.
First Navigate to the personal access tokens page and generate a new token (Settings > Developer Settings > Personal access tokens > Generate new Token) Enter the Required Details and You will have a Personal Token as shown in the image below. (Tip - Remember to give Expiration Date)
Now you are Ready to Explore Core REST API concepts.
- Getting Your own GitHub User Profile.
curl -i -u your_username:your_token https://api.github.com/user
Eg:
- View Repositories of an authenticated user
curl -i -H "Authorization: token <your_token>" https://api.github.com/user/repos
Eg:
(All your Repositories will be Displayed)
you can also list Repositories of another user
curl -i https://api.github.com/users/<user_name>/repos
- Get Issues assigned to you
curl -H "Authorization: token <your_token>" https://api.github.com/issues
Eg:
- Create a Repository
curl -H "Authorization: token <your_token>" -d '{"name":"Github API Testing"}' https://api.github.com/user/repos
Eg: