-
Notifications
You must be signed in to change notification settings - Fork 0
Github API
Nanthakarn Limkool edited this page Dec 16, 2021
·
3 revisions
% curl https://api.github.com/zen
# output
> Approachable is better than simple.# 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
# output1Any headers beginning with X- are custom headers, and are not included in the HTTP spec.
- to add limit requests per hour
- to get more information of
other user
# use -u flag to set 'your' username (also need -i flag)
% curl -i -u zezay https://api.github.com/users/$usernameoutput not different from output1
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/useroutput different depend on generated $token
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