Github API - KU-SKE17/Software-Process GitHub Wiki
Testing setup
% curl https://api.github.com/zen
# output
> Approachable is better than simple.
Get a profile
# GET /users/$username -> JSON
% curl https://api.github.com/users/$username
# or (add -i flag to include headers)
% curl -i https://api.github.com/users/$username
# output1
Any headers beginning with X- are custom headers, and are not included in the HTTP spec.
Authentication
- to add limit requests per hour
- to get more information of
other user
Using password
# use -u flag to set 'your' username (also need -i flag)
% curl -i -u zezay https://api.github.com/users/$username
output not different from output1
Using access tokens
generate $token
from https://github.com/settings/tokens ($username
account)
# get other profile
curl -i -u zezay:$token https://api.github.com/users/$username
# get your own profile
curl -i -u zezay:$token https://api.github.com/user
output different depend on generated $token
Repositories
Get /repos
-> all repositories
Get /repos/$repo_name
-> only that repository
note. following command no need -i flag
# get from username
% curl -i https://api.github.com/users/$username/repos
# (there is a 'type' parameter that can filter the repositories)
$ curl -i "https://api.github.com/users/$username/repos?type=owner"
# or
% curl -i -H "Accept: application/vnd.github.v3+json" https://api.github.com/users/$username/repos
# get from token
% curl -i -H "Authorization: token $token" https://api.github.com/user/repos