Last active
August 29, 2015 14:17
-
-
Save makeittotop/f4bb5455fb7ae9df29b5 to your computer and use it in GitHub Desktop.
git api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# user info | |
curl -XGET https://api.github.com/users/makeittotop -vv | |
# note the X-RateLimit-Limit and X-RateLimit-Remaining headers. This indicates how many requests | |
# a client can make in a rolling time period (typically an hour) and how many of those requests | |
# the client has already spent. | |
curl -XGET https://api.github.com/users/makeittotop -vv -i | |
# Unauthenticated clients can make 60 requests per hour. auth'ed users - 5000! | |
curl -u makeittotop -XGET https://api.github.com/users/makeittotop -vv -i | |
# authorizations API | |
# In this case, we’re setting up the token with repo access, which grants access to read and write to public and private repositories # and user scope, which grants read and write access to public and private user profile data. | |
curl -XPOST -i -u makeittotop -d '{"scopes": ["repo", "user"], "note": "getting-started"}' https://api.github.com/authorizations | |
Enter host password for user 'makeittotop': | |
HTTP/1.1 201 Created | |
Server: GitHub.com | |
Date: Thu, 19 Mar 2015 14:32:11 GMT | |
Content-Type: application/json; charset=utf-8 | |
Content-Length: 467 | |
Status: 201 Created | |
X-RateLimit-Limit: 5000 | |
X-RateLimit-Remaining: 4994 | |
X-RateLimit-Reset: 1426776461 | |
Cache-Control: private, max-age=60, s-maxage=60 | |
ETag: "caa1164fa3c82c0acce87d886c303bee" | |
Location: https://api.github.com/authorizations/16263426 | |
Vary: Accept, Authorization, Cookie, X-GitHub-OTP | |
X-GitHub-Media-Type: github.v3 | |
X-XSS-Protection: 1; mode=block | |
X-Frame-Options: deny | |
Content-Security-Policy: default-src 'none' | |
Access-Control-Allow-Credentials: true | |
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval | |
Access-Control-Allow-Origin: * | |
X-GitHub-Request-Id: 5ECE68C2:584C:13B0FCE:550ADDEA | |
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload | |
X-Content-Type-Options: nosniff | |
Vary: Accept-Encoding | |
X-Served-By: b0ef53392caa42315c6206737946d931 | |
{ | |
"id": 16263426, | |
"url": "https://api.github.com/authorizations/16263426", | |
"app": { | |
"name": "getting-started (API)", | |
"url": "https://developer.github.com/v3/oauth_authorizations/", | |
"client_id": "00000000000000000000" | |
}, | |
"token": "##########....#########", | |
"note": "getting-started", | |
"note_url": null, | |
"created_at": "2015-03-19T14:32:11Z", | |
"updated_at": "2015-03-19T14:32:11Z", | |
"scopes": [ | |
"repo", | |
"user" | |
] | |
} | |
curl -XGET -i -vv -H'Authorization: token #####....#####' https://api.github.com/user | |
# user repos | |
curl -XGET -i -H'Authorization: token ****' https://api.github.com/user/repos | |
# organization repos | |
curl -i https://api.github.com/orgs/docker/repos | |
curl -i "https://api.github.com/users/barajoun/repos?type=owner" | |
curl -i -H 'Authorization: token 5199831f4dd3b79e7c5b7e0ebe75d67aa66e79d4' \ | |
-d '{ \ | |
"name": "test_proj", \ | |
"auto_init": true, \ | |
"private": true, \ | |
"gitignore_template": "nanoc" \ | |
}' \ | |
https://api.github.com/user/repos | |
# we created the repository as private, we need to authenticate in order to see it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment