User Migration API public beta

Starting today, both users and organizations now have the ability to request an archive of their repositories, issues, comments, and other data using the Migrations API.

To access this new API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.wyandotte-preview+json

During the preview period, we may change aspects of these API methods based on your feedback. If we do, we'll announce the changes here on the developer blog, but we won't provide advance notice.

Requesting a user migration archive

Before you can download an archive of your data, you must first export it. To start a migration, make a POST request to the /user/migrations endpoint, listing the repositories you'd like to include in the archive:

curl -X POST -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN --data '{"repositories":["USERNAME/REPO", "USERNAME/ANOTHER_REPO"]}' https://api.github.com/user/migrations

Checking the status of a migration

After you've started a migration, you can check the status of your archive by making a GET request to the /user/migrations/:migration_id endpoint, using the migration ID provided in the response to your initial request (or as retrieved from GET /user/migrations):

curl -X GET -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN https://api.github.com/user/migrations/:migration_id

Retrieving the archive URL

Once your migration is in the exported state, you can request the URL to your migration archive by making a GET request to the /user/migrations/:migration_id/archive endpoint. This endpoint will return an authenticated URL which you can use to retrieve your archive as a tar.gz file:

curl -X GET -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN https://api.github.com/user/migrations/:migration_id/archive

Deleting an archive

Your migration archive will remain available to download for seven days. If you would like to delete your archive sooner, you can do so by making a DELETE request to the /user/migrations/:migration_id/archive endpoint:

curl -X DELETE -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN https://api.github.com/user/migrations/:migration_id/archive

While the migration will continue to exist, the exported archive and its contents will not.

Exporting all user-owned repositories

[Updated 07-05-18] If you'd like to export all your repositories and have Ruby installed, you can use the following code to conveniently generate a list of repository names to supply in the body of the POST /user/migrations request:

gem install octokit
OCTOKIT_ACCESS_TOKEN=TOKEN ruby -e "require 'octokit'; puts Octokit::Client.new(auto_paginate: true).repos(nil, type: :owner).map(&:full_name).to_json"

If you'd prefer to make the necessary API request(s) yourself, you can retrieve a list of your repositories by making a GET request to the List repositories for the authenticated user endpoint:

curl -u USERNAME:TOKEN https://api.github.com/user/repos?type=owner&per_page=100

Please note, however, that if you have more than 100 repositories, you'll need to follow the instructions for paginating requests.

We hope these endpoints can help users to back up or archive their repository data and better understand what information GitHub stores on their behalf.

If you have any questions or feedback, please get in touch with us.