Diff and patch media types
Starting today, you can get .diff
and .patch
content directly from the API for the following resources:
Simply use the same resource URL and send either application/vnd.github.diff
or application/vnd.github.patch
in the Accept
header:
curl -H "Accept: application/vnd.github.diff" $ https://api.github.com/repos/pengwynn/dotfiles/commits/aee60a4cd56fb4c6a50e60f17096fc40c0d4d72c diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink index 1f599cb..abaf625 100755 --- a/tmux/tmux.conf.symlink +++ b/tmux/tmux.conf.symlink @@ -111,6 +111,7 @@ set-option -g base-index 1 ## enable mouse set-option -g mouse-select-pane on set-option -g mouse-select-window on +set-option -g mouse-resize-pane on set-window-option -g mode-keys vi set-window-option -g mode-mouse on # set-window-option -g monitor-activity off
Pagination for Organization Repository lists now paginates properly
Improvements continue to the Organizations Repository listing endpoint.
Today we're improving pagination so that it works as documented. Now
you can expect Link
headers to navigate through the results space,
regardless of what you send in the type
parameter.
The docs for Organization Repositories queries are still here:
EDIT: Link
headers are our preferred navigation technique.
Finding sources and fork repositories for organizations
We've made a couple of changes today to the Organization repositories listing to bring it a bit closer to the functionality of the GitHub.com Organization repositories tab. We now let you retrieve repositories which are forks of another repository, as well as those repositories which are sources (not forks).
# Grab all fork Repositories for an Organization curl "https://api.github.com/orgs/:org/repos?type=forks" # Grab all source Repositories for an Organization curl "https://api.github.com/orgs/:org/repos?type=sources"
Check out the docs for sorting and filtering options:
Create an OAuth authorization for an app
The Authorizations API is an easy way to create an OAuth authorization using Basic Auth. Just POST your desired scopes and optional note and you get a token back:
curl -u pengwynn -d '{"scopes": ["user", "gist"]}' \ https://api.github.com/authorizations
This call creates a token for the authenticated user tied to a special "API" OAuth application.
We now support creating tokens for your own OAuth application by passing your
twenty character client_id
and forty character client_secret
as found in
the settings page for your OAuth application.
curl -u pengwynn -d '{ \ "scopes": ["user", "gist"], \ "client_id": "abcdeabcdeabcdeabcdeabcde" \ "client_secret": "abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde" \ }' \ ' https://api.github.com/authorizations
No more implementing the web flow just to get a token tied to your app's rate limit.
Per-repository Review and Issue Comment listing
You've always been able to grab all the commit comments for an entire repository via the API, but to get Issue comments and Pull Request Review Comments, you could only fetch the comments for a single Issue or Pull Request.
Today, we're introducing two new methods to grab all Issue Comments and Review Comments for a repository.
# Grab all Issue Comments curl https://api.github.com/repos/mathiasbynens/dotfiles/issues/comments # Grab all Review Comments curl https://api.github.com/repos/mathiasbynens/dotfiles/pulls/comments
Check out the docs for sorting and filtering options:
Gitignore Templates API
We recently made it easy to initialize a repository when you create
it via the API. One of the options you can pass when creating a
repository is gitignore_template
. This value is the name of one of the
templates from the public GitHub .gitignore repository.
The Gitignore Templates API makes it easy to list those templates:
curl https://api.github.com/gitignore/templates HTTP/1.1 200 OK [ "Actionscript", "Android", "AppceleratorTitanium", "Autotools", "Bancha", "C", "C++", ...
If you'd like to view the source, you can also fetch a single template.
curl -H 'Accept: application/vnd.github.raw' \ https://api.github.com/gitignore/templates/Objective-C HTTP/1.1 200 OK # Xcode .DS_Store build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 *.xcworkspace !default.xcworkspace xcuserdata profile *.moved-aside DerivedData .idea/
Forking to Organizations
We made a slight change to the way you fork a repository. By default, you can fork my repository through an HTTP POST to the repository's fork resource.
curl -X POST https://api.github.com/repos/technoweenie/faraday/forks
This repository forks to your personal account. However, there are cases when
you want to fork to one of your organizations instead. The previous method
required a ?org
query parameter:
curl -X POST /repos/technoweenie/faraday/forks?org=mycompany
Query parameters on POST requests are unusual in APIs, and definitely
inconsistent with the rest of the GitHub API. You should be able to post a
JSON body like every other POST endpoint. Now, you can! Only, now we're
calling the field organization
.
curl /repos/technoweenie/faraday/forks?org=mycompany \ -d '{"organization": "mycompany"}'
Don't worry, we are committed to maintaining the legacy behavior until the next major change of the GitHub API.
Gist comment URIs
The URIs of all gist comments are changing immediately. The new URI pattern for gist comments is /gists/{gist-id}/comments/{id}
. (See gist comments section of the docs for more details.) This change is necessary because the auto-incremented ids of gist comments are easy to guess. This predictability allows anyone to view comments on private Gists with relative ease. Obviously, comments on private gists should be just as private as the gist itself.
Adding the gist id to the URI of comments makes it impossible, in practical terms, to guess that URI because the id of private gists are very large random numbers. This is, unfortunately, a breaking change but one that cannot be avoided because of the security implications of the current URIs. We apologize for the inconvenience.
We have also added a comments_url
member to the Gist documents. The comments_url
link provides access to the comments of a Gist in a way that will insulate clients from changes in the URI patterns used by the GitHub API. We are increasing our use of links in order to make changes such as this one less damaging to clients. We strongly encourage using url
and *_url
properties, where possible, rather than constructing URIs using the patterns published on this site. Doing so will result in clients that break less often.
Notifications API
Now that the dust has settled around Notifications and Stars, we've unleashed all that in a brand new API. You can now view and mark notifications as read.
Endpoint
The core notifications functionality is under the /notifications
endpoint.
You can look for unread notifications:
curl https://api.github.com/notifications
You can filter these notifications to a single Repository:
curl https://api.github.com/repos/technoweenie/faraday/notifications
You can mark them as read:
# all notifications curl https://api.github.com/notifications \ -X PUT -d '{"read": true}' # notifications for a single repository curl https://api.github.com/repos/technoweenie/faraday/notifications \ -X PUT -d '{"read": true}'
You can also modify subscriptions for a Repository or a single thread.
# subscription details for the thread (either an Issue or Commit) curl https://api.github.com/notifications/threads/1/subscription # subscription details for a whole Repository. curl https://api.github.com/repos/technoweenie/faraday/subscription
Polling
The Notifications API is optimized for polling by the last modified time:
# Add authentication to your requests curl -I https://api.github.com/notifications HTTP/1.1 200 OK Last-Modified: Thu, 25 Oct 2012 15:16:27 GMT X-Poll-Interval: 60 # Pass the Last-Modified header exactly curl -I https://api.github.com/notifications -H "If-Modified-Since: Thu, 25 Oct 2012 15:16:27 GMT" HTTP/1.1 304 Not Modified X-Poll-Interval: 60
You can read about the API details in depth in the Notifications documentation.
Set the default branch for a repository
You can set the default branch for a repository to something other than 'master' from the GitHub repository admin screen:
Now, you can update this setting via the API. We've added a default_branch
parameter to the Edit Repository method:
curl -u pengwynn \ -d '{"name": "octokit", "default_branch":"development"}' \ https://api.github.com/repos/octokit/octokit.rb
If you provide a branch name that hasn't been pushed to GitHub, we'll gracefully fall back to 'master'
or the first branch.