New Github v2 API Summary
Github has a new API! The documentation is (of course) a project on github.
It looks like the Api/docs are still in progress. While I was happy to get all the new stuff, I’m still really hoping that github will let me get a user’s watched repos, as there is huge potential there.
So, a quick look at the new stuff.
What’s new?
There’s a ton of new calls you can make, especially w/ working with repos. You can now do things like create a new repo or add collaborators. This stuff will, I suspect, pave the way for some desktop interfaces to github in the next few months.
For example, you can now fork a repo using the api
1 2 3 |
curl -F 'login=schacon' -F 'token=XXX' http://github.com/api/v2/yaml/repos/fork/dim/retrospectiva |
Brief tutorial
So, here are some of the basic calls. They are mostly straight out of the docs, just put together here to make it easier for me to reference.
Getting user data
1 2 3 4 5 6 |
## Old way curl -i http://github.com/api/v1/json/defunkt ## New way curl http://github.com/api/v2/yaml/user/show/defunkt |
Getting info about a user and about repos
1 2 3 4 5 6 7 |
## Get user repos curl http://github.com/api/v2/yaml/repos/show/schacon ## Get repo info curl http://github.com/api/v2/yaml/repos/show/schacon/grit |
A list of followers and followings
1 2 3 4 5 6 7 8 |
## Get a user's followers (note that these are wrong in the doc til my fork is applied) curl http://github.com/api/v2/yaml/user/show/defunkt/followers ## Get people the user is following curl http://github.com/api/v2/yaml/user/show/defunkt/following |
Showing commits
1 2 3 4 5 6 |
## Old way curl -i http://github.com/api/v1/xml/caged/gitnub/commits/master ## New way curl http://github.com/api/v2/yaml/commits/list/mojombo/grit/master |
Searching for users and repos
1 2 3 4 5 6 |
## Search for users curl http://github.com/api/v2/xml/user/search/chacon ## Search for repos curl http://github.com/api/v2/yaml/repos/search/ruby+testing |
Enjoy.
April 15, 2009

