octokit/rest.js

Introduction

Usage

Node

Install with npm install @octokit/rest.

const octokit = require('@octokit/rest')()

// Compare: https://developer.github.com/v3/repos/#list-organization-repositories
octokit.repos.getForOrg({
  org: 'octokit',
  type: 'public'
}).then(({ data, headers, status }) => {
  // handle data
})

Browser

  1. Download octokit-rest.min.js from the latest release: https://github.com/octokit/rest.js/releases

  2. Load it as script into your web application:

    <script src="octokit-rest.min.js"></script>
  3. Initialize octokit

    const octokit = new Octokit()
    
    // Compare: https://developer.github.com/v3/repos/#list-organization-repositories
    octokit.repos.getForOrg({
     org: 'octokit',
     type: 'public'
    }).then(({data, headers, status}) => {
     // handle data
    })

Client options

All available client options with default values

const octokit = require('@octokit/rest')({
  timeout: 0, // 0 means no request timeout
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'octokit/rest.js v1.2.3' // v1.2.3 will be current version
  },

  // custom GitHub Enterprise URL
  baseUrl: 'https://api.github.com',

  // Node only: advanced request options can be passed as http(s) agent
  agent: undefined
})

@octokit/rest API docs: https://octokit.github.io/rest.js/
GitHub v3 REST API docs: https://developer.github.com/v3/

API Previews

To take advantage of GitHub’s API Previews, pass a custom accept header, which you can do with any endpoint method documented in the API docs, e.g.

const { data: { topics } } = octokit.repos.get({
  owner: 'octokit',
  repo: 'rest.js',
  headers: {
    accept: 'application/vnd.github.mercy-preview+json'
  }
})

Multiple preview headers can be combined by separating them with commas

const { data: { topics, codeOfConduct } } = octokit.repos.get({
  owner: 'octokit',
  repo: 'rest.js',
  headers: {
    accept: 'application/vnd.github.mercy-preview+json,application/vnd.github.scarlet-witch-preview+json'
  }
})

Authentication

Most GitHub API calls don't require authentication. Rules of thumb:

  1. If you can see the information by visiting the site without being logged in, you don't have to be authenticated to retrieve the same information through the API.
  2. If you want to change data, you have to be authenticated.

To enable authenticated requests, pass an auth option to the Octokit constructor:

const clientWithAuth = new Octokit({
  auth: 'token secret123'
})

The auth option can be

  1. A string

    The value will be passed as value for the Authorization header, see authentication.

    new Octokit({
     auth: 'token secret123'
    })

    Use this for

    • personal access tokens
    • OAuth access tokens
    • GitHub App bearer tokens
    • GitHub App installation tokens
  2. As object with the properties username, password, on2fa.

    on2fa is an asynchronous function that must resolve with two-factor authentication code sent to the user.

    new Octokit({
     auth: {
       username: 'octocat',
       password: 'secret',
       async on2fa () {
         // example: ask the user
         return prompt('Two-factor authentication Code:')
       }
     }
    })
  3. An object with the properties clientId and clientSecret

    OAuth applications can authenticate using their clientId and clientSecret in order to increase the unauthenticated rate limit.

  4. A function

    Must resolve with a string which then will be passed as value for the Authorization header. The function will be called before each request and can be asynchronous.

    new Octokit({
     auth () {
       return 'token secret123'
     }
    })

    This is useful for GitHub apps, as installations need to renew their tokens each hour. Here is an example on how to implement authentication for GitHub Apps

    const App = require('@octokit/app')
    const Octokit = require('@octokit/rest')
    
    const app = new App({ id: process.env.APP_ID, privateKey: process.env.PRIVATE_KEY })
    const octokit = new Octokit({
     async auth () {
       const installationAccessToken = await app.getInstallationAccessToken({ 
         installationId: process.env.INSTALLATION_ID 
       });
       return `token ${installationAccessToken}`;
     }
    })

    See also: https://github.com/octokit/app.js#authenticating-as-an-installation.

activity

List public events

We delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listPublicEvents()

List repository events

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listRepoEvents({
  owner,
  repo
})

List public events for a network of repositories

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listPublicEventsForRepoNetwork({
  owner,
  repo
})

List public events for an organization

Parameters

namerequireddescription
orgyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listPublicEventsForOrg({
  org
})

List events that a user has received

These are events that you've received by watching repos and following users. If you are authenticated as the given user, you will see private events. Otherwise, you'll only see public events.

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listReceivedEventsForUser({
  username
})

List public events that a user has received

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listReceivedPublicEventsForUser({
  username
})

List events performed by a user

If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events.

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listEventsForUser({
  username
})

List public events performed by a user

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listPublicEventsForUser({
  username
})

List events for an organization

This is the user's organization dashboard. You must be authenticated as the user to view this.

Parameters

namerequireddescription
usernameyes
orgyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listEventsForOrg({
  username,
  org
})

List feeds

GitHub provides several timeline resources in Atom format. The Feeds API lists all the feeds available to the authenticated user:

  • Timeline: The GitHub global public timeline
  • User: The public timeline for any user, using URI template
  • Current user public: The public timeline for the authenticated user
  • Current user: The private timeline for the authenticated user
  • Current user actor: The private timeline for activity created by the authenticated user
  • Current user organizations: The private timeline for the organizations the authenticated user is a member of.
  • Security advisories: A collection of public announcements that provide information about security-related vulnerabilities in software on GitHub.

Note: Private feeds are only returned when authenticating via Basic Auth since current feed URIs use the older, non revocable auth tokens.

Parameters

namerequireddescription
octokit.activity.listFeeds()

List your notifications

List all notifications for the current user, sorted by most recently updated.

The following example uses the since parameter to list notifications that have been updated after the specified time.

Parameters

namerequireddescription
allnoIf `true`, show notifications marked as read.
participatingnoIf `true`, only shows notifications in which the user is directly participating or mentioned.
sincenoOnly show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
beforenoOnly show notifications updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listNotifications()

List your notifications in a repository

List all notifications for the current user.

Parameters

namerequireddescription
owneryes
repoyes
allnoIf `true`, show notifications marked as read.
participatingnoIf `true`, only shows notifications in which the user is directly participating or mentioned.
sincenoOnly show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
beforenoOnly show notifications updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listNotificationsForRepo({
  owner,
  repo
})

Mark as read

Marking a notification as "read" removes it from the default view on GitHub. If the number of notifications is too large to complete in one request, you will receive a 202 Accepted status and GitHub will run an asynchronous process to mark notifications as "read." To check whether any "unread" notifications remain, you can use the List your notifications endpoint and pass the query parameter all=false.

Parameters

namerequireddescription
last_read_atnoDescribes the last point that notifications were checked. Anything updated since this time will not be updated. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
octokit.activity.markAsRead()

Mark notifications as read in a repository

Marking all notifications in a repository as "read" removes them from the default view on GitHub. If the number of notifications is too large to complete in one request, you will receive a 202 Accepted status and GitHub will run an asynchronous process to mark notifications as "read." To check whether any "unread" notifications remain, you can use the List your notifications in a repository endpoint and pass the query parameter all=false.

Parameters

namerequireddescription
owneryes
repoyes
last_read_atnoDescribes the last point that notifications were checked. Anything updated since this time will not be updated. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
octokit.activity.markNotificationsAsReadForRepo({
  owner,
  repo
})

View a single thread

Parameters

namerequireddescription
thread_idyes
octokit.activity.getThread({
  thread_id
})

Mark a thread as read

Parameters

namerequireddescription
thread_idyes
octokit.activity.markThreadAsRead({
  thread_id
})

Get a thread subscription

This checks to see if the current user is subscribed to a thread. You can also get a repository subscription.

Note that subscriptions are only generated if a user is participating in a conversation--for example, they've replied to the thread, were @mentioned, or manually subscribe to a thread.

Parameters

namerequireddescription
thread_idyes
octokit.activity.getThreadSubscription({
  thread_id
})

Set a thread subscription

This lets you subscribe or unsubscribe from a conversation.

Parameters

namerequireddescription
thread_idyes
ignorednoUnsubscribes and subscribes you to a conversation. Set `ignored` to `true` to block all notifications from this thread.
octokit.activity.setThreadSubscription({
  thread_id
})

Delete a thread subscription

Mutes all future notifications for a conversation until you comment on the thread or get @mentioned.

Parameters

namerequireddescription
thread_idyes
octokit.activity.deleteThreadSubscription({
  thread_id
})

List Stargazers

You can also find out when stars were created by passing the following custom media type via the Accept header:

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listStargazersForRepo({
  owner,
  repo
})

List repositories being starred by a user

You can also find out when stars were created by passing the following custom media type via the Accept header:

Parameters

namerequireddescription
usernameyes
sortnoOne of `created` (when the repository was starred) or `updated` (when it was last pushed to).
directionnoOne of `asc` (ascending) or `desc` (descending).
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listReposStarredByUser({
  username
})

List repositories being starred by the authenticated user

You can also find out when stars were created by passing the following custom media type via the Accept header:

Parameters

namerequireddescription
sortnoOne of `created` (when the repository was starred) or `updated` (when it was last pushed to).
directionnoOne of `asc` (ascending) or `desc` (descending).
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listReposStarredByAuthenticatedUser()

Check if you are starring a repository

Requires for the user to be authenticated.

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.checkStarringRepo({
  owner,
  repo
})

Star a repository

Requires for the user to be authenticated.

Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.starRepo({
  owner,
  repo
})

Unstar a repository

Requires for the user to be authenticated.

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.unstarRepo({
  owner,
  repo
})

List watchers

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listWatchersForRepo({
  owner,
  repo
})

List repositories being watched by a user

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listReposWatchedByUser({
  username
})

List repositories being watched by the authenticated user

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.activity.listWatchedReposForAuthenticatedUser()

Get a Repository Subscription

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.getRepoSubscription({
  owner,
  repo
})

Set a Repository Subscription

If you would like to watch a repository, set subscribed to true. If you would like to ignore notifications made within a repository, set ignored to true. If you would like to stop watching a repository, delete the repository's subscription completely.

Parameters

namerequireddescription
owneryes
repoyes
subscribednoDetermines if notifications should be received from this repository.
ignorednoDetermines if all notifications should be blocked from this repository.
octokit.activity.setRepoSubscription({
  owner,
  repo
})

Delete a Repository Subscription

This endpoint should only be used to stop watching a repository. To control whether or not you wish to receive notifications from a repository, set the repository's subscription manually.

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.deleteRepoSubscription({
  owner,
  repo
})

Check if you are watching a repository (LEGACY)

Requires for the user to be authenticated.

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.checkWatchingRepoLegacy({
  owner,
  repo
})

Watch a repository (LEGACY)

Requires the user to be authenticated.

Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.watchRepoLegacy({
  owner,
  repo
})

Stop watching a repository (LEGACY)

Requires for the user to be authenticated.

Parameters

namerequireddescription
owneryes
repoyes
octokit.activity.stopWatchingRepoLegacy({
  owner,
  repo
})

apps

Get a single GitHub App

Note: The :app_slug is just the URL-friendly name of your GitHub App. You can find this on the settings page for your GitHub App (e.g., https://github.com/settings/apps/:app_slug).

If the GitHub App you specify is public, you can access this endpoint without authenticating. If the GitHub App you specify is private, you must authenticate with a personal access token or an installation access token to access this endpoint.

Parameters

namerequireddescription
app_slugyes
octokit.apps.getBySlug({
  app_slug
})

Get the authenticated GitHub App

Returns the GitHub App associated with the authentication credentials used.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
octokit.apps.getAuthenticated()

List installations

You must use a JWT to access this endpoint.

The permissions the installation has are included under the permissions key.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listInstallations()

Get an installation

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
installation_idyes
octokit.apps.getInstallation({
  installation_id
})

Delete an installation

Uninstalls a GitHub App on a user, organization, or business account.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
installation_idyes
octokit.apps.deleteInstallation({
  installation_id
})

Create a new installation token

Creates an access token that enables a GitHub App to make authenticated API requests for the app's installation on an organization or individual account. Installation tokens expire one hour from the time you create them. Using an expired token produces a status code of 401 - Unauthorized, and requires creating a new installation token.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
installation_idyes
octokit.apps.createInstallationToken({
  installation_id
})

Get an organization installation

Enables an authenticated GitHub App to find the organization's installation information.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
orgyes
octokit.apps.getOrgInstallation({
  org
})

Find organization installation

Enables an authenticated GitHub App to find the organization's installation information.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
orgyes
octokit.apps.findOrgInstallation({
  org
})

Get a repository installation

Enables an authenticated GitHub App to find the repository's installation information. The installation's account type will be either an organization or a user account, depending which account the repository belongs to.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
owneryes
repoyes
octokit.apps.getRepoInstallation({
  owner,
  repo
})

Find repository installation

Enables an authenticated GitHub App to find the repository's installation information. The installation's account type will be either an organization or a user account, depending which account the repository belongs to.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
owneryes
repoyes
octokit.apps.findRepoInstallation({
  owner,
  repo
})

Get a user installation

Enables an authenticated GitHub App to find the user’s installation information.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
usernameyes
octokit.apps.getUserInstallation({
  username
})

Find repository installation

Enables an authenticated GitHub App to find the user’s installation information.

You must use a JWT to access this endpoint.

Parameters

namerequireddescription
usernameyes
octokit.apps.findUserInstallation({
  username
})

Create a GitHub App from a manifest

Use this endpoint to complete the handshake necessary when implementing the GitHub App Manifest flow. When you create a GitHub App with the manifest flow, you receive a temporary code used to retrieve the GitHub App's id, pem (private key), and webhook_secret.

Parameters

namerequireddescription
codeyes
octokit.apps.createFromManifest({
  code
})

List repositories

List repositories that an installation can access.

You must use an installation access token to access this endpoint.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listRepos()

List installations for a user

Lists installations of your GitHub App that the authenticated user has explicit permission (:read, :write, or :admin) to access.

You must use a user-to-server OAuth access token, created for a user who has authorized your GitHub App, to access this endpoint.

The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.

You can find the permissions for the installation under the permissions key.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listInstallationsForAuthenticatedUser()

List repositories accessible to the user for an installation

List repositories that the authenticated user has explicit permission (:read, :write, or :admin) to access for an installation.

The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.

You must use a user-to-server OAuth access token, created for a user who has authorized your GitHub App, to access this endpoint.

The access the user has to each repository is included in the hash under the permissions key.

Parameters

namerequireddescription
installation_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listInstallationReposForAuthenticatedUser({
  installation_id
})

Add repository to installation

Add a single repository to an installation. The authenticated user must have admin access to the repository.

You must use a personal access token (which you can create via the command line or the OAuth Authorizations API) or Basic Authentication to access this endpoint.

Parameters

namerequireddescription
installation_idyes
repository_idyes
octokit.apps.addRepoToInstallation({
  installation_id,
  repository_id
})

Remove repository from installation

Remove a single repository from an installation. The authenticated user must have admin access to the repository.

You must use a personal access token (which you can create via the command line or the OAuth Authorizations API) or Basic Authentication to access this endpoint.

Parameters

namerequireddescription
installation_idyes
repository_idyes
octokit.apps.removeRepoFromInstallation({
  installation_id,
  repository_id
})

Create a content attachment

Creates an attachment under a content reference URL in the body or comment of an issue or pull request. Use the id of the content reference from the content_reference event to create an attachment.

The app must create a content attachment within six hours of the content reference URL being posted. See "Using content attachments" for details about content attachments.

You must use an installation access token to access this endpoint.

This example creates a content attachment for the domain https://errors.ai/.

Parameters

namerequireddescription
content_reference_idyes
titleyesThe title of the content attachment displayed in the body or comment of an issue or pull request.
bodyyesThe body text of the content attachment displayed in the body or comment of an issue or pull request. This parameter supports markdown.
octokit.apps.createContentAttachment({
  content_reference_id,
  title,
  body
})

List all plans for your Marketplace listing

GitHub Apps must use a JWT to access this endpoint. OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listPlans()

List all plans for your Marketplace listing (stubbed)

GitHub Apps must use a JWT to access this endpoint. OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listPlansStubbed()

List all GitHub accounts (user or organization) on a specific plan

Returns any accounts associated with a plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.

GitHub Apps must use a JWT to access this endpoint. OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.

Parameters

namerequireddescription
plan_idyes
sortnoSorts the GitHub accounts by the date they were created or last updated. Can be one of `created` or `updated`.
directionnoTo return the oldest accounts first, set to `asc`. Can be one of `asc` or `desc`. Ignored without the `sort` parameter.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listAccountsUserOrOrgOnPlan({
  plan_id
})

List all GitHub accounts (user or organization) on a specific plan (stubbed)

Returns any accounts associated with a plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.

GitHub Apps must use a JWT to access this endpoint. OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.

Parameters

namerequireddescription
plan_idyes
sortnoSorts the GitHub accounts by the date they were created or last updated. Can be one of `created` or `updated`.
directionnoTo return the oldest accounts first, set to `asc`. Can be one of `asc` or `desc`. Ignored without the `sort` parameter.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listAccountsUserOrOrgOnPlanStubbed({
  plan_id
})

Check if a GitHub account is associated with any Marketplace listing

Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.

GitHub Apps must use a JWT to access this endpoint. OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.

Parameters

namerequireddescription
account_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.checkAccountIsAssociatedWithAny({
  account_id
})

Check if a GitHub account is associated with any Marketplace listing (stubbed)

Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.

GitHub Apps must use a JWT to access this endpoint. OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.

Parameters

namerequireddescription
account_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.checkAccountIsAssociatedWithAnyStubbed({
  account_id
})

Get a user's Marketplace purchases

Returns only active subscriptions. You must use a user-to-server OAuth access token, created for a user who has authorized your GitHub App, to access this endpoint. . OAuth Apps must authenticate using an OAuth token.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listMarketplacePurchasesForAuthenticatedUser()

Get a user's Marketplace purchases (stubbed)

Returns only active subscriptions. You must use a user-to-server OAuth access token, created for a user who has authorized your GitHub App, to access this endpoint. . OAuth Apps must authenticate using an OAuth token.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.apps.listMarketplacePurchasesForAuthenticatedUserStubbed()

checks

Create a check run

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array.

Creates a new check run for a specific commit in a repository. Your GitHub App must have the checks:write permission to create check runs.

Parameters

namerequireddescription
owneryes
repoyes
nameyesThe name of the check. For example, "code-coverage".
head_shayesThe SHA of the commit.
details_urlnoThe URL of the integrator's site that has the full details of the check.
external_idnoA reference for the run on the integrator's system.
statusnoThe current status. Can be one of `queued`, `in_progress`, or `completed`.
started_atnoThe time that the check run began. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
conclusionno**Required if you provide `completed_at` or a `status` of `completed`**. The final conclusion of the check. Can be one of `success`, `failure`, `neutral`, `cancelled`, `timed_out`, or `action_required`. When the conclusion is `action_required`, additional details should be provided on the site specified by `details_url`. **Note:** Providing `conclusion` will automatically set the `status` parameter to `completed`.
completed_atno**Required if you provide `conclusion`**. The time the check completed. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
outputnoCheck runs can accept a variety of data in the `output` object, including a `title` and `summary` and can optionally provide descriptive details about the run. See the [`output` object](#output-object) description.
output.titleyesThe title of the check run.
output.summaryyesThe summary of the check run. This parameter supports Markdown.
output.textnoThe details of the check run. This parameter supports Markdown.
output.annotationsnoAdds information from your analysis to specific lines of code. Annotations are visible on GitHub in the **Checks** and **Files changed** tab of the pull request. The Checks API limits the number of annotations to a maximum of 50 per API request. To create more than 50 annotations, you have to make multiple requests to the [Update a check run](https://developer.github.com/v3/checks/runs/#update-a-check-run) endpoint. Each time you update the check run, annotations are appended to the list of annotations that already exist for the check run. For details about how you can view annotations on GitHub, see "[About status checks](https://help.github.com/articles/about-status-checks#checks)". See the [`annotations` object](#annotations-object) description for details about how to use this parameter.
output.annotations[].pathyesThe path of the file to add an annotation to. For example, `assets/css/main.css`.
output.annotations[].start_lineyesThe start line of the annotation.
output.annotations[].end_lineyesThe end line of the annotation.
output.annotations[].start_columnnoThe start column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values.
output.annotations[].end_columnnoThe end column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values.
output.annotations[].annotation_levelyesThe level of the annotation. Can be one of `notice`, `warning`, or `failure`.
output.annotations[].messageyesA short description of the feedback for these lines of code. The maximum size is 64 KB.
output.annotations[].titlenoThe title that represents the annotation. The maximum size is 255 characters.
output.annotations[].raw_detailsnoDetails about this annotation. The maximum size is 64 KB.
output.imagesnoAdds images to the output displayed in the GitHub pull request UI. See the [`images` object](#images-object) description for details.
output.images[].altyesThe alternative text for the image.
output.images[].image_urlyesThe full URL of the image.
output.images[].captionnoA short image description.
actionsnoPossible further actions the integrator can perform, which a user may trigger. Each action includes a `label`, `identifier` and `description`. A maximum of three actions are accepted. See the [`actions` object](#actions-object) description.
actions[].labelyesThe text to be displayed on a button in the web UI. The maximum size is 20 characters.
actions[].descriptionyesA short explanation of what this action would do. The maximum size is 40 characters.
actions[].identifieryesA reference for the action on the integrator's system. The maximum size is 20 characters.
octokit.checks.create({
  owner,
  repo,
  name,
  head_sha
})

Update a check run

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array.

Updates a check run for a specific commit in a repository. Your GitHub App must have the checks:write permission to edit check runs.

Parameters

namerequireddescription
owneryes
repoyes
check_run_idyes
namenoThe name of the check. For example, "code-coverage".
details_urlnoThe URL of the integrator's site that has the full details of the check.
external_idnoA reference for the run on the integrator's system.
started_atnoThis is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
statusnoThe current status. Can be one of `queued`, `in_progress`, or `completed`.
conclusionno**Required if you provide `completed_at` or a `status` of `completed`**. The final conclusion of the check. Can be one of `success`, `failure`, `neutral`, `cancelled`, `timed_out`, or `action_required`. **Note:** Providing `conclusion` will automatically set the `status` parameter to `completed`.
completed_atno**Required if you provide `conclusion`**. The time the check completed. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
outputnoCheck runs can accept a variety of data in the `output` object, including a `title` and `summary` and can optionally provide descriptive details about the run. See the [`output` object](#output-object-1) description.
output.titleno**Required**.
output.summaryyesCan contain Markdown.
output.textnoCan contain Markdown.
output.annotationsnoAdds information from your analysis to specific lines of code. Annotations are visible in GitHub's pull request UI. Annotations are visible in GitHub's pull request UI. The Checks API limits the number of annotations to a maximum of 50 per API request. To create more than 50 annotations, you have to make multiple requests to the [Update a check run](https://developer.github.com/v3/checks/runs/#update-a-check-run) endpoint. Each time you update the check run, annotations are appended to the list of annotations that already exist for the check run. For details about annotations in the UI, see "[About status checks](https://help.github.com/articles/about-status-checks#checks)". See the [`annotations` object](#annotations-object-1) description for details.
output.annotations[].pathyesThe path of the file to add an annotation to. For example, `assets/css/main.css`.
output.annotations[].start_lineyesThe start line of the annotation.
output.annotations[].end_lineyesThe end line of the annotation.
output.annotations[].start_columnnoThe start column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values.
output.annotations[].end_columnnoThe end column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values.
output.annotations[].annotation_levelyesThe level of the annotation. Can be one of `notice`, `warning`, or `failure`.
output.annotations[].messageyesA short description of the feedback for these lines of code. The maximum size is 64 KB.
output.annotations[].titlenoThe title that represents the annotation. The maximum size is 255 characters.
output.annotations[].raw_detailsnoDetails about this annotation. The maximum size is 64 KB.
output.imagesnoAdds images to the output displayed in the GitHub pull request UI. See the [`images` object](#annotations-object-1) description for details.
output.images[].altyesThe alternative text for the image.
output.images[].image_urlyesThe full URL of the image.
output.images[].captionnoA short image description.
actionsnoPossible further actions the integrator can perform, which a user may trigger. Each action includes a `label`, `identifier` and `description`. A maximum of three actions are accepted. See the [`actions` object](#actions-object) description.
actions[].labelyesThe text to be displayed on a button in the web UI. The maximum size is 20 characters.
actions[].descriptionyesA short explanation of what this action would do. The maximum size is 40 characters.
actions[].identifieryesA reference for the action on the integrator's system. The maximum size is 20 characters.
octokit.checks.update({
  owner,
  repo,
  check_run_id
})

List check runs for a specific ref

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array.

Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name. GitHub Apps must have the checks:read permission on a private repository or pull access to a public repository to get check runs. OAuth Apps and authenticated users must have the repo scope to get check runs in a private repository.

Parameters

namerequireddescription
owneryes
repoyes
refyes
check_namenoReturns check runs with the specified `name`.
statusnoReturns check runs with the specified `status`. Can be one of `queued`, `in_progress`, or `completed`.
filternoFilters check runs by their `completed_at` timestamp. Can be one of `latest` (returning the most recent check runs) or `all`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.checks.listForRef({
  owner,
  repo,
  ref
})

List check runs in a check suite

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array.

Lists check runs for a check suite using its id. GitHub Apps must have the checks:read permission on a private repository or pull access to a public repository to get check runs. OAuth Apps and authenticated users must have the repo scope to get check runs in a private repository.

Parameters

namerequireddescription
owneryes
repoyes
check_suite_idyes
check_namenoReturns check runs with the specified `name`.
statusnoReturns check runs with the specified `status`. Can be one of `queued`, `in_progress`, or `completed`.
filternoFilters check runs by their `completed_at` timestamp. Can be one of `latest` (returning the most recent check runs) or `all`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.checks.listForSuite({
  owner,
  repo,
  check_suite_id
})

Get a single check run

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array.

Gets a single check run using its id. GitHub Apps must have the checks:read permission on a private repository or pull access to a public repository to get check runs. OAuth Apps and authenticated users must have the repo scope to get check runs in a private repository.

Parameters

namerequireddescription
owneryes
repoyes
check_run_idyes
octokit.checks.get({
  owner,
  repo,
  check_run_id
})

List annotations for a check run

Lists annotations for a check run using the annotation id. GitHub Apps must have the checks:read permission on a private repository or pull access to a public repository to get annotations for a check run. OAuth Apps and authenticated users must have the repo scope to get annotations for a check run in a private repository.

Parameters

namerequireddescription
owneryes
repoyes
check_run_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.checks.listAnnotations({
  owner,
  repo,
  check_run_id
})

Get a single check suite

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array and a null value for head_branch.

Gets a single check suite using its id. GitHub Apps must have the checks:read permission on a private repository or pull access to a public repository to get check suites. OAuth Apps and authenticated users must have the repo scope to get check suites in a private repository.

Parameters

namerequireddescription
owneryes
repoyes
check_suite_idyes
octokit.checks.getSuite({
  owner,
  repo,
  check_suite_id
})

List check suites for a specific ref

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array and a null value for head_branch.

Lists check suites for a commit ref. The ref can be a SHA, branch name, or a tag name. GitHub Apps must have the checks:read permission on a private repository or pull access to a public repository to list check suites. OAuth Apps and authenticated users must have the repo scope to get check suites in a private repository.

Parameters

namerequireddescription
owneryes
repoyes
refyes
app_idnoFilters check suites by GitHub App `id`.
check_namenoFilters checks suites by the name of the [check run](https://developer.github.com/v3/checks/runs/).
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.checks.listSuitesForRef({
  owner,
  repo,
  ref
})

Set preferences for check suites on a repository

Changes the default automatic flow when creating check suites. By default, the CheckSuiteEvent is automatically created each time code is pushed to a repository. When you disable the automatic creation of check suites, you can manually Create a check suite. You must have admin permissions in the repository to set preferences for check suites.

Parameters

namerequireddescription
owneryes
repoyes
auto_trigger_checksnoEnables or disables automatic creation of CheckSuite events upon pushes to the repository. Enabled by default. See the [`auto_trigger_checks` object](#auto_trigger_checks-object) description for details.
auto_trigger_checks[].app_idyesThe `id` of the GitHub App.
auto_trigger_checks[].settingyesSet to `true` to enable automatic creation of CheckSuite events upon pushes to the repository, or `false` to disable them.
octokit.checks.setSuitesPreferences({
  owner,
  repo
})

Create a check suite

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array and a null value for head_branch.

By default, check suites are automatically created when you create a check run. You only need to use this endpoint for manually creating check suites when you've disabled automatic creation using "Set preferences for check suites on a repository". Your GitHub App must have the checks:write permission to create check suites.

Parameters

namerequireddescription
owneryes
repoyes
head_shayesThe sha of the head commit.
octokit.checks.createSuite({
  owner,
  repo,
  head_sha
})

Rerequest check suite

Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository. This endpoint will trigger the check_suite webhook event with the action rerequested. When a check suite is rerequested, its status is reset to queued and the conclusion is cleared.

To rerequest a check suite, your GitHub App must have the checks:read permission on a private repository or pull access to a public repository.

Parameters

namerequireddescription
owneryes
repoyes
check_suite_idyes
octokit.checks.rerequestSuite({
  owner,
  repo,
  check_suite_id
})

codesOfConduct

List all codes of conduct

Parameters

namerequireddescription
octokit.codesOfConduct.listConductCodes()

Get an individual code of conduct

Parameters

namerequireddescription
keyyes
octokit.codesOfConduct.getConductCode({
  key
})

Get the contents of a repository's code of conduct

This method returns the contents of the repository's code of conduct file, if one is detected.

Parameters

namerequireddescription
owneryes
repoyes
octokit.codesOfConduct.getForRepo({
  owner,
  repo
})

emojis

Get

Lists all the emojis available to use on GitHub.

Parameters

namerequireddescription
octokit.emojis.get()

gists

List public gists for the specified user

Parameters

namerequireddescription
usernameyes
sincenoThis is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Only gists updated at or after this time are returned.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.gists.listPublicForUser({
  username
})

List the authenticated user's gists or if called anonymously, this will return all public gists

Parameters

namerequireddescription
sincenoThis is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Only gists updated at or after this time are returned.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.gists.list()

List all public gists

List all public gists sorted by most recently updated to least recently updated.

Note: With pagination, you can fetch up to 3000 gists. For example, you can fetch 100 pages with 30 gists per page or 30 pages with 100 gists per page.

Parameters

namerequireddescription
sincenoThis is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Only gists updated at or after this time are returned.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.gists.listPublic()

List starred gists

List the authenticated user's starred gists:

Parameters

namerequireddescription
sincenoThis is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Only gists updated at or after this time are returned.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.gists.listStarred()

Get a single gist

Parameters

namerequireddescription
gist_idyes
octokit.gists.get({
  gist_id
})

Get a specific revision of a gist

Parameters

namerequireddescription
gist_idyes
shayes
octokit.gists.getRevision({
  gist_id,
  sha
})

Create a gist

Allows you to add a new gist with one or more files.

Note: Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally.

Parameters

namerequireddescription
filesyesThe filenames and content of each file in the gist. The keys in the `files` object represent the filename and have the type `string`.
files.contentnoThe content of the file.
descriptionnoA descriptive name for this gist.
publicnoWhen `true`, the gist will be public and available for anyone to see.
octokit.gists.create({
  files
})

Edit a gist

Allows you to update or delete a gist file and rename gist files. Files from the previous version of the gist that aren't explicitly changed during an edit are unchanged.

Parameters

namerequireddescription
gist_idyes
descriptionnoA descriptive name for this gist.
filesnoThe filenames and content that make up this gist.
files.contentnoThe updated content of the file.
files.filenamenoThe new name for this file. To delete a file, set the value of the filename to `null`.
octokit.gists.update({
  gist_id
})

List gist commits

Parameters

namerequireddescription
gist_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.gists.listCommits({
  gist_id
})

Star a gist

Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Parameters

namerequireddescription
gist_idyes
octokit.gists.star({
  gist_id
})

Unstar a gist

Parameters

namerequireddescription
gist_idyes
octokit.gists.unstar({
  gist_id
})

Check if a gist is starred

Parameters

namerequireddescription
gist_idyes
octokit.gists.checkIsStarred({
  gist_id
})

Fork a gist

Note: This was previously /gists/:gist_id/fork.

Parameters

namerequireddescription
gist_idyes
octokit.gists.fork({
  gist_id
})

List gist forks

Parameters

namerequireddescription
gist_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.gists.listForks({
  gist_id
})

Delete a gist

Parameters

namerequireddescription
gist_idyes
octokit.gists.delete({
  gist_id
})

List comments on a gist

Parameters

namerequireddescription
gist_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.gists.listComments({
  gist_id
})

Get a single comment

Parameters

namerequireddescription
gist_idyes
comment_idyes
octokit.gists.getComment({
  gist_id,
  comment_id
})

Create a comment

Parameters

namerequireddescription
gist_idyes
bodyyesThe comment text.
octokit.gists.createComment({
  gist_id,
  body
})

Edit a comment

Parameters

namerequireddescription
gist_idyes
comment_idyes
bodyyesThe comment text.
octokit.gists.updateComment({
  gist_id,
  comment_id,
  body
})

Delete a comment

Parameters

namerequireddescription
gist_idyes
comment_idyes
octokit.gists.deleteComment({
  gist_id,
  comment_id
})

git

Get a blob

The content in the response will always be Base64 encoded.

_Note_: This API supports blobs up to 100 megabytes in size.

Parameters

namerequireddescription
owneryes
repoyes
file_shayes
octokit.git.getBlob({
  owner,
  repo,
  file_sha
})

Create a blob

Parameters

namerequireddescription
owneryes
repoyes
contentyesThe new blob's content.
encodingnoThe encoding used for `content`. Currently, `"utf-8"` and `"base64"` are supported.
octokit.git.createBlob({
  owner,
  repo,
  content
})

Get a commit

Gets a Git commit object.

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

Value Description
expired_key The key that made the signature is expired.
not_signing_key The "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_error There was an error communicating with the signature verification service.
gpgverify_unavailable The signature verification service is currently unavailable.
unsigned The object does not include a signature.
unknown_signature_type A non-PGP signature was found in the commit.
no_user No user was associated with the committer email address in the commit.
unverified_email The committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_email The committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_key The key that made the signature has not been registered with any user's account.
malformed_signature There was an error parsing the signature.
invalid The signature could not be cryptographically verified using the key whose key-id was found in the signature.
valid None of the above errors applied, so the signature is considered to be verified.

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes
octokit.git.getCommit({
  owner,
  repo,
  commit_sha
})

Create a commit

Creates a new Git commit object.

In this example, the payload of the signature would be:

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

Value Description
expired_key The key that made the signature is expired.
not_signing_key The "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_error There was an error communicating with the signature verification service.
gpgverify_unavailable The signature verification service is currently unavailable.
unsigned The object does not include a signature.
unknown_signature_type A non-PGP signature was found in the commit.
no_user No user was associated with the committer email address in the commit.
unverified_email The committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_email The committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_key The key that made the signature has not been registered with any user's account.
malformed_signature There was an error parsing the signature.
invalid The signature could not be cryptographically verified using the key whose key-id was found in the signature.
valid None of the above errors applied, so the signature is considered to be verified.

Parameters

namerequireddescription
owneryes
repoyes
messageyesThe commit message
treeyesThe SHA of the tree object this commit points to
parentsyesThe SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of more than one should be provided.
authornoInformation about the author of the commit. By default, the `author` will be the authenticated user and the current date. See the `author` and `committer` object below for details.
author.namenoThe name of the author (or committer) of the commit
author.emailnoThe email of the author (or committer) of the commit
author.datenoIndicates when this commit was authored (or committed). This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
committernoInformation about the person who is making the commit. By default, `committer` will use the information set in `author`. See the `author` and `committer` object below for details.
committer.namenoThe name of the author (or committer) of the commit
committer.emailnoThe email of the author (or committer) of the commit
committer.datenoIndicates when this commit was authored (or committed). This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
signaturenoThe [PGP signature](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) of the commit. GitHub adds the signature to the `gpgsig` header of the created commit. For a commit signature to be verifiable by Git or GitHub, it must be an ASCII-armored detached PGP signature over the string commit as it would be written to the object database. To pass a `signature` parameter, you need to first manually create a valid PGP signature, which can be complicated. You may find it easier to [use the command line](https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work) to create signed commits.
octokit.git.createCommit({
  owner,
  repo,
  message,
  tree,
  parents
})

Get a reference

Returns a branch or tag reference. Other than the REST API it always returns a single reference. If the REST API returns with an array then the method responds with an error.

Parameters

namerequireddescription
owneryes
repoyes
refyesMust be formatted as `heads/branch`, not just `branch`
octokit.git.getRef({
  owner,
  repo,
  ref
})

Get all references

This will return an array of all the references on the system, including things like notes and stashes if they exist on the server

Parameters

namerequireddescription
owneryes
repoyes
namespacenoFilter by sub-namespace (reference prefix). Most commen examples would be `'heads/'` and `'tags/'` to retrieve branches or tags
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.git.listRefs({
  owner,
  repo
})

Create a reference

Creates a reference for your repository. You are unable to create new references for empty repositories, even if the commit SHA-1 hash used exists. Empty repositories are repositories without branches.

Parameters

namerequireddescription
owneryes
repoyes
refyesThe name of the fully qualified reference (ie: `refs/heads/master`). If it doesn't start with 'refs' and have at least two slashes, it will be rejected.
shayesThe SHA1 value for this reference.
octokit.git.createRef({
  owner,
  repo,
  ref,
  sha
})

Update a reference

Parameters

namerequireddescription
owneryes
repoyes
refyes
shayesThe SHA1 value to set this reference to
forcenoIndicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to `false` will make sure you're not overwriting work.
octokit.git.updateRef({
  owner,
  repo,
  ref,
  sha
})

Delete a reference

DELETE /repos/octocat/Hello-World/git/refs/heads/feature-a
DELETE /repos/octocat/Hello-World/git/refs/tags/v1.0

Parameters

namerequireddescription
owneryes
repoyes
refyes
octokit.git.deleteRef({
  owner,
  repo,
  ref
})

Get a tag

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

Value Description
expired_key The key that made the signature is expired.
not_signing_key The "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_error There was an error communicating with the signature verification service.
gpgverify_unavailable The signature verification service is currently unavailable.
unsigned The object does not include a signature.
unknown_signature_type A non-PGP signature was found in the commit.
no_user No user was associated with the committer email address in the commit.
unverified_email The committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_email The committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_key The key that made the signature has not been registered with any user's account.
malformed_signature There was an error parsing the signature.
invalid The signature could not be cryptographically verified using the key whose key-id was found in the signature.
valid None of the above errors applied, so the signature is considered to be verified.

Parameters

namerequireddescription
owneryes
repoyes
tag_shayes
octokit.git.getTag({
  owner,
  repo,
  tag_sha
})

Create a tag object

Note that creating a tag object does not create the reference that makes a tag in Git. If you want to create an annotated tag in Git, you have to do this call to create the tag object, and then create the refs/tags/[tag] reference. If you want to create a lightweight tag, you only have to create the tag reference - this call would be unnecessary.

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

Value Description
expired_key The key that made the signature is expired.
not_signing_key The "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_error There was an error communicating with the signature verification service.
gpgverify_unavailable The signature verification service is currently unavailable.
unsigned The object does not include a signature.
unknown_signature_type A non-PGP signature was found in the commit.
no_user No user was associated with the committer email address in the commit.
unverified_email The committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_email The committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_key The key that made the signature has not been registered with any user's account.
malformed_signature There was an error parsing the signature.
invalid The signature could not be cryptographically verified using the key whose key-id was found in the signature.
valid None of the above errors applied, so the signature is considered to be verified.

Parameters

namerequireddescription
owneryes
repoyes
tagyesThe tag's name. This is typically a version (e.g., "v0.0.1").
messageyesThe tag message.
objectyesThe SHA of the git object this is tagging.
typeyesThe type of the object we're tagging. Normally this is a `commit` but it can also be a `tree` or a `blob`.
taggernoAn object with information about the individual creating the tag.
tagger.namenoThe name of the author of the tag
tagger.emailnoThe email of the author of the tag
tagger.datenoWhen this object was tagged. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
octokit.git.createTag({
  owner,
  repo,
  tag,
  message,
  object,
  type
})

Get a tree

If truncated in the response is true, the number of items in the tree array exceeded our maximum limit. If you need to fetch more items, omit the recursive parameter, and fetch one sub-tree at a time. If you need to fetch even more items, you can clone the repository and iterate over the Git data locally.

Parameters

namerequireddescription
owneryes
repoyes
tree_shayes
recursiveno
octokit.git.getTree({
  owner,
  repo,
  tree_sha
})

Create a tree

The tree creation API will take nested entries as well. If both a tree and a nested path modifying that tree are specified, it will overwrite the contents of that tree with the new path contents and write a new tree out.

Parameters

namerequireddescription
owneryes
repoyes
treeyesObjects (of `path`, `mode`, `type`, and `sha`) specifying a tree structure.
tree[].pathnoThe file referenced in the tree.
tree[].modenoThe file mode; one of `100644` for file (blob), `100755` for executable (blob), `040000` for subdirectory (tree), `160000` for submodule (commit), or `120000` for a blob that specifies the path of a symlink.
tree[].typenoEither `blob`, `tree`, or `commit`.
tree[].shanoThe SHA1 checksum ID of the object in the tree. Also called `tree.sha`. **Note:** Use either `tree.sha` or `content` to specify the contents of the entry. Using both `tree.sha` and `content` will return an error.
tree[].contentnoThe content you want this file to have. GitHub will write this blob out and use that SHA for this entry. Use either this, or `tree.sha`. **Note:** Use either `tree.sha` or `content` to specify the contents of the entry. Using both `tree.sha` and `content` will return an error.
base_treenoThe SHA1 of the tree you want to update with new data. If you don't set this, the commit will be created on top of everything; however, it will only contain your change, the rest of your files will show up as deleted.
octokit.git.createTree({
  owner,
  repo,
  tree
})

gitignore

Listing available templates

List all templates available to pass as an option when creating a repository.

Parameters

namerequireddescription
octokit.gitignore.listTemplates()

Get a single template

The API also allows fetching the source of a single template.

Use the raw media type to get the raw contents.

Parameters

namerequireddescription
nameyes
octokit.gitignore.getTemplate({
  name
})

interactions

Get interaction restrictions for an organization

Shows which group of GitHub users can interact with this organization and when the restriction expires. If there are no restrictions, you will see an empty response.

Parameters

namerequireddescription
orgyes
octokit.interactions.getRestrictionsForOrg({
  org
})

Add or update interaction restrictions for an organization

Temporarily restricts interactions to certain GitHub users in any public repository in the given organization. You must be an organization owner to set these restrictions.

Parameters

namerequireddescription
orgyes
limityesSpecifies the group of GitHub users who can comment, open issues, or create pull requests in public repositories for the given organization. Must be one of: `existing_users`, `contributors_only`, or `collaborators_only`.
octokit.interactions.addOrUpdateRestrictionsForOrg({
  org,
  limit
})

Remove interaction restrictions for an organization

Removes all interaction restrictions from public repositories in the given organization. You must be an organization owner to remove restrictions.

Parameters

namerequireddescription
orgyes
octokit.interactions.removeRestrictionsForOrg({
  org
})

Get interaction restrictions for a repository

Shows which group of GitHub users can interact with this repository and when the restriction expires. If there are no restrictions, you will see an empty response.

Parameters

namerequireddescription
owneryes
repoyes
octokit.interactions.getRestrictionsForRepo({
  owner,
  repo
})

Add or update interaction restrictions for a repository

Temporarily restricts interactions to certain GitHub users within the given repository. You must have owner or admin access to set restrictions.

Parameters

namerequireddescription
owneryes
repoyes
limityesSpecifies the group of GitHub users who can comment, open issues, or create pull requests for the given repository. Must be one of: `existing_users`, `contributors_only`, or `collaborators_only`.
octokit.interactions.addOrUpdateRestrictionsForRepo({
  owner,
  repo,
  limit
})

Remove interaction restrictions for a repository

Removes all interaction restrictions from the given repository. You must have owner or admin access to remove restrictions.

Parameters

namerequireddescription
owneryes
repoyes
octokit.interactions.removeRestrictionsForRepo({
  owner,
  repo
})

issues

List all issues assigned to the authenticated user across all visible repositories including owned repositories, member repositories, and organization repositories

Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the pull_request key.

Be aware that the id of a pull request returned from "Issues" endpoints will be an issue id. To find out the pull request id, use the "List pull requests" endpoint.

Parameters

namerequireddescription
filternoIndicates which sorts of issues to return. Can be one of: \* `assigned`: Issues assigned to you \* `created`: Issues created by you \* `mentioned`: Issues mentioning you \* `subscribed`: Issues you're subscribed to updates for \* `all`: All issues the authenticated user can see, regardless of participation or creation
statenoIndicates the state of the issues to return. Can be either `open`, `closed`, or `all`.
labelsnoA list of comma separated label names. Example: `bug,ui,@high`
sortnoWhat to sort results by. Can be either `created`, `updated`, `comments`.
directionnoThe direction of the sort. Can be either `asc` or `desc`.
sincenoOnly issues updated at or after this time are returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.list()

List all issues across owned and member repositories assigned to the authenticated user

Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the pull_request key.

Be aware that the id of a pull request returned from "Issues" endpoints will be an issue id. To find out the pull request id, use the "List pull requests" endpoint.

Parameters

namerequireddescription
filternoIndicates which sorts of issues to return. Can be one of: \* `assigned`: Issues assigned to you \* `created`: Issues created by you \* `mentioned`: Issues mentioning you \* `subscribed`: Issues you're subscribed to updates for \* `all`: All issues the authenticated user can see, regardless of participation or creation
statenoIndicates the state of the issues to return. Can be either `open`, `closed`, or `all`.
labelsnoA list of comma separated label names. Example: `bug,ui,@high`
sortnoWhat to sort results by. Can be either `created`, `updated`, `comments`.
directionnoThe direction of the sort. Can be either `asc` or `desc`.
sincenoOnly issues updated at or after this time are returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.listForAuthenticatedUser()

List all issues for a given organization assigned to the authenticated user

Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the pull_request key.

Be aware that the id of a pull request returned from "Issues" endpoints will be an issue id. To find out the pull request id, use the "List pull requests" endpoint.

Parameters

namerequireddescription
orgyes
filternoIndicates which sorts of issues to return. Can be one of: \* `assigned`: Issues assigned to you \* `created`: Issues created by you \* `mentioned`: Issues mentioning you \* `subscribed`: Issues you're subscribed to updates for \* `all`: All issues the authenticated user can see, regardless of participation or creation
statenoIndicates the state of the issues to return. Can be either `open`, `closed`, or `all`.
labelsnoA list of comma separated label names. Example: `bug,ui,@high`
sortnoWhat to sort results by. Can be either `created`, `updated`, `comments`.
directionnoThe direction of the sort. Can be either `asc` or `desc`.
sincenoOnly issues updated at or after this time are returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.listForOrg({
  org
})

List issues for a repository

Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the pull_request key.

Be aware that the id of a pull request returned from "Issues" endpoints will be an issue id. To find out the pull request id, use the "List pull requests" endpoint.

Parameters

namerequireddescription
owneryes
repoyes
milestonenoIf an `integer` is passed, it should refer to a milestone by its `number` field. If the string `*` is passed, issues with any milestone are accepted. If the string `none` is passed, issues without milestones are returned.
statenoIndicates the state of the issues to return. Can be either `open`, `closed`, or `all`.
assigneenoCan be the name of a user. Pass in `none` for issues with no assigned user, and `*` for issues assigned to any user.
creatornoThe user that created the issue.
mentionednoA user that's mentioned in the issue.
labelsnoA list of comma separated label names. Example: `bug,ui,@high`
sortnoWhat to sort results by. Can be either `created`, `updated`, `comments`.
directionnoThe direction of the sort. Can be either `asc` or `desc`.
sincenoOnly issues updated at or after this time are returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.listForRepo({
  owner,
  repo
})

Get a single issue

The API returns a 301 Moved Permanently status if the issue was transferred to another repository. If the issue was transferred to or deleted from a repository where the authenticated user lacks read access, the API returns a 404 Not Found status. If the issue was deleted from a repository where the authenticated user has read access, the API returns a 410 Gone status. To receive webhook events for transferred and deleted issues, subscribe to the issues webhook.

Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the pull_request key.

Be aware that the id of a pull request returned from "Issues" endpoints will be an issue id. To find out the pull request id, use the "List pull requests" endpoint.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
numberno
octokit.issues.get({
  owner,
  repo,
  issue_number
})

Create an issue

Any user with pull access to a repository can create an issue. If issues are disabled in the repository, the API returns a 410 Gone status.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
titleyesThe title of the issue.
bodynoThe contents of the issue.
assigneenoLogin for the user that this issue should be assigned to. _NOTE: Only users with push access can set the assignee for new issues. The assignee is silently dropped otherwise. **This field is deprecated.**_
milestonenoThe `number` of the milestone to associate this issue with. _NOTE: Only users with push access can set the milestone for new issues. The milestone is silently dropped otherwise._
labelsnoLabels to associate with this issue. _NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise._
assigneesnoLogins for Users to assign to this issue. _NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise._
octokit.issues.create({
  owner,
  repo,
  title
})

Edit an issue

Issue owners and users with push access can edit an issue.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
titlenoThe title of the issue.
bodynoThe contents of the issue.
assigneenoLogin for the user that this issue should be assigned to. **This field is deprecated.**
statenoState of the issue. Either `open` or `closed`.
milestonenoThe `number` of the milestone to associate this issue with or `null` to remove current. _NOTE: Only users with push access can set the milestone for issues. The milestone is silently dropped otherwise._
labelsnoLabels to associate with this issue. Pass one or more Labels to _replace_ the set of Labels on this Issue. Send an empty array (`[]`) to clear all Labels from the Issue. _NOTE: Only users with push access can set labels for issues. Labels are silently dropped otherwise._
assigneesnoLogins for Users to assign to this issue. Pass one or more user logins to _replace_ the set of assignees on this Issue. Send an empty array (`[]`) to clear all assignees from the Issue. _NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise._
numberno
octokit.issues.update({
  owner,
  repo,
  issue_number
})

Lock an issue

Users with push access can lock an issue or pull request's conversation.

Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
lock_reasonnoThe reason for locking the issue or pull request conversation. Lock will fail if you don't use one of these reasons: \* `off-topic` \* `too heated` \* `resolved` \* `spam`
numberno
octokit.issues.lock({
  owner,
  repo,
  issue_number
})

Unlock an issue

Users with push access can unlock an issue's conversation.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
numberno
octokit.issues.unlock({
  owner,
  repo,
  issue_number
})

List assignees

Lists the available assignees for issues in a repository.

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.listAssignees({
  owner,
  repo
})

Check assignee

Checks if a user has permission to be assigned to an issue in this repository.

If the assignee can be assigned to issues in the repository, a 204 header with no content is returned.

Otherwise a 404 status code is returned.

Parameters

namerequireddescription
owneryes
repoyes
assigneeyes
octokit.issues.checkAssignee({
  owner,
  repo,
  assignee
})

Add assignees to an issue

Adds up to 10 assignees to an issue. Users already assigned to an issue are not replaced.

This example adds two assignees to the existing octocat assignee.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
assigneesnoUsernames of people to assign this issue to. _NOTE: Only users with push access can add assignees to an issue. Assignees are silently ignored otherwise._
numberno
octokit.issues.addAssignees({
  owner,
  repo,
  issue_number
})

Remove assignees from an issue

Removes one or more assignees from an issue.

This example removes two of three assignees, leaving the octocat assignee.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
assigneesnoUsernames of assignees to remove from an issue. _NOTE: Only users with push access can remove assignees from an issue. Assignees are silently ignored otherwise._
numberno
octokit.issues.removeAssignees({
  owner,
  repo,
  issue_number
})

List comments on an issue

Issue Comments are ordered by ascending ID.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
sincenoOnly comments updated at or after this time are returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.issues.listComments({
  owner,
  repo,
  issue_number
})

List comments in a repository

By default, Issue Comments are ordered by ascending ID.

Parameters

namerequireddescription
owneryes
repoyes
sortnoEither `created` or `updated`.
directionnoEither `asc` or `desc`. Ignored without the `sort` parameter.
sincenoOnly comments updated at or after this time are returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
octokit.issues.listCommentsForRepo({
  owner,
  repo
})

Get a single comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.getComment({
  owner,
  repo,
  comment_id
})

Create a comment

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
bodyyesThe contents of the comment.
numberno
octokit.issues.createComment({
  owner,
  repo,
  issue_number,
  body
})

Edit a comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
bodyyesThe contents of the comment.
octokit.issues.updateComment({
  owner,
  repo,
  comment_id,
  body
})

Delete a comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
octokit.issues.deleteComment({
  owner,
  repo,
  comment_id
})

List events for an issue

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.issues.listEvents({
  owner,
  repo,
  issue_number
})

List events for a repository

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.listEventsForRepo({
  owner,
  repo
})

Get a single event

Parameters

namerequireddescription
owneryes
repoyes
event_idyes
octokit.issues.getEvent({
  owner,
  repo,
  event_id
})

List all labels for this repository

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.listLabelsForRepo({
  owner,
  repo
})

Get a single label

Parameters

namerequireddescription
owneryes
repoyes
nameyes
octokit.issues.getLabel({
  owner,
  repo,
  name
})

Create a label

Parameters

namerequireddescription
owneryes
repoyes
nameyesThe name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing `:strawberry:` will render the emoji ![:strawberry:](https://github.githubassets.com/images/icons/emoji/unicode/1f353.png ":strawberry:"). For a full list of available emoji and codes, see [emoji-cheat-sheet.com](http://emoji-cheat-sheet.com/).
coloryesThe [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`.
descriptionnoA short description of the label.
octokit.issues.createLabel({
  owner,
  repo,
  name,
  color
})

Update a label

Parameters

namerequireddescription
owneryes
repoyes
current_nameyes
namenoThe new name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing `:strawberry:` will render the emoji ![:strawberry:](https://github.githubassets.com/images/icons/emoji/unicode/1f353.png ":strawberry:"). For a full list of available emoji and codes, see [emoji-cheat-sheet.com](http://emoji-cheat-sheet.com/).
colornoThe [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`.
descriptionnoA short description of the label.
octokit.issues.updateLabel({
  owner,
  repo,
  current_name
})

Delete a label

Parameters

namerequireddescription
owneryes
repoyes
nameyes
octokit.issues.deleteLabel({
  owner,
  repo,
  name
})

List labels on an issue

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.issues.listLabelsOnIssue({
  owner,
  repo,
  issue_number
})

Add labels to an issue

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
labelsyesThe name of the label to add to the issue. Must contain at least one label. **Note:** Alternatively, you can pass a single label as a `string` or an `array` of labels directly, but GitHub recommends passing an object with the `labels` key.
numberno
octokit.issues.addLabels({
  owner,
  repo,
  issue_number,
  labels
})

Remove a label from an issue

Removes the specified label from the issue, and returns the remaining labels on the issue. This endpoint returns a 404 Not Found status if the label does not exist.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
nameyes
numberno
octokit.issues.removeLabel({
  owner,
  repo,
  issue_number,
  name
})

Replace all labels for an issue

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
labelsnoThe names of the labels to add to the issue. You can pass an empty array to remove all labels. **Note:** Alternatively, you can pass a single label as a `string` or an `array` of labels directly, but GitHub recommends passing an object with the `labels` key.
numberno
octokit.issues.replaceLabels({
  owner,
  repo,
  issue_number
})

Remove all labels from an issue

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
numberno
octokit.issues.removeLabels({
  owner,
  repo,
  issue_number
})

Get labels for every issue in a milestone

Parameters

namerequireddescription
owneryes
repoyes
milestone_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.issues.listLabelsForMilestone({
  owner,
  repo,
  milestone_number
})

List milestones for a repository

Parameters

namerequireddescription
owneryes
repoyes
statenoThe state of the milestone. Either `open`, `closed`, or `all`.
sortnoWhat to sort results by. Either `due_on` or `completeness`.
directionnoThe direction of the sort. Either `asc` or `desc`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.issues.listMilestonesForRepo({
  owner,
  repo
})

Get a single milestone

Parameters

namerequireddescription
owneryes
repoyes
milestone_numberyes
numberno
octokit.issues.getMilestone({
  owner,
  repo,
  milestone_number
})

Create a milestone

Parameters

namerequireddescription
owneryes
repoyes
titleyesThe title of the milestone.
statenoThe state of the milestone. Either `open` or `closed`.
descriptionnoA description of the milestone.
due_onnoThe milestone due date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
octokit.issues.createMilestone({
  owner,
  repo,
  title
})

Update a milestone

Parameters

namerequireddescription
owneryes
repoyes
milestone_numberyes
titlenoThe title of the milestone.
statenoThe state of the milestone. Either `open` or `closed`.
descriptionnoA description of the milestone.
due_onnoThe milestone due date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
numberno
octokit.issues.updateMilestone({
  owner,
  repo,
  milestone_number
})

Delete a milestone

Parameters

namerequireddescription
owneryes
repoyes
milestone_numberyes
numberno
octokit.issues.deleteMilestone({
  owner,
  repo,
  milestone_number
})

List events for an issue

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.issues.listEventsForTimeline({
  owner,
  repo,
  issue_number
})

licenses

List commonly used licenses

Parameters

namerequireddescription
octokit.licenses.listCommonlyUsed()

List all licenses

Parameters

namerequireddescription
octokit.licenses.list()

Get an individual license

Parameters

namerequireddescription
licenseyes
octokit.licenses.get({
  license
})

Get the contents of a repository's license

This method returns the contents of the repository's license file, if one is detected.

Similar to the repository contents API, this method also supports custom media types for retrieving the raw license content or rendered license HTML.

Parameters

namerequireddescription
owneryes
repoyes
octokit.licenses.getForRepo({
  owner,
  repo
})

markdown

Render an arbitrary Markdown document

Parameters

namerequireddescription
textyesThe Markdown text to render in HTML. Markdown content must be 400 KB or less.
modenoThe rendering mode. Can be either: \* `markdown` to render a document in plain Markdown, just like README.md files are rendered. \* `gfm` to render a document in [GitHub Flavored Markdown](https://github.github.com/gfm/), which creates links for user mentions as well as references to SHA-1 hashes, issues, and pull requests.
contextnoThe repository context to use when creating references in `gfm` mode. Omit this parameter when using `markdown` mode.
octokit.markdown.render({
  text
})

Render a Markdown document in raw mode

You must send Markdown as plain text (using a Content-Type header of text/plain or text/x-markdown) to this endpoint, rather than using JSON format. In raw mode, GitHub Flavored Markdown is not supported and Markdown will be rendered in plain format like a README.md file. Markdown content must be 400 KB or less.

Parameters

namerequireddescription
datayes
octokit.markdown.renderRaw({
  data
})

meta

Get

This endpoint provides a list of GitHub's IP addresses. For more information, see "About GitHub's IP addresses."

Parameters

namerequireddescription
octokit.meta.get()

migrations

Start an organization migration

Initiates the generation of a migration archive.

Parameters

namerequireddescription
orgyes
repositoriesyesA list of arrays indicating which repositories should be migrated.
lock_repositoriesnoIndicates whether repositories should be locked (to prevent manipulation) while migrating data.
exclude_attachmentsnoIndicates whether attachments should be excluded from the migration (to reduce migration archive file size).
octokit.migrations.startForOrg({
  org,
  repositories
})

Get a list of organization migrations

Lists the most recent migrations.

Parameters

namerequireddescription
orgyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.migrations.listForOrg({
  org
})

Get the status of an organization migration

Fetches the status of a migration.

The state of a migration can be one of the following values:

  • pending, which means the migration hasn't started yet.
  • exporting, which means the migration is in progress.
  • exported, which means the migration finished successfully.
  • failed, which means the migration failed.

Parameters

namerequireddescription
orgyes
migration_idyes
octokit.migrations.getStatusForOrg({
  org,
  migration_id
})

Download an organization migration archive

Fetches the URL to a migration archive.

Parameters

namerequireddescription
orgyes
migration_idyes
octokit.migrations.getArchiveForOrg({
  org,
  migration_id
})

Delete an organization migration archive

Deletes a previous migration archive. Migration archives are automatically deleted after seven days.

Parameters

namerequireddescription
orgyes
migration_idyes
octokit.migrations.deleteArchiveForOrg({
  org,
  migration_id
})

Unlock an organization repository

Unlocks a repository that was locked for migration. You should unlock each migrated repository and delete them when the migration is complete and you no longer need the source data.

Parameters

namerequireddescription
orgyes
migration_idyes
repo_nameyes
octokit.migrations.unlockRepoForOrg({
  org,
  migration_id,
  repo_name
})

Start an import

Start a source import to a GitHub repository using GitHub Importer.

Parameters

namerequireddescription
owneryes
repoyes
vcs_urlyesThe URL of the originating repository.
vcsnoThe originating VCS type. Can be one of `subversion`, `git`, `mercurial`, or `tfvc`. Please be aware that without this parameter, the import job will take additional time to detect the VCS type before beginning the import. This detection step will be reflected in the response.
vcs_usernamenoIf authentication is required, the username to provide to `vcs_url`.
vcs_passwordnoIf authentication is required, the password to provide to `vcs_url`.
tfvc_projectnoFor a tfvc import, the name of the project that is being imported.
octokit.migrations.startImport({
  owner,
  repo,
  vcs_url
})

Get import progress

View the progress of an import.

Import status

This section includes details about the possible values of the status field of the Import Progress response.

An import that does not have errors will progress through these steps:

  • detecting - the "detection" step of the import is in progress because the request did not include a vcs parameter. The import is identifying the type of source control present at the URL.
  • importing - the "raw" step of the import is in progress. This is where commit data is fetched from the original repository. The import progress response will include commit_count (the total number of raw commits that will be imported) and percent (0 - 100, the current progress through the import).
  • mapping - the "rewrite" step of the import is in progress. This is where SVN branches are converted to Git branches, and where author updates are applied. The import progress response does not include progress information.
  • pushing - the "push" step of the import is in progress. This is where the importer updates the repository on GitHub. The import progress response will include push_percent, which is the percent value reported by git push when it is "Writing objects".
  • complete - the import is complete, and the repository is ready on GitHub.

If there are problems, you will see one of these in the status field:

  • auth_failed - the import requires authentication in order to connect to the original repository. To update authentication for the import, please see the Update Existing Import section.
  • error - the import encountered an error. The import progress response will include the failed_step and an error message. Contact GitHub Support for more information.
  • detection_needs_auth - the importer requires authentication for the originating repository to continue detection. To update authentication for the import, please see the Update Existing Import section.
  • detection_found_nothing - the importer didn't recognize any source control at the URL. To resolve, Cancel the import and retry with the correct URL.
  • detection_found_multiple - the importer found several projects or repositories at the provided URL. When this is the case, the Import Progress response will also include a project_choices field with the possible project choices as values. To update project choice, please see the Update Existing Import section.

The project_choices field

When multiple projects are found at the provided URL, the response hash will include a project_choices field, the value of which is an array of hashes each representing a project choice. The exact key/value pairs of the project hashes will differ depending on the version control type.

Git LFS related fields

This section includes details about Git LFS related fields that may be present in the Import Progress response.

  • use_lfs - describes whether the import has been opted in or out of using Git LFS. The value can be opt_in, opt_out, or undecided if no action has been taken.
  • has_large_files - the boolean value describing whether files larger than 100MB were found during the importing step.
  • large_files_size - the total size in gigabytes of files larger than 100MB found in the originating repository.
  • large_files_count - the total number of files larger than 100MB found in the originating repository. To see a list of these files, make a "Get Large Files" request.

Parameters

namerequireddescription
owneryes
repoyes
octokit.migrations.getImportProgress({
  owner,
  repo
})

Update existing import

An import can be updated with credentials or a project choice by passing in the appropriate parameters in this API request. If no parameters are provided, the import will be restarted.

Some servers (e.g. TFS servers) can have several projects at a single URL. In those cases the import progress will have the status detection_found_multiple and the Import Progress response will include a project_choices array. You can select the project to import by providing one of the objects in the project_choices array in the update request.

The following example demonstrates the workflow for updating an import with "project1" as the project choice. Given a project_choices array like such:

To restart an import, no parameters are provided in the update request.

Parameters

namerequireddescription
owneryes
repoyes
vcs_usernamenoThe username to provide to the originating repository.
vcs_passwordnoThe password to provide to the originating repository.
octokit.migrations.updateImport({
  owner,
  repo
})

Get commit authors

Each type of source control system represents authors in a different way. For example, a Git commit author has a display name and an email address, but a Subversion commit author just has a username. The GitHub Importer will make the author information valid, but the author might not be correct. For example, it will change the bare Subversion username hubot into something like hubot <hubot@12341234-abab-fefe-8787-fedcba987654>.

This API method and the "Map a commit author" method allow you to provide correct Git author information.

Parameters

namerequireddescription
owneryes
repoyes
sincenoOnly authors found after this id are returned. Provide the highest author ID you've seen so far. New authors may be added to the list at any point while the importer is performing the `raw` step.
octokit.migrations.getCommitAuthors({
  owner,
  repo
})

Map a commit author

Update an author's identity for the import. Your application can continue updating authors any time before you push new commits to the repository.

Parameters

namerequireddescription
owneryes
repoyes
author_idyes
emailnoThe new Git author email.
namenoThe new Git author name.
octokit.migrations.mapCommitAuthor({
  owner,
  repo,
  author_id
})

Set Git LFS preference

You can import repositories from Subversion, Mercurial, and TFS that include files larger than 100MB. This ability is powered by Git LFS. You can learn more about our LFS feature and working with large files on our help site.

Parameters

namerequireddescription
owneryes
repoyes
use_lfsyesCan be one of `opt_in` (large files will be stored using Git LFS) or `opt_out` (large files will be removed during the import).
octokit.migrations.setLfsPreference({
  owner,
  repo,
  use_lfs
})

Get large files

List files larger than 100MB found during the import

Parameters

namerequireddescription
owneryes
repoyes
octokit.migrations.getLargeFiles({
  owner,
  repo
})

Cancel an import

Stop an import for a repository.

Parameters

namerequireddescription
owneryes
repoyes
octokit.migrations.cancelImport({
  owner,
  repo
})

Start a user migration

Initiates the generation of a user migration archive.

Parameters

namerequireddescription
repositoriesyesAn array of repositories to include in the migration.
lock_repositoriesnoLocks the `repositories` to prevent changes during the migration when set to `true`.
exclude_attachmentsnoDoes not include attachments uploaded to GitHub.com in the migration data when set to `true`. Excluding attachments will reduce the migration archive file size.
octokit.migrations.startForAuthenticatedUser({
  repositories
})

Get a list of user migrations

Lists all migrations a user has started.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.migrations.listForAuthenticatedUser()

Get the status of a user migration

Fetches a single user migration. The response includes the state of the migration, which can be one of the following values:

  • pending - the migration hasn't started yet.
  • exporting - the migration is in progress.
  • exported - the migration finished successfully.
  • failed - the migration failed.

Once the migration has been exported you can download the migration archive.

Parameters

namerequireddescription
migration_idyes
octokit.migrations.getStatusForAuthenticatedUser({
  migration_id
})

Download a user migration archive

Fetches the URL to download the migration archive as a tar.gz file. Depending on the resources your repository uses, the migration archive can contain JSON files with data for these objects:

  • attachments
  • bases
  • commit_comments
  • issue_comments
  • issue_events
  • issues
  • milestones
  • organizations
  • projects
  • protected_branches
  • pull_request_reviews
  • pull_requests
  • releases
  • repositories
  • review_comments
  • schema
  • users

The archive will also contain an attachments directory that includes all attachment files uploaded to GitHub.com and a repositories directory that contains the repository's Git data.

Parameters

namerequireddescription
migration_idyes
octokit.migrations.getArchiveForAuthenticatedUser({
  migration_id
})

Delete a user migration archive

Deletes a previous migration archive. Downloadable migration archives are automatically deleted after seven days. Migration metadata, which is returned in the Get a list of user migrations and Get the status of a user migration endpoints, will continue to be available even after an archive is deleted.

Parameters

namerequireddescription
migration_idyes
octokit.migrations.deleteArchiveForAuthenticatedUser({
  migration_id
})

Unlock a user repository

Unlocks a repository. You can lock repositories when you start a user migration. Once the migration is complete you can unlock each repository to begin using it again or delete the repository if you no longer need the source data. Returns a status of 404 Not Found if the repository is not locked.

Parameters

namerequireddescription
migration_idyes
repo_nameyes
octokit.migrations.unlockRepoForAuthenticatedUser({
  migration_id,
  repo_name
})

oauthAuthorizations

List your grants

You can use this API to list the set of OAuth applications that have been granted access to your account. Unlike the list your authorizations API, this API does not manage individual tokens. This API will return one entry for each OAuth application that has been granted access to your account, regardless of the number of tokens an application has generated for your user. The list of OAuth applications returned matches what is shown on the application authorizations settings screen within GitHub. The scopes returned are the union of scopes authorized for the application. For example, if an application has one token with repo scope and another token with user scope, the grant will return ["repo", "user"].

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.oauthAuthorizations.listGrants()

Get a single grant

Parameters

namerequireddescription
grant_idyes
octokit.oauthAuthorizations.getGrant({
  grant_id
})

Delete a grant

Deleting an OAuth application's grant will also delete all OAuth tokens associated with the application for your user. Once deleted, the application has no access to your account and is no longer listed on the application authorizations settings screen within GitHub.

Parameters

namerequireddescription
grant_idyes
octokit.oauthAuthorizations.deleteGrant({
  grant_id
})

List your authorizations

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.oauthAuthorizations.listAuthorizations()

Get a single authorization

Parameters

namerequireddescription
authorization_idyes
octokit.oauthAuthorizations.getAuthorization({
  authorization_id
})

Create a new authorization

Creates OAuth tokens using Basic Authentication. If you have two-factor authentication setup, Basic Authentication for this endpoint requires that you use a one-time password (OTP) and your username and password instead of tokens. For more information, see "Woking with two-factor authentication."

You can use this endpoint to create multiple OAuth tokens instead of implementing the web flow.

To create tokens for a particular OAuth application using this endpoint, you must authenticate as the user you want to create an authorization for and provide the app's client ID and secret, found on your OAuth application's settings page. If your OAuth application intends to create multiple tokens for one user, use fingerprint to differentiate between them.

You can also create tokens on GitHub from the personal access tokens settings page. Read more about these tokens in the GitHub Help documentation.

Organizations that enforce SAML SSO require personal access tokens to be whitelisted. Read more about whitelisting tokens in the GitHub Help documentation.

Parameters

namerequireddescription
scopesnoA list of scopes that this authorization is in.
noteyesA note to remind you what the OAuth token is for. Tokens not associated with a specific OAuth application (i.e. personal access tokens) must have a unique note.
note_urlnoA URL to remind you what app the OAuth token is for.
client_idnoThe 20 character OAuth app client key for which to create the token.
client_secretnoThe 40 character OAuth app client secret for which to create the token.
fingerprintnoA unique string to distinguish an authorization from others created for the same client ID and user.
octokit.oauthAuthorizations.createAuthorization({
  note
})

Get-or-create an authorization for a specific app

Creates a new authorization for the specified OAuth application, only if an authorization for that application doesn't already exist for the user. The URL includes the 20 character client ID for the OAuth app that is requesting the token. It returns the user's existing authorization for the application if one is present. Otherwise, it creates and returns a new one.

If you have two-factor authentication setup, Basic Authentication for this endpoint requires that you use a one-time password (OTP) and your username and password instead of tokens. For more information, see "Woking with two-factor authentication."

Parameters

namerequireddescription
client_idyes
client_secretyesThe 40 character OAuth app client secret associated with the client ID specified in the URL.
scopesnoA list of scopes that this authorization is in.
notenoA note to remind you what the OAuth token is for.
note_urlnoA URL to remind you what app the OAuth token is for.
fingerprintnoA unique string to distinguish an authorization from others created for the same client and user. If provided, this API is functionally equivalent to [Get-or-create an authorization for a specific app and fingerprint](https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app-and-fingerprint).
octokit.oauthAuthorizations.getOrCreateAuthorizationForApp({
  client_id,
  client_secret
})

Get-or-create an authorization for a specific app and fingerprint

This method will create a new authorization for the specified OAuth application, only if an authorization for that application and fingerprint do not already exist for the user. The URL includes the 20 character client ID for the OAuth app that is requesting the token. fingerprint is a unique string to distinguish an authorization from others created for the same client ID and user. It returns the user's existing authorization for the application if one is present. Otherwise, it creates and returns a new one.

If you have two-factor authentication setup, Basic Authentication for this endpoint requires that you use a one-time password (OTP) and your username and password instead of tokens. For more information, see "Woking with two-factor authentication."

Parameters

namerequireddescription
client_idyes
fingerprintyes
client_secretyesThe 40 character OAuth app client secret associated with the client ID specified in the URL.
scopesnoA list of scopes that this authorization is in.
notenoA note to remind you what the OAuth token is for.
note_urlnoA URL to remind you what app the OAuth token is for.
octokit.oauthAuthorizations.getOrCreateAuthorizationForAppAndFingerprint({
  client_id,
  fingerprint,
  client_secret
})

Get-or-create an authorization for a specific app and fingerprint

This method will create a new authorization for the specified OAuth application, only if an authorization for that application and fingerprint do not already exist for the user. The URL includes the 20 character client ID for the OAuth app that is requesting the token. fingerprint is a unique string to distinguish an authorization from others created for the same client ID and user. It returns the user's existing authorization for the application if one is present. Otherwise, it creates and returns a new one.

If you have two-factor authentication setup, Basic Authentication for this endpoint requires that you use a one-time password (OTP) and your username and password instead of tokens. For more information, see "Woking with two-factor authentication."

Parameters

namerequireddescription
client_idyes
fingerprintyes
client_secretyesThe 40 character OAuth app client secret associated with the client ID specified in the URL.
scopesnoA list of scopes that this authorization is in.
notenoA note to remind you what the OAuth token is for.
note_urlnoA URL to remind you what app the OAuth token is for.
octokit.oauthAuthorizations.getOrCreateAuthorizationForAppFingerprint({
  client_id,
  fingerprint,
  client_secret
})

Update an existing authorization

If you have two-factor authentication setup, Basic Authentication for this endpoint requires that you use a one-time password (OTP) and your username and password instead of tokens. For more information, see "Woking with two-factor authentication."

You can only send one of these scope keys at a time.

Parameters

namerequireddescription
authorization_idyes
scopesnoReplaces the authorization scopes with these.
add_scopesnoA list of scopes to add to this authorization.
remove_scopesnoA list of scopes to remove from this authorization.
notenoA note to remind you what the OAuth token is for. Tokens not associated with a specific OAuth application (i.e. personal access tokens) must have a unique note.
note_urlnoA URL to remind you what app the OAuth token is for.
fingerprintnoA unique string to distinguish an authorization from others created for the same client ID and user.
octokit.oauthAuthorizations.updateAuthorization({
  authorization_id
})

Delete an authorization

Parameters

namerequireddescription
authorization_idyes
octokit.oauthAuthorizations.deleteAuthorization({
  authorization_id
})

Check an authorization

OAuth applications can use a special API method for checking OAuth token validity without running afoul of normal rate limits for failed login attempts. Authentication works differently with this particular endpoint. You must use Basic Authentication when accessing it, where the username is the OAuth application client_id and the password is its client_secret. Invalid tokens will return 404 NOT FOUND.

Parameters

namerequireddescription
client_idyes
access_tokenyes
octokit.oauthAuthorizations.checkAuthorization({
  client_id,
  access_token
})

Reset an authorization

OAuth applications can use this API method to reset a valid OAuth token without end user involvement. Applications must save the "token" property in the response, because changes take effect immediately. You must use Basic Authentication when accessing it, where the username is the OAuth application client_id and the password is its client_secret. Invalid tokens will return 404 NOT FOUND.

Parameters

namerequireddescription
client_idyes
access_tokenyes
octokit.oauthAuthorizations.resetAuthorization({
  client_id,
  access_token
})

Revoke an authorization for an application

OAuth application owners can revoke a single token for an OAuth application. You must use Basic Authentication for this method, where the username is the OAuth application client_id and the password is its client_secret.

Parameters

namerequireddescription
client_idyes
access_tokenyes
octokit.oauthAuthorizations.revokeAuthorizationForApplication({
  client_id,
  access_token
})

Revoke a grant for an application

OAuth application owners can revoke a grant for their OAuth application and a specific user. You must use Basic Authentication for this method, where the username is the OAuth application client_id and the password is its client_secret. You must also provide a valid token as :access_token and the grant for the token's owner will be deleted.

Deleting an OAuth application's grant will also delete all OAuth tokens associated with the application for the user. Once deleted, the application will have no access to the user's account and will no longer be listed on the application authorizations settings screen within GitHub.

Parameters

namerequireddescription
client_idyes
access_tokenyes
octokit.oauthAuthorizations.revokeGrantForApplication({
  client_id,
  access_token
})

orgs

List your organizations

List organizations for the authenticated user.

OAuth scope requirements

This only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with read:org scope, you can publicize your organization membership with user scope, etc.). Therefore, this API requires at least user or read:org scope. OAuth requests with insufficient scope receive a 403 Forbidden response.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listForAuthenticatedUser()

List all organizations

Lists all organizations, in the order that they were created on GitHub.

Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of organizations.

Parameters

namerequireddescription
sincenoThe integer ID of the last Organization that you've seen.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.list()

List user organizations

List public organization memberships for the specified user.

This method only lists public memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the List your organizations API instead.

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listForUser({
  username
})

Get an organization

To see many of the organization response values, you need to be an authenticated organization owner with the admin:org scope. When the value of two_factor_requirement_enabled is true, the organization requires all members, billing managers, and outside collaborators to enable two-factor authentication.

Parameters

namerequireddescription
orgyes
octokit.orgs.get({
  org
})

Edit an organization

Note: The new members_allowed_repository_creation_type replaces the functionality of members_can_create_repositories.

Setting members_allowed_repository_creation_type will override the value of members_can_create_repositories in the following ways:

  • Setting members_allowed_repository_creation_type to all or private sets members_can_create_repositories to true.
  • Setting members_allowed_repository_creation_type to none sets members_can_create_repositories to false.
  • If you omit members_allowed_repository_creation_type, members_can_create_repositories is not modified.

Parameters

namerequireddescription
orgyes
billing_emailnoBilling email address. This address is not publicized.
companynoThe company name.
emailnoThe publicly visible email address.
locationnoThe location.
namenoThe shorthand name of the company.
descriptionnoThe description of the company.
has_organization_projectsnoToggles whether organization projects are enabled for the organization.
has_repository_projectsnoToggles whether repository projects are enabled for repositories that belong to the organization.
default_repository_permissionnoDefault permission level members have for organization repositories: \* `read` - can pull, but not push to or administer this repository. \* `write` - can pull and push, but not administer this repository. \* `admin` - can pull, push, and administer this repository. \* `none` - no permissions granted by default.
members_can_create_repositoriesnoToggles the ability of non-admin organization members to create repositories. Can be one of: \* `true` - all organization members can create repositories. \* `false` - only admin members can create repositories. Default: `true` **Note:** Another parameter can override the this parameter. See [this note](#members_can_create_repositories) for details. **Note:** Another parameter can override the this parameter. See [this note](#members_can_create_repositories) for details.
members_allowed_repository_creation_typenoSpecifies which types of repositories non-admin organization members can create. Can be one of: \* `all` - all organization members can create public and private repositories. \* `private` - members can create private repositories. This option is only available to repositories that are part of an organization on [GitHub Business Cloud](https://github.com/pricing/business-cloud). \* `none` - only admin members can create repositories. **Note:** Using this parameter will override values set in `members_can_create_repositories`. See [this note](#members_can_create_repositories) for details.
octokit.orgs.update({
  org
})

List credential authorizations for an organization

Listing and deleting credential authorizations is available to organizations with GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

An authenticated organization owner with the read:org scope can list all credential authorizations for an organization that uses SAML single sign-on (SSO). The credentials are either personal access tokens or SSH keys that organization members have authorized for the organization. For more information, see About authentication with SAML single sign-on.

Parameters

namerequireddescription
orgyes
octokit.orgs.listCredentialAuthorizations({
  org
})

Remove a credential authorization for an organization

Listing and deleting credential authorizations is available to organizations with GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

An authenticated organization owner with the admin:org scope can remove a credential authorization for an organization that uses SAML SSO. Once you remove someone's credential authorization, they will need to create a new personal access token or SSH key and authorize it for the organization they want to access.

Parameters

namerequireddescription
orgyes
credential_idyes
octokit.orgs.removeCredentialAuthorization({
  org,
  credential_id
})

List blocked users

List the users blocked by an organization.

Parameters

namerequireddescription
orgyes
octokit.orgs.listBlockedUsers({
  org
})

Check whether a user is blocked from an organization

If the user is blocked:

If the user is not blocked:

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.checkBlockedUser({
  org,
  username
})

Block a user

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.blockUser({
  org,
  username
})

Unblock a user

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.unblockUser({
  org,
  username
})

List hooks

Parameters

namerequireddescription
orgyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listHooks({
  org
})

Get single hook

Parameters

namerequireddescription
orgyes
hook_idyes
octokit.orgs.getHook({
  org,
  hook_id
})

Create a hook

Here's how you can create a hook that posts payloads in JSON format:

Parameters

namerequireddescription
orgyes
nameyesMust be passed as "web".
configyesKey/value pairs to provide settings for this webhook. [These are defined below](#create-hook-config-params).
config.urlyesThe URL to which the payloads will be delivered.
config.content_typenoThe media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`.
config.secretnoIf provided, the `secret` will be used as the `key` to generate the HMAC hex digest value in the [`X-Hub-Signature`](https://developer.github.com/webhooks/#delivery-headers) header.
config.insecure_sslnoDetermines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.**
eventsnoDetermines what [events](https://developer.github.com/v3/activity/events/types/) the hook is triggered for.
activenoDetermines if notifications are sent when the webhook is triggered. Set to `true` to send notifications.
octokit.orgs.createHook({
  org,
  name,
  config
})

Edit a hook

Parameters

namerequireddescription
orgyes
hook_idyes
confignoKey/value pairs to provide settings for this webhook. [These are defined below](#update-hook-config-params).
config.urlyesThe URL to which the payloads will be delivered.
config.content_typenoThe media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`.
config.secretnoIf provided, the `secret` will be used as the `key` to generate the HMAC hex digest value in the [`X-Hub-Signature`](https://developer.github.com/webhooks/#delivery-headers) header.
config.insecure_sslnoDetermines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.**
eventsnoDetermines what [events](https://developer.github.com/v3/activity/events/types/) the hook is triggered for.
activenoDetermines if notifications are sent when the webhook is triggered. Set to `true` to send notifications.
octokit.orgs.updateHook({
  org,
  hook_id
})

Ping a hook

This will trigger a ping event to be sent to the hook.

Parameters

namerequireddescription
orgyes
hook_idyes
octokit.orgs.pingHook({
  org,
  hook_id
})

Delete a hook

Parameters

namerequireddescription
orgyes
hook_idyes
octokit.orgs.deleteHook({
  org,
  hook_id
})

Members list

List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned.

Parameters

namerequireddescription
orgyes
filternoFilter members returned in the list. Can be one of: \* `2fa_disabled` - Members without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled. Available for organization owners. \* `all` - All members the authenticated user can see.
rolenoFilter members returned by their role. Can be one of: \* `all` - All members of the organization, regardless of role. \* `admin` - Organization owners. \* `member` - Non-owner organization members.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listMembers({
  org
})

Check membership

Check if a user is, publicly or privately, a member of the organization.

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.checkMembership({
  org,
  username
})

Remove a member

Removing a user from this list will remove them from all teams and they will no longer have any access to the organization's repositories.

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.removeMember({
  org,
  username
})

Public members list

Members of an organization can choose to have their membership publicized or not.

Parameters

namerequireddescription
orgyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listPublicMembers({
  org
})

Check public membership

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.checkPublicMembership({
  org,
  username
})

Publicize a user's membership

The user can publicize their own membership. (A user cannot publicize the membership for another user.)

Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.publicizeMembership({
  org,
  username
})

Conceal a user's membership

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.concealMembership({
  org,
  username
})

Get organization membership

In order to get a user's membership with an organization, the authenticated user must be an organization member.

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.getMembership({
  org,
  username
})

Add or update organization membership

Only authenticated organization owners can add a member to the organization or update the member's role.

  • If the authenticated user is adding a member to the organization, the invited user will receive an email inviting them to the organization. The user's membership status will be pending until they accept the invitation.

  • Authenticated users can update a user's membership by passing the role parameter. If the authenticated user changes a member's role to admin, the affected user will receive an email notifying them that they've been made an organization owner. If the authenticated user changes an owner's role to member, no email will be sent.

Rate limits

To prevent abuse, the authenticated user is limited to 50 organization invitations per 24 hour period. If the organization is more than one month old or on a paid plan, the limit is 500 invitations per 24 hour period.

Parameters

namerequireddescription
orgyes
usernameyes
rolenoThe role to give the user in the organization. Can be one of: \* `admin` - The user will become an owner of the organization. \* `member` - The user will become a non-owner member of the organization.
octokit.orgs.addOrUpdateMembership({
  org,
  username
})

Remove organization membership

In order to remove a user's membership with an organization, the authenticated user must be an organization owner.

If the specified user is an active member of the organization, this will remove them from the organization. If the specified user has been invited to the organization, this will cancel their invitation. The specified user will receive an email notification in both cases.

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.removeMembership({
  org,
  username
})

List organization invitation teams

List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner.

Parameters

namerequireddescription
orgyes
invitation_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listInvitationTeams({
  org,
  invitation_id
})

List pending organization invitations

The return hash contains a role field which refers to the Organization Invitation role and will be one of the following values: direct_member, admin, billing_manager, hiring_manager, or reinstate. If the invitee is not a GitHub member, the login field in the return hash will be null.

Parameters

namerequireddescription
orgyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listPendingInvitations({
  org
})

Create organization invitation

Invite people to an organization by using their GitHub user ID or their email address. In order to create invitations in an organization, the authenticated user must be an organization owner.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
orgyes
invitee_idno**Required unless you provide `email`**. GitHub user ID for the person you are inviting.
emailno**Required unless you provide `invitee_id`**. Email address of the person you are inviting, which can be an existing GitHub user.
rolenoSpecify role for new member. Can be one of: \* `admin` - Organization owners with full administrative rights to the organization and complete access to all repositories and teams. \* `direct_member` - Non-owner organization members with ability to see other members and join teams by invitation. \* `billing_manager` - Non-owner organization members with ability to manage the billing settings of your organization.
team_idsnoSpecify IDs for the teams you want to invite new members to.
octokit.orgs.createInvitation({
  org
})

List your organization memberships

Parameters

namerequireddescription
statenoIndicates the state of the memberships to return. Can be either `active` or `pending`. If not specified, the API returns both active and pending memberships.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listMemberships()

Get your organization membership

Parameters

namerequireddescription
orgyes
octokit.orgs.getMembershipForAuthenticatedUser({
  org
})

Edit your organization membership

Parameters

namerequireddescription
orgyes
stateyesThe state that the membership should be in. Only `"active"` will be accepted.
octokit.orgs.updateMembership({
  org,
  state
})

List outside collaborators

List all users who are outside collaborators of an organization.

Parameters

namerequireddescription
orgyes
filternoFilter the list of outside collaborators. Can be one of: \* `2fa_disabled`: Outside collaborators without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled. \* `all`: All outside collaborators.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.orgs.listOutsideCollaborators({
  org
})

Remove outside collaborator

Removing a user from this list will remove them from all the organization's repositories.

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.removeOutsideCollaborator({
  org,
  username
})

Convert member to outside collaborator

When an organization member is converted to an outside collaborator, they'll only have access to the repositories that their current team membership allows. The user will no longer be a member of the organization. For more information, see "Converting an organization member to an outside collaborator".

Parameters

namerequireddescription
orgyes
usernameyes
octokit.orgs.convertMemberToOutsideCollaborator({
  org,
  username
})

projects

List repository projects

Lists the projects in a repository. Returns a 404 Not Found status if projects are disabled in the repository. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

Parameters

namerequireddescription
owneryes
repoyes
statenoIndicates the state of the projects to return. Can be either `open`, `closed`, or `all`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.listForRepo({
  owner,
  repo
})

List organization projects

Lists the projects in an organization. Returns a 404 Not Found status if projects are disabled in the organization. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

s

Parameters

namerequireddescription
orgyes
statenoIndicates the state of the projects to return. Can be either `open`, `closed`, or `all`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.listForOrg({
  org
})

List user projects

Parameters

namerequireddescription
usernameyes
statenoIndicates the state of the projects to return. Can be either `open`, `closed`, or `all`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.listForUser({
  username
})

Get a project

Gets a project by its id. Returns a 404 Not Found status if projects are disabled. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

Parameters

namerequireddescription
project_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.get({
  project_id
})

Create a repository project

Creates a repository project board. Returns a 404 Not Found status if projects are disabled in the repository. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

Parameters

namerequireddescription
owneryes
repoyes
nameyesThe name of the project.
bodynoThe description of the project.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.createForRepo({
  owner,
  repo,
  name
})

Create an organization project

Creates an organization project board. Returns a 404 Not Found status if projects are disabled in the organization. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

Parameters

namerequireddescription
orgyes
nameyesThe name of the project.
bodynoThe description of the project.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.createForOrg({
  org,
  name
})

Create a user project

Parameters

namerequireddescription
nameyesThe name of the project.
bodynoThe description of the project.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.createForAuthenticatedUser({
  name
})

Update a project

Updates a project board's information. Returns a 404 Not Found status if projects are disabled. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

Parameters

namerequireddescription
project_idyes
namenoThe name of the project.
bodynoThe description of the project.
statenoState of the project. Either `open` or `closed`.
organization_permissionnoThe permission level that determines whether all members of the project's organization can see and/or make changes to the project. Setting `organization_permission` is only available for organization projects. If an organization member belongs to a team with a higher level of access or is a collaborator with a higher level of access, their permission level is not lowered by `organization_permission`. For information on changing access for a team or collaborator, see [Add or update team project](https://developer.github.com/v3/teams/#add-or-update-team-project) or [Add user as a collaborator](https://developer.github.com/v3/projects/collaborators/#add-user-as-a-collaborator). **Note:** Updating a project's `organization_permission` requires `admin` access to the project. Can be one of: \* `read` - Organization members can read, but not write to or administer this project. \* `write` - Organization members can read and write, but not administer this project. \* `admin` - Organization members can read, write and administer this project. \* `none` - Organization members can only see this project if it is public.
privatenoSets the visibility of a project board. Setting `private` is only available for organization and user projects. **Note:** Updating a project's visibility requires `admin` access to the project. Can be one of: \* `false` - Anyone can see the project. \* `true` - Only the user can view a project board created on a user account. Organization members with the appropriate `organization_permission` can see project boards in an organization account.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.update({
  project_id
})

Delete a project

Deletes a project board. Returns a 404 Not Found status if projects are disabled.

Parameters

namerequireddescription
project_idyes
octokit.projects.delete({
  project_id
})

List project cards

Parameters

namerequireddescription
column_idyes
archived_statenoFilters the project cards that are returned by the card's state. Can be one of `all`,`archived`, or `not_archived`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.listCards({
  column_id
})

Get a project card

Parameters

namerequireddescription
card_idyes
octokit.projects.getCard({
  card_id
})

Create a project card

Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the pull_request key.

Be aware that the id of a pull request returned from "Issues" endpoints will be an issue id. To find out the pull request id, use the "List pull requests" endpoint.

Parameters

namerequireddescription
column_idyes
notenoThe card's note content. Only valid for cards without another type of content, so you must omit when specifying `content_id` and `content_type`.
content_idnoThe issue or pull request id you want to associate with this card. You can use the [List issues for a repository](https://developer.github.com/v3/issues/#list-issues-for-a-repository) and [List pull requests](https://developer.github.com/v3/pulls/#list-pull-requests) endpoints to find this id. **Note:** Depending on whether you use the issue id or pull request id, you will need to specify `Issue` or `PullRequest` as the `content_type`.
content_typeno**Required if you provide `content_id`**. The type of content you want to associate with this card. Use `Issue` when `content_id` is an issue id and use `PullRequest` when `content_id` is a pull request id.
octokit.projects.createCard({
  column_id
})

Update a project card

Parameters

namerequireddescription
card_idyes
notenoThe card's note content. Only valid for cards without another type of content, so this cannot be specified if the card already has a `content_id` and `content_type`.
archivednoUse `true` to archive a project card. Specify `false` if you need to restore a previously archived project card.
octokit.projects.updateCard({
  card_id
})

Delete a project card

Parameters

namerequireddescription
card_idyes
octokit.projects.deleteCard({
  card_id
})

Move a project card

Parameters

namerequireddescription
card_idyes
positionyesCan be one of `top`, `bottom`, or `after:<card_id>`, where `<card_id>` is the `id` value of a card in the same column, or in the new column specified by `column_id`.
column_idnoThe `id` value of a column in the same project.
octokit.projects.moveCard({
  card_id,
  position
})

List collaborators

Lists the collaborators for an organization project. For a project, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. You must be an organization owner or a project admin to list collaborators.

Parameters

namerequireddescription
project_idyes
affiliationnoFilters the collaborators by their affiliation. Can be one of: \* `outside`: Outside collaborators of a project that are not a member of the project's organization. \* `direct`: Collaborators with permissions to a project, regardless of organization membership status. \* `all`: All collaborators the authenticated user can see.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.listCollaborators({
  project_id
})

Review a user's permission level

Returns the collaborator's permission level for an organization project. Possible values for the permission key: admin, write, read, none. You must be an organization owner or a project admin to review a user's permission level.

Parameters

namerequireddescription
project_idyes
usernameyes
octokit.projects.reviewUserPermissionLevel({
  project_id,
  username
})

Add user as a collaborator

Adds a collaborator to a an organization project and sets their permission level. You must be an organization owner or a project admin to add a collaborator.

Parameters

namerequireddescription
project_idyes
usernameyes
permissionnoThe permission to grant the collaborator. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://developer.github.com/v3/#http-verbs)." Can be one of: \* `read` - can read, but not write to or administer this project. \* `write` - can read and write, but not administer this project. \* `admin` - can read, write and administer this project.
octokit.projects.addCollaborator({
  project_id,
  username
})

Remove user as a collaborator

Removes a collaborator from an organization project. You must be an organization owner or a project admin to remove a collaborator.

Parameters

namerequireddescription
project_idyes
usernameyes
octokit.projects.removeCollaborator({
  project_id,
  username
})

List project columns

Parameters

namerequireddescription
project_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.projects.listColumns({
  project_id
})

Get a project column

Parameters

namerequireddescription
column_idyes
octokit.projects.getColumn({
  column_id
})

Create a project column

Parameters

namerequireddescription
project_idyes
nameyesThe name of the column.
octokit.projects.createColumn({
  project_id,
  name
})

Update a project column

Parameters

namerequireddescription
column_idyes
nameyesThe new name of the column.
octokit.projects.updateColumn({
  column_id,
  name
})

Delete a project column

Parameters

namerequireddescription
column_idyes
octokit.projects.deleteColumn({
  column_id
})

Move a project column

Parameters

namerequireddescription
column_idyes
positionyesCan be one of `first`, `last`, or `after:<column_id>`, where `<column_id>` is the `id` value of a column in the same project.
octokit.projects.moveColumn({
  column_id,
  position
})

pulls

List pull requests

Draft pull requests are available in public repositories with GitHub Free and GitHub Pro, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
statenoEither `open`, `closed`, or `all` to filter by state.
headnoFilter pulls by head user and branch name in the format of `user:ref-name`. Example: `github:new-script-format`.
basenoFilter pulls by base branch name. Example: `gh-pages`.
sortnoWhat to sort results by. Can be either `created`, `updated`, `popularity` (comment count) or `long-running` (age, filtering by pulls updated in the last month).
directionnoThe direction of the sort. Can be either `asc` or `desc`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.pulls.list({
  owner,
  repo
})

Get a single pull request

Draft pull requests are available in public repositories with GitHub Free and GitHub Pro, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Lists details of a pull request by providing its number.

When you get, create, or edit a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the mergeable key. For more information, see "Checking mergeability of pull requests".

The value of the mergeable attribute can be true, false, or null. If the value is null, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-null value for the mergeable attribute in the response. If mergeable is true, then merge_commit_sha will be the SHA of the test merge commit.

The value of the merge_commit_sha attribute changes depending on the state of the pull request. Before merging a pull request, the merge_commit_sha attribute holds the SHA of the test merge commit. After merging a pull request, the merge_commit_sha attribute changes depending on how you merged the pull request:

  • If merged as a merge commit, merge_commit_sha represents the SHA of the merge commit.
  • If merged via a squash, merge_commit_sha represents the SHA of the squashed commit on the base branch.
  • If rebased, merge_commit_sha represents the commit that the base branch was updated to.

Pass the appropriate media type to fetch diff and patch formats.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
numberno
octokit.pulls.get({
  owner,
  repo,
  pull_number
})

Create a pull request

Draft pull requests are available in public repositories with GitHub Free and GitHub Pro, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
titleyesThe title of the pull request.
headyesThe name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace `head` with a user like this: `username:branch`.
baseyesThe name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository.
bodynoThe contents of the pull request.
maintainer_can_modifynoIndicates whether [maintainers can modify](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) the pull request.
draftnoIndicates whether the pull request is a draft. See "[Draft Pull Requests](https://help.github.com/en/articles/about-pull-requests#draft-pull-requests)" in the GitHub Help documentation to learn more.
octokit.pulls.create({
  owner,
  repo,
  title,
  head,
  base
})

Create a Pull Request from an Issue

Draft pull requests are available in public repositories with GitHub Free and GitHub Pro, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
issueyesThe issue number in this repository to turn into a Pull Request.
headyesThe name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace `head` with a user like this: `username:branch`.
baseyesThe name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository.
maintainer_can_modifynoIndicates whether [maintainers can modify](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) the pull request.
draftnoIndicates whether the pull request is a draft. See "[Draft Pull Requests](https://help.github.com/en/articles/about-pull-requests#draft-pull-requests)" in the GitHub Help documentation to learn more.
octokit.pulls.createFromIssue({
  owner,
  repo,
  issue,
  head,
  base
})

Update a pull request

Draft pull requests are available in public repositories with GitHub Free and GitHub Pro, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
titlenoThe title of the pull request.
bodynoThe contents of the pull request.
statenoState of this Pull Request. Either `open` or `closed`.
basenoThe name of the branch you want your changes pulled into. This should be an existing branch on the current repository. You cannot update the base branch on a pull request to point to another repository.
maintainer_can_modifynoIndicates whether [maintainers can modify](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) the pull request.
numberno
octokit.pulls.update({
  owner,
  repo,
  pull_number
})

List commits on a pull request

Lists a maximum of 250 commits for a pull request. To receive a complete commit list for pull requests with more than 250 commits, use the Commit List API.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.pulls.listCommits({
  owner,
  repo,
  pull_number
})

List pull requests files

Note: The response includes a maximum of 300 files.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.pulls.listFiles({
  owner,
  repo,
  pull_number
})

Get if a pull request has been merged

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
numberno
octokit.pulls.checkIfMerged({
  owner,
  repo,
  pull_number
})

Merge a pull request (Merge Button)

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
commit_titlenoTitle for the automatic commit message.
commit_messagenoExtra detail to append to automatic commit message.
shanoSHA that pull request head must match to allow merge.
merge_methodnoMerge method to use. Possible values are `merge`, `squash` or `rebase`. Default is `merge`.
numberno
octokit.pulls.merge({
  owner,
  repo,
  pull_number
})

List comments on a pull request

By default, review comments are ordered by ascending ID.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
sortnoCan be either `created` or `updated` comments.
directionnoCan be either `asc` or `desc`. Ignored without `sort` parameter.
sincenoThis is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Only returns comments `updated` at or after this time.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.pulls.listComments({
  owner,
  repo,
  pull_number
})

List comments in a repository

By default, review comments are ordered by ascending ID.

Parameters

namerequireddescription
owneryes
repoyes
sortnoCan be either `created` or `updated` comments.
directionnoCan be either `asc` or `desc`. Ignored without `sort` parameter.
sincenoThis is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Only returns comments `updated` at or after this time.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.pulls.listCommentsForRepo({
  owner,
  repo
})

Get a single comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
octokit.pulls.getComment({
  owner,
  repo,
  comment_id
})

Create a comment

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Note: To comment on a specific line in a file, you need to first determine the position of that line in the diff. The GitHub REST API v3 offers the application/vnd.github.v3.diff media type. To see a pull request diff, add this media type to the Accept header of a call to the single pull request endpoint.

The position value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
bodyyesThe text of the comment.
commit_idyesThe SHA of the commit needing a comment. Not using the latest commit SHA may render your comment outdated if a subsequent commit modifies the line you specify as the `position`.
pathyesThe relative path to the file that necessitates a comment.
positionyesThe position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note below.
numberno
octokit.pulls.createComment({
  owner,
  repo,
  pull_number,
  body,
  commit_id,
  path,
  position
})

Create a comment reply

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Note: To comment on a specific line in a file, you need to first determine the position of that line in the diff. The GitHub REST API v3 offers the application/vnd.github.v3.diff media type. To see a pull request diff, add this media type to the Accept header of a call to the single pull request endpoint.

The position value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
bodyyesThe text of the comment.
in_reply_toyesThe comment ID to reply to. **Note**: This must be the ID of a _top-level comment_, not a reply to that comment. Replies to replies are not supported.
numberno
octokit.pulls.createCommentReply({
  owner,
  repo,
  pull_number,
  body,
  in_reply_to
})

Edit a comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
bodyyesThe text of the comment.
octokit.pulls.updateComment({
  owner,
  repo,
  comment_id,
  body
})

Delete a comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
octokit.pulls.deleteComment({
  owner,
  repo,
  comment_id
})

List review requests

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.pulls.listReviewRequests({
  owner,
  repo,
  pull_number
})

Create a review request

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
reviewersnoAn array of user `login`s that will be requested.
team_reviewersnoAn array of team `slug`s that will be requested.
numberno
octokit.pulls.createReviewRequest({
  owner,
  repo,
  pull_number
})

Delete a review request

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
reviewersnoAn array of user `login`s that will be removed.
team_reviewersnoAn array of team `slug`s that will be removed.
numberno
octokit.pulls.deleteReviewRequest({
  owner,
  repo,
  pull_number
})

List reviews on a pull request

The list of reviews returns in chronological order.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.pulls.listReviews({
  owner,
  repo,
  pull_number
})

Get a single review

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes
numberno
octokit.pulls.getReview({
  owner,
  repo,
  pull_number,
  review_id
})

Delete a pending review

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes
numberno
octokit.pulls.deletePendingReview({
  owner,
  repo,
  pull_number,
  review_id
})

Get comments for a single review

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.pulls.getCommentsForReview({
  owner,
  repo,
  pull_number,
  review_id
})

Create a pull request review

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Note: To comment on a specific line in a file, you need to first determine the position of that line in the diff. The GitHub REST API v3 offers the application/vnd.github.v3.diff media type. To see a pull request diff, add this media type to the Accept header of a call to the single pull request endpoint.

The position value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
commit_idnoThe SHA of the commit that needs a review. Not using the latest commit SHA may render your review comment outdated if a subsequent commit modifies the line you specify as the `position`. Defaults to the most recent commit in the pull request when you do not specify a value.
bodyno**Required** when using `REQUEST_CHANGES` or `COMMENT` for the `event` parameter. The body text of the pull request review.
eventnoThe review action you want to perform. The review actions include: `APPROVE`, `REQUEST_CHANGES`, or `COMMENT`. By leaving this blank, you set the review action state to `PENDING`, which means you will need to [submit the pull request review](https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review) when you are ready.
commentsnoUse the following table to specify the location, destination, and contents of the draft review comment.
comments[].pathyesThe relative path to the file that necessitates a review comment.
comments[].positionyesThe position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note below.
comments[].bodyyesText of the review comment.
numberno
octokit.pulls.createReview({
  owner,
  repo,
  pull_number
})

Update a pull request review

Update the review summary comment with new text.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes
bodyyesThe body text of the pull request review.
numberno
octokit.pulls.updateReview({
  owner,
  repo,
  pull_number,
  review_id,
  body
})

Submit a pull request review

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes
bodynoThe body text of the pull request review
eventyesThe review action you want to perform. The review actions include: `APPROVE`, `REQUEST_CHANGES`, or `COMMENT`. When you leave this blank, the API returns _HTTP 422 (Unrecognizable entity)_ and sets the review action state to `PENDING`, which means you will need to re-submit the pull request review using a review action.
numberno
octokit.pulls.submitReview({
  owner,
  repo,
  pull_number,
  review_id,
  event
})

Dismiss a pull request review

Note: To dismiss a pull request review on a protected branch, you must be a repository administrator or be included in the list of people or teams who can dismiss pull request reviews.

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes
messageyesThe message for the pull request review dismissal
numberno
octokit.pulls.dismissReview({
  owner,
  repo,
  pull_number,
  review_id,
  message
})

rateLimit

Get your current rate limit status

Note: Accessing this endpoint does not count against your REST API rate limit.

Understanding your rate limit status

The Search API has a custom rate limit, separate from the rate limit governing the rest of the REST API. The GraphQL API also has a custom rate limit that is separate from and calculated differently than rate limits in the REST API.

For these reasons, the Rate Limit API response categorizes your rate limit. Under resources, you'll see four objects:

  • The core object provides your rate limit status for all non-search-related resources in the REST API.
  • The search object provides your rate limit status for the Search API.
  • The graphql object provides your rate limit status for the GraphQL API.
  • The integration_manifest object provides your rate limit status for the GitHub App Manifest code conversion endpoint.

For more information on the headers and values in the rate limit response, see "Rate limiting."

The rate object (shown at the bottom of the response above) is deprecated.

If you're writing new API client code or updating existing code, you should use the core object instead of the rate object. The core object contains the same information that is present in the rate object.

Parameters

namerequireddescription
octokit.rateLimit.get()

reactions

List reactions for a commit comment

List the reactions to a commit comment.

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
contentnoReturns a single [reaction type](https://developer.github.com/v3/reactions/#reaction-types). Omit this parameter to list all reactions to a commit comment.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.reactions.listForCommitComment({
  owner,
  repo,
  comment_id
})

Create reaction for a commit comment

Create a reaction to a commit comment. A response with a Status: 200 OK means that you already added the reaction type to this commit comment.

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
contentyesThe [reaction type](https://developer.github.com/v3/reactions/#reaction-types) to add to the commit comment.
octokit.reactions.createForCommitComment({
  owner,
  repo,
  comment_id,
  content
})

List reactions for an issue

List the reactions to an issue.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
contentnoReturns a single [reaction type](https://developer.github.com/v3/reactions/#reaction-types). Omit this parameter to list all reactions to an issue.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
numberno
octokit.reactions.listForIssue({
  owner,
  repo,
  issue_number
})

Create reaction for an issue

Create a reaction to an issue. A response with a Status: 200 OK means that you already added the reaction type to this issue.

Parameters

namerequireddescription
owneryes
repoyes
issue_numberyes
contentyesThe [reaction type](https://developer.github.com/v3/reactions/#reaction-types) to add to the issue.
numberno
octokit.reactions.createForIssue({
  owner,
  repo,
  issue_number,
  content
})

List reactions for an issue comment

List the reactions to an issue comment.

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
contentnoReturns a single [reaction type](https://developer.github.com/v3/reactions/#reaction-types). Omit this parameter to list all reactions to an issue comment.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.reactions.listForIssueComment({
  owner,
  repo,
  comment_id
})

Create reaction for an issue comment

Create a reaction to an issue comment. A response with a Status: 200 OK means that you already added the reaction type to this issue comment.

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
contentyesThe [reaction type](https://developer.github.com/v3/reactions/#reaction-types) to add to the issue comment.
octokit.reactions.createForIssueComment({
  owner,
  repo,
  comment_id,
  content
})

List reactions for a pull request review comment

List the reactions to a pull request review comment.

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
contentnoReturns a single [reaction type](https://developer.github.com/v3/reactions/#reaction-types). Omit this parameter to list all reactions to a pull request review comment.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.reactions.listForPullRequestReviewComment({
  owner,
  repo,
  comment_id
})

Create reaction for a pull request review comment

Create a reaction to a pull request review comment. A response with a Status: 200 OK means that you already added the reaction type to this pull request review comment.

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
contentyesThe [reaction type](https://developer.github.com/v3/reactions/#reaction-types) to add to the pull request review comment.
octokit.reactions.createForPullRequestReviewComment({
  owner,
  repo,
  comment_id,
  content
})

List reactions for a team discussion

List the reactions to a team discussion. OAuth access tokens require the read:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
contentnoReturns a single [reaction type](https://developer.github.com/v3/reactions/#reaction-types). Omit this parameter to list all reactions to a team discussion.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.reactions.listForTeamDiscussion({
  team_id,
  discussion_number
})

Create reaction for a team discussion

Create a reaction to a team discussion. OAuth access tokens require the write:discussion scope. A response with a Status: 200 OK means that you already added the reaction type to this team discussion.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
contentyesThe [reaction type](https://developer.github.com/v3/reactions/#reaction-types) to add to the team discussion.
octokit.reactions.createForTeamDiscussion({
  team_id,
  discussion_number,
  content
})

List reactions for a team discussion comment

List the reactions to a team discussion comment. OAuth access tokens require the read:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
comment_numberyes
contentnoReturns a single [reaction type](https://developer.github.com/v3/reactions/#reaction-types). Omit this parameter to list all reactions to a team discussion comment.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.reactions.listForTeamDiscussionComment({
  team_id,
  discussion_number,
  comment_number
})

Create reaction for a team discussion comment

Create a reaction to a team discussion comment. OAuth access tokens require the write:discussion scope. A response with a Status: 200 OK means that you already added the reaction type to this team discussion comment.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
comment_numberyes
contentyesThe [reaction type](https://developer.github.com/v3/reactions/#reaction-types) to add to the team discussion comment.
octokit.reactions.createForTeamDiscussionComment({
  team_id,
  discussion_number,
  comment_number,
  content
})

Delete a reaction

OAuth access tokens require the write:discussion scope, when deleting a team discussion or team discussion comment.

Parameters

namerequireddescription
reaction_idyes
octokit.reactions.delete({
  reaction_id
})

repos

List your repositories

List repositories that the authenticated user has explicit permission (:read, :write, or :admin) to access.

The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.

Parameters

namerequireddescription
visibilitynoCan be one of `all`, `public`, or `private`.
affiliationnoComma-separated list of values. Can include: \* `owner`: Repositories that are owned by the authenticated user. \* `collaborator`: Repositories that the user has been added to as a collaborator. \* `organization_member`: Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on.
typenoCan be one of `all`, `owner`, `public`, `private`, `member`. Default: `all` Will cause a `422` error if used in the same request as **visibility** or **affiliation**. Will cause a `422` error if used in the same request as **visibility** or **affiliation**.
sortnoCan be one of `created`, `updated`, `pushed`, `full_name`.
directionnoCan be one of `asc` or `desc`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.list()

List user repositories

List public repositories for the specified user.

Parameters

namerequireddescription
usernameyes
typenoCan be one of `all`, `owner`, `member`.
sortnoCan be one of `created`, `updated`, `pushed`, `full_name`.
directionnoCan be one of `asc` or `desc`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listForUser({
  username
})

List organization repositories

List repositories for the specified org.

Parameters

namerequireddescription
orgyes
typenoCan be one of `all`, `public`, `private`, `forks`, `sources`, `member`.
sortnoCan be one of `created`, `updated`, `pushed`, `full_name`.
directionnoCan be one of `asc` or `desc`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listForOrg({
  org
})

List all public repositories

This provides a dump of every public repository, in the order that they were created.

Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of repositories.

Parameters

namerequireddescription
sincenoThe integer ID of the last Repository that you've seen.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listPublic()

Create a new repository for the authenticated user

Note: There are two endpoints for creating a repository: one to create a repository on a user account, and one to create a repository in an organization. The organization endpoint is fully enabled for GitHub Apps, whereas the user endpoint is enabled only for user-to-server requests.

OAuth scope requirements

When using OAuth, authorizations must include:

  • public_repo scope or repo scope to create a public repository
  • repo scope to create a private repository

Parameters

namerequireddescription
nameyesThe name of the repository.
descriptionnoA short description of the repository.
homepagenoA URL with more information about the repository.
privatenoEither `true` to create a private repository or `false` to create a public one. Creating private repositories requires a paid GitHub account.
has_issuesnoEither `true` to enable issues for this repository or `false` to disable them.
has_projectsnoEither `true` to enable projects for this repository or `false` to disable them. **Note:** If you're creating a repository in an organization that has disabled repository projects, the default is `false`, and if you pass `true`, the API returns an error.
has_wikinoEither `true` to enable the wiki for this repository or `false` to disable it.
team_idnoThe id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization.
auto_initnoPass `true` to create an initial commit with empty README.
gitignore_templatenoDesired language or platform [.gitignore template](https://github.com/github/gitignore) to apply. Use the name of the template without the extension. For example, "Haskell".
license_templatenoChoose an [open source license template](https://choosealicense.com/) that best suits your needs, and then use the [license keyword](https://help.github.com/articles/licensing-a-repository/#searching-github-by-license-type) as the `license_template` string. For example, "mit" or "mpl-2.0".
allow_squash_mergenoEither `true` to allow squash-merging pull requests, or `false` to prevent squash-merging.
allow_merge_commitnoEither `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
allow_rebase_mergenoEither `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.
octokit.repos.createForAuthenticatedUser({
  name
})

Create a new repository in this organization

Note: There are two endpoints for creating a repository: one to create a repository on a user account, and one to create a repository in an organization. The organization endpoint is fully enabled for GitHub Apps, whereas the user endpoint is enabled only for user-to-server requests.

OAuth scope requirements

When using OAuth, authorizations must include:

  • public_repo scope or repo scope to create a public repository
  • repo scope to create a private repository

Parameters

namerequireddescription
orgyes
nameyesThe name of the repository.
descriptionnoA short description of the repository.
homepagenoA URL with more information about the repository.
privatenoEither `true` to create a private repository or `false` to create a public one. Creating private repositories requires a paid GitHub account.
has_issuesnoEither `true` to enable issues for this repository or `false` to disable them.
has_projectsnoEither `true` to enable projects for this repository or `false` to disable them. **Note:** If you're creating a repository in an organization that has disabled repository projects, the default is `false`, and if you pass `true`, the API returns an error.
has_wikinoEither `true` to enable the wiki for this repository or `false` to disable it.
team_idnoThe id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization.
auto_initnoPass `true` to create an initial commit with empty README.
gitignore_templatenoDesired language or platform [.gitignore template](https://github.com/github/gitignore) to apply. Use the name of the template without the extension. For example, "Haskell".
license_templatenoChoose an [open source license template](https://choosealicense.com/) that best suits your needs, and then use the [license keyword](https://help.github.com/articles/licensing-a-repository/#searching-github-by-license-type) as the `license_template` string. For example, "mit" or "mpl-2.0".
allow_squash_mergenoEither `true` to allow squash-merging pull requests, or `false` to prevent squash-merging.
allow_merge_commitnoEither `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
allow_rebase_mergenoEither `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.
octokit.repos.createInOrg({
  org,
  name
})

Get

The parent and source objects are present when the repository is a fork. parent is the repository this repository was forked from, source is the ultimate source for the network.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.get({
  owner,
  repo
})

Edit

Note: To edit a repository's topics, use the topics endpoint.

Parameters

namerequireddescription
owneryes
repoyes
nameyesThe name of the repository.
descriptionnoA short description of the repository.
homepagenoA URL with more information about the repository.
privatenoEither `true` to make the repository private or `false` to make it public. Creating private repositories requires a paid GitHub account. Default: `false`. **Note**: You will get a `422` error if the organization restricts [changing repository visibility](https://help.github.com/articles/repository-permission-levels-for-an-organization#changing-the-visibility-of-repositories) to organization owners and a non-owner tries to change the value of private. **Note**: You will get a `422` error if the organization restricts [changing repository visibility](https://help.github.com/articles/repository-permission-levels-for-an-organization#changing-the-visibility-of-repositories) to organization owners and a non-owner tries to change the value of private.
has_issuesnoEither `true` to enable issues for this repository or `false` to disable them.
has_projectsnoEither `true` to enable projects for this repository or `false` to disable them. **Note:** If you're creating a repository in an organization that has disabled repository projects, the default is `false`, and if you pass `true`, the API returns an error.
has_wikinoEither `true` to enable the wiki for this repository or `false` to disable it.
default_branchnoUpdates the default branch for this repository.
allow_squash_mergenoEither `true` to allow squash-merging pull requests, or `false` to prevent squash-merging.
allow_merge_commitnoEither `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
allow_rebase_mergenoEither `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.
archivedno`true` to archive this repository. **Note**: You cannot unarchive repositories through the API.
octokit.repos.update({
  owner,
  repo,
  name
})

List all topics for a repository

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.listTopics({
  owner,
  repo
})

Replace all topics for a repository

Parameters

namerequireddescription
owneryes
repoyes
namesyesAn array of topics to add to the repository. Pass one or more topics to _replace_ the set of existing topics. Send an empty array (`[]`) to clear all topics from the repository. **Note:** Topic `names` cannot contain uppercase letters.
octokit.repos.replaceTopics({
  owner,
  repo,
  names
})

List contributors

Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API v3 caches contributor data to improve performance.

GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.

Parameters

namerequireddescription
owneryes
repoyes
anonnoSet to `1` or `true` to include anonymous contributors in results.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listContributors({
  owner,
  repo
})

List languages

Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.listLanguages({
  owner,
  repo
})

List teams

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listTeams({
  owner,
  repo
})

List tags

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listTags({
  owner,
  repo
})

Delete a repository

Deleting a repository requires admin access. If OAuth is used, the delete_repo scope is required.

If an organization owner has configured the organization to prevent members from deleting organization-owned repositories, a member will get this response:

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.delete({
  owner,
  repo
})

Transfer a repository

A transfer request will need to be accepted by the new owner when transferring a personal repository to another user. The response will contain the original owner, and the transfer will continue asynchronously. For more details on the requirements to transfer personal and organization-owned repositories, see about repository transfers.

Parameters

namerequireddescription
owneryes
repoyes
new_ownerno**Required:** The username or organization name the repository will be transferred to.
team_idsnoID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories.
octokit.repos.transfer({
  owner,
  repo
})

List branches

Parameters

namerequireddescription
owneryes
repoyes
protectednoSetting to `true` returns only protected branches. When set to `false`, only unprotected branches are returned. Omitting this parameter returns all branches.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listBranches({
  owner,
  repo
})

Get branch

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.getBranch({
  owner,
  repo,
  branch
})

Get branch protection

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.getBranchProtection({
  owner,
  repo,
  branch
})

Update branch protection

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Protecting a branch requires admin or owner permissions to the repository.

Note: Passing new arrays of users and teams replaces their previous values.

Note: The list of users and teams in total is limited to 100 items.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
required_status_checksyesRequire status checks to pass before merging. Set to `null` to disable.
required_status_checks.strictyesRequire branches to be up to date before merging.
required_status_checks.contextsyesThe list of status checks to require in order to merge into this branch
enforce_adminsyesEnforce all configured restrictions for administrators. Set to `true` to enforce required status checks for repository administrators. Set to `null` to disable.
required_pull_request_reviewsyesRequire at least one approving review on a pull request, before merging. Set to `null` to disable.
required_pull_request_reviews.dismissal_restrictionsnoSpecify which users and teams can dismiss pull request reviews. Pass an empty `dismissal_restrictions` object to disable. User and team `dismissal_restrictions` are only available for organization-owned repositories. Omit this parameter for personal repositories.
required_pull_request_reviews.dismissal_restrictions.usersnoThe list of user `login`s with dismissal access
required_pull_request_reviews.dismissal_restrictions.teamsnoThe list of team `slug`s with dismissal access
required_pull_request_reviews.dismiss_stale_reviewsnoSet to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit.
required_pull_request_reviews.require_code_owner_reviewsnoBlocks merging pull requests until [code owners](https://help.github.com/articles/about-code-owners/) review them.
required_pull_request_reviews.required_approving_review_countnoSpecify the number of reviewers required to approve pull requests. Use a number between 1 and 6.
restrictionsyesRestrict who can push to this branch. Team and user `restrictions` are only available for organization-owned repositories. Set to `null` to disable.
restrictions.usersnoThe list of user `login`s with push access
restrictions.teamsnoThe list of team `slug`s with push access
octokit.repos.updateBranchProtection({
  owner,
  repo,
  branch,
  required_status_checks,
  enforce_admins,
  required_pull_request_reviews,
  restrictions
})

Remove branch protection

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.removeBranchProtection({
  owner,
  repo,
  branch
})

Get required status checks of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.getProtectedBranchRequiredStatusChecks({
  owner,
  repo,
  branch
})

Update required status checks of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
strictnoRequire branches to be up to date before merging.
contextsnoThe list of status checks to require in order to merge into this branch
octokit.repos.updateProtectedBranchRequiredStatusChecks({
  owner,
  repo,
  branch
})

Remove required status checks of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.removeProtectedBranchRequiredStatusChecks({
  owner,
  repo,
  branch
})

List required status checks contexts of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.listProtectedBranchRequiredStatusChecksContexts({
  owner,
  repo,
  branch
})

Replace required status checks contexts of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
contextsyes
octokit.repos.replaceProtectedBranchRequiredStatusChecksContexts({
  owner,
  repo,
  branch,
  contexts
})

Add required status checks contexts of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
contextsyes
octokit.repos.addProtectedBranchRequiredStatusChecksContexts({
  owner,
  repo,
  branch,
  contexts
})

Remove required status checks contexts of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
contextsyes
octokit.repos.removeProtectedBranchRequiredStatusChecksContexts({
  owner,
  repo,
  branch,
  contexts
})

Get pull request review enforcement of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.getProtectedBranchPullRequestReviewEnforcement({
  owner,
  repo,
  branch
})

Update pull request review enforcement of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

Note: Passing new arrays of users and teams replaces their previous values.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
dismissal_restrictionsnoSpecify which users and teams can dismiss pull request reviews. Pass an empty `dismissal_restrictions` object to disable. User and team `dismissal_restrictions` are only available for organization-owned repositories. Omit this parameter for personal repositories.
dismissal_restrictions.usersnoThe list of user `login`s with dismissal access
dismissal_restrictions.teamsnoThe list of team `slug`s with dismissal access
dismiss_stale_reviewsnoSet to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit.
require_code_owner_reviewsnoBlocks merging pull requests until [code owners](https://help.github.com/articles/about-code-owners/) have reviewed.
required_approving_review_countnoSpecifies the number of reviewers required to approve pull requests. Use a number between 1 and 6.
octokit.repos.updateProtectedBranchPullRequestReviewEnforcement({
  owner,
  repo,
  branch
})

Remove pull request review enforcement of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.removeProtectedBranchPullRequestReviewEnforcement({
  owner,
  repo,
  branch
})

Get required signatures of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to check whether a branch requires signed commits. An enabled status of true indicates you must sign commits on this branch. For more information, see Signing commits with GPG in GitHub Help.

Note: You must enable branch protection to require signed commits.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.getProtectedBranchRequiredSignatures({
  owner,
  repo,
  branch
})

Add required signatures of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to require signed commits on a branch. You must enable branch protection to require signed commits.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.addProtectedBranchRequiredSignatures({
  owner,
  repo,
  branch
})

Remove required signatures of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to disable required signed commits on a branch. You must enable branch protection to require signed commits.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.removeProtectedBranchRequiredSignatures({
  owner,
  repo,
  branch
})

Get admin enforcement of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.getProtectedBranchAdminEnforcement({
  owner,
  repo,
  branch
})

Add admin enforcement of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Adding admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.addProtectedBranchAdminEnforcement({
  owner,
  repo,
  branch
})

Remove admin enforcement of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Removing admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.removeProtectedBranchAdminEnforcement({
  owner,
  repo,
  branch
})

Get restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Note: Teams and users restrictions are only available for organization-owned repositories.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.getProtectedBranchRestrictions({
  owner,
  repo,
  branch
})

Remove restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Disables the ability to restrict who can push to this branch.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.removeProtectedBranchRestrictions({
  owner,
  repo,
  branch
})

List team restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Lists the teams who have push access to this branch. If you pass the hellcat-preview media type, the list includes child teams.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listProtectedBranchTeamRestrictions({
  owner,
  repo,
  branch
})

Replace team restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Replaces the list of teams that have push access to this branch. This removes all teams that previously had push access and grants push access to the new list of teams. If you pass the hellcat-preview media type, you can include child teams.

Type Description
array The teams that can have push access. Use the team's slug. Note: The list of users and teams in total is limited to 100 items.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
teamsyes
octokit.repos.replaceProtectedBranchTeamRestrictions({
  owner,
  repo,
  branch,
  teams
})

Add team restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Grants the specified teams push access for this branch. If you pass the hellcat-preview media type, you can also give push access to child teams.

Type Description
array The teams that can have push access. Use the team's slug. Note: The list of users and teams in total is limited to 100 items.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
teamsyes
octokit.repos.addProtectedBranchTeamRestrictions({
  owner,
  repo,
  branch,
  teams
})

Remove team restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Removes the ability of a team to push to this branch. If you pass the hellcat-preview media type, you can include child teams.

Type Description
array Teams that should no longer have push access. Use the team's slug. Note: The list of users and teams in total is limited to 100 items.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
teamsyes
octokit.repos.removeProtectedBranchTeamRestrictions({
  owner,
  repo,
  branch,
  teams
})

List user restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Lists the people who have push access to this branch.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
octokit.repos.listProtectedBranchUserRestrictions({
  owner,
  repo,
  branch
})

Replace user restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people.

Type Description
array Usernames for people who can have push access. Note: The list of users and teams in total is limited to 100 items.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
usersyes
octokit.repos.replaceProtectedBranchUserRestrictions({
  owner,
  repo,
  branch,
  users
})

Add user restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Grants the specified people push access for this branch.

Type Description
array Usernames for people who can have push access. Note: The list of users and teams in total is limited to 100 items.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
usersyes
octokit.repos.addProtectedBranchUserRestrictions({
  owner,
  repo,
  branch,
  users
})

Remove user restrictions of protected branch

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Removes the ability of a team to push to this branch.

Type Description
array Usernames of the people who should no longer have push access. Note: The list of users and teams in total is limited to 100 items.

Parameters

namerequireddescription
owneryes
repoyes
branchyes
usersyes
octokit.repos.removeProtectedBranchUserRestrictions({
  owner,
  repo,
  branch,
  users
})

List collaborators

For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.

If you pass the hellcat-preview media type, team members will include the members of child teams.

Parameters

namerequireddescription
owneryes
repoyes
affiliationnoFilter collaborators returned by their affiliation. Can be one of: \* `outside`: All outside collaborators of an organization-owned repository. \* `direct`: All collaborators with permissions to an organization-owned repository, regardless of organization membership status. \* `all`: All collaborators the authenticated user can see.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listCollaborators({
  owner,
  repo
})

Check if a user is a collaborator

For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.

If you pass the hellcat-preview media type, team members will include the members of child teams.

Parameters

namerequireddescription
owneryes
repoyes
usernameyes
octokit.repos.checkCollaborator({
  owner,
  repo,
  username
})

Review a user's permission level

Possible values for the permission key: admin, write, read, none.

Parameters

namerequireddescription
owneryes
repoyes
usernameyes
octokit.repos.getCollaboratorPermissionLevel({
  owner,
  repo,
  username
})

Add user as a collaborator

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

The invitee will receive a notification that they have been invited to the repository, which they must accept or decline. They may do this via the notifications page, the email they receive, or by using the repository invitations API endpoints.

Rate limits

To prevent abuse, you are limited to sending 50 invitations to a repository per 24 hour period. Note there is no limit if you are inviting organization members to an organization repository.

Parameters

namerequireddescription
owneryes
repoyes
usernameyes
permissionnoThe permission to grant the collaborator. **Only valid on organization-owned repositories.** Can be one of: \* `pull` - can pull, but not push to or administer this repository. \* `push` - can pull and push, but not administer this repository. \* `admin` - can pull, push and administer this repository.
octokit.repos.addCollaborator({
  owner,
  repo,
  username
})

Remove user as a collaborator

Parameters

namerequireddescription
owneryes
repoyes
usernameyes
octokit.repos.removeCollaborator({
  owner,
  repo,
  username
})

List commit comments for a repository

Commit Comments use these custom media types. You can read more about the use of media types in the API here.

Comments are ordered by ascending ID.

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listCommitComments({
  owner,
  repo
})

List comments for a single commit

Parameters

namerequireddescription
owneryes
repoyes
refyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listCommentsForCommit({
  owner,
  repo,
  ref
})

Create a commit comment

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
shayes
bodyyesThe contents of the comment.
pathnoRelative path of the file to comment on.
positionnoLine index in the diff to comment on.
lineno**Deprecated**. Use **position** parameter instead. Line number in the file to comment on.
octokit.repos.createCommitComment({
  owner,
  repo,
  sha,
  body
})

Get a single commit comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
octokit.repos.getCommitComment({
  owner,
  repo,
  comment_id
})

Update a commit comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
bodyyesThe contents of the comment
octokit.repos.updateCommitComment({
  owner,
  repo,
  comment_id,
  body
})

Delete a commit comment

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes
octokit.repos.deleteCommitComment({
  owner,
  repo,
  comment_id
})

List commits on a repository

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

Value Description
expired_key The key that made the signature is expired.
not_signing_key The "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_error There was an error communicating with the signature verification service.
gpgverify_unavailable The signature verification service is currently unavailable.
unsigned The object does not include a signature.
unknown_signature_type A non-PGP signature was found in the commit.
no_user No user was associated with the committer email address in the commit.
unverified_email The committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_email The committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_key The key that made the signature has not been registered with any user's account.
malformed_signature There was an error parsing the signature.
invalid The signature could not be cryptographically verified using the key whose key-id was found in the signature.
valid None of the above errors applied, so the signature is considered to be verified.

Parameters

namerequireddescription
owneryes
repoyes
shanoSHA or branch to start listing commits from.
pathnoOnly commits containing this file path will be returned.
authornoGitHub login or email address by which to filter by commit author.
sincenoOnly commits after this date will be returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
untilnoOnly commits before this date will be returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listCommits({
  owner,
  repo
})

Get a single commit

Diffs with binary data will have no patch property. Pass the appropriate media type to fetch diff and patch formats.

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

Value Description
expired_key The key that made the signature is expired.
not_signing_key The "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_error There was an error communicating with the signature verification service.
gpgverify_unavailable The signature verification service is currently unavailable.
unsigned The object does not include a signature.
unknown_signature_type A non-PGP signature was found in the commit.
no_user No user was associated with the committer email address in the commit.
unverified_email The committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_email The committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_key The key that made the signature has not been registered with any user's account.
malformed_signature There was an error parsing the signature.
invalid The signature could not be cryptographically verified using the key whose key-id was found in the signature.
valid None of the above errors applied, so the signature is considered to be verified.

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes
shano
octokit.repos.getCommit({
  owner,
  repo,
  commit_sha
})

Get the SHA-1 of a commit reference

Note: To access this endpoint, you must provide a custom media type in the Accept header:

application/vnd.github.VERSION.sha

Returns the SHA-1 of the commit reference. You must have read access for the repository to get the SHA-1 of a commit reference. You can use this endpoint to check if a remote reference's SHA-1 is the same as your local reference's SHA-1 by providing the local SHA-1 reference as the ETag.

Parameters

namerequireddescription
owneryes
repoyes
refyes
octokit.repos.getCommitRefSha({
  owner,
  repo,
  ref
})

Compare two commits

Both :base and :head must be branch names in :repo. To compare branches across other repositories in the same network as :repo, use the format <USERNAME>:branch.

The response from the API is equivalent to running the git log base..head command; however, commits are returned in reverse chronological order. Pass the appropriate media type to fetch diff and patch formats.

Working with large comparisons

The response will include a comparison of up to 250 commits. If you are working with a larger commit range, you can use the Commit List API to enumerate all commits in the range.

For comparisons with extremely large diffs, you may receive an error response indicating that the diff took too long to generate. You can typically resolve this error by using a smaller commit range.

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

Value Description
expired_key The key that made the signature is expired.
not_signing_key The "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_error There was an error communicating with the signature verification service.
gpgverify_unavailable The signature verification service is currently unavailable.
unsigned The object does not include a signature.
unknown_signature_type A non-PGP signature was found in the commit.
no_user No user was associated with the committer email address in the commit.
unverified_email The committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_email The committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_key The key that made the signature has not been registered with any user's account.
malformed_signature There was an error parsing the signature.
invalid The signature could not be cryptographically verified using the key whose key-id was found in the signature.
valid None of the above errors applied, so the signature is considered to be verified.

Parameters

namerequireddescription
owneryes
repoyes
baseyes
headyes
octokit.repos.compareCommits({
  owner,
  repo,
  base,
  head
})

List branches for HEAD commit

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see GitHub's billing plans in the GitHub Help documentation.

Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch.

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes
octokit.repos.listBranchesForHeadCommit({
  owner,
  repo,
  commit_sha
})

List pull requests associated with commit

Lists all pull requests containing the provided commit SHA, which can be from any point in the commit history. The results will include open and closed pull requests. Additional preview headers may be required to see certain details for associated pull requests, such as whether a pull request is in a draft state. For more information about previews that might affect this endpoint, see the List pull requests endpoint.

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listPullRequestsAssociatedWithCommit({
  owner,
  repo,
  commit_sha
})

Retrieve community profile metrics

This endpoint will return all community profile metrics, including an overall health score, repository description, the presence of documentation, detected code of conduct, detected license, and the presence of ISSUE_TEMPLATE, PULL_REQUEST_TEMPLATE, README, and CONTRIBUTING files.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.retrieveCommunityProfileMetrics({
  owner,
  repo
})

Get the README

Gets the preferred README for a repository.

READMEs support custom media types for retrieving the raw content or rendered HTML.

Parameters

namerequireddescription
owneryes
repoyes
refnoThe name of the commit/branch/tag.
octokit.repos.getReadme({
  owner,
  repo
})

Get contents

Gets the contents of a file or directory in a repository. Specify the file path or directory in :path. If you omit :path, you will receive the contents of all files in the repository.

Files and symlinks support a custom media type for retrieving the raw content or rendered HTML (when supported). All content types support a custom media type to ensure the content is returned in a consistent object format.

Note:

  • To get a repository's contents recursively, you can recursively get the tree.
  • This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the Git Trees API.
  • This API supports files up to 1 megabyte in size.

The response will be an array of objects, one object for each item in the directory.

When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value should be "submodule". This behavior exists in API v3 for backwards compatibility purposes. In the next major version of the API, the type will be returned as "submodule".

If the requested :path points to a symlink, and the symlink's target is a normal file in the repository, then the API responds with the content of the file (in the format shown above).

Otherwise, the API responds with an object describing the symlink itself:

The submodule_git_url identifies the location of the submodule repository, and the sha identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit.

If the submodule repository is not hosted on github.com, the Git URLs (git_url and _links["git"]) and the github.com URLs (html_url and _links["html"]) will have null values.

Parameters

namerequireddescription
owneryes
repoyes
pathyes
refnoThe name of the commit/branch/tag.
octokit.repos.getContents({
  owner,
  repo,
  path
})

Create a file

Creates a new file in a repository.

Parameters

namerequireddescription
owneryes
repoyes
pathyes
messageyesThe commit message.
contentyesThe new file content, using Base64 encoding.
branchnoThe branch name.
committernoThe person that committed the file.
committer.nameyesThe name of the author or committer of the commit. You'll receive a `422` status code if `name` is omitted.
committer.emailyesThe email of the author or committer of the commit. You'll receive a `422` status code if `name` is omitted.
authornoThe author of the file.
author.nameyesThe name of the author or committer of the commit. You'll receive a `422` status code if `name` is omitted.
author.emailyesThe email of the author or committer of the commit. You'll receive a `422` status code if `name` is omitted.
octokit.repos.createFile({
  owner,
  repo,
  path,
  message,
  content
})

Update a file

Updates a file in a repository.

Parameters

namerequireddescription
owneryes
repoyes
pathyes
messageyesThe commit message.
contentyesThe new file content, using Base64 encoding.
shayesThe blob SHA of the file being replaced.
branchnoThe branch name.
committernoThe person that committed the file.
committer.nameyesThe name of the author or committer of the commit. You'll receive a `422` status code if you omit `name`.
committer.emailyesThe email of the author or committer of the commit. You'll receive a `422` status code if you omit `name`.
authornoThe author of the file.
author.nameyesThe name of the author or committer of the commit. You'll receive a `422` status code if you omit `name`.
author.emailyesThe email of the author or committer of the commit. You'll receive a `422` status code if you omit `name`.
octokit.repos.updateFile({
  owner,
  repo,
  path,
  message,
  content,
  sha
})

Delete a file

Deletes a file in a repository.

The author section is optional and is filled in with the committer information if omitted. If the committer information is omitted, the authenticated user's information is used.

You must provide values for both name and email, whether you choose to use author or committer. Otherwise, you'll receive a 422 status code.

Both the author and committer parameters have the same keys:

name type description
name string The name of the author (or committer) of the commit
email string The email of the author (or committer) of the commit

Parameters

namerequireddescription
owneryes
repoyes
pathyes
messageyesThe commit message.
shayesThe blob SHA of the file being replaced.
branchnoThe branch name.
committernoobject containing information about the committer.
authornoobject containing information about the author.
octokit.repos.deleteFile({
  owner,
  repo,
  path,
  message,
  sha
})

Gets a redirect URL to download an archive for a repository. The :archive_format can be either tarball or zipball. The :ref must be a valid Git reference. If you omit :ref, the repository’s default branch (usually master) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request.

_Note_: For private repositories, these links are temporary and expire after five minutes.

To follow redirects with curl, use the -L switch:

Parameters

namerequireddescription
owneryes
repoyes
archive_formatyes
refyes
octokit.repos.getArchiveLink({
  owner,
  repo,
  archive_format,
  ref
})

List deployments

Simple filtering of deployments is available via query parameters:

Parameters

namerequireddescription
owneryes
repoyes
shanoThe SHA recorded at creation time.
refnoThe name of the ref. This can be a branch, tag, or SHA.
tasknoThe name of the task for the deployment (e.g., `deploy` or `deploy:migrations`).
environmentnoThe name of the environment that was deployed to (e.g., `staging` or `production`).
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listDeployments({
  owner,
  repo
})

Get a single deployment

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes
octokit.repos.getDeployment({
  owner,
  repo,
  deployment_id
})

Create a deployment

Deployments offer a few configurable parameters with sane defaults.

The ref parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them before we merge a pull request.

The environment parameter allows deployments to be issued to different runtime environments. Teams often have multiple environments for verifying their applications, such as production, staging, and qa. This parameter makes it easier to track which environments have requested deployments. The default environment is production.

The auto_merge parameter is used to ensure that the requested ref is not behind the repository's default branch. If the ref is behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds, the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will return a failure response.

By default, commit statuses for every submitted context must be in a success state. The required_contexts parameter allows you to specify a subset of contexts that must be success, or to specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do not require any contexts or create any commit statuses, the deployment will always succeed.

The payload parameter is available for any extra information that a deployment system might need. It is a JSON text field that will be passed on when a deployment event is dispatched.

The task parameter is used by the deployment system to allow different execution paths. In the web world this might be deploy:migrations to run schema changes on the system. In the compiled world this could be a flag to compile an application with debugging enabled.

Users with repo or repo_deployment scopes can create a deployment for a given ref:

A simple example putting the user and room into the payload to notify back to chat networks.

A more advanced example specifying required commit statuses and bypassing auto-merging.

You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating a deployment. This auto-merge happens when:

  • Auto-merge option is enabled in the repository
  • Topic branch does not include the latest changes on the base branch, which is masterin the response example
  • There are no merge conflicts

If there are no new commits in the base branch, a new request to create a deployment should give a successful response.

This error happens when the auto_merge option is enabled and when the default branch (in this case master), can't be merged into the branch that's being deployed (in this case topic-branch), due to merge conflicts.

This error happens when the required_contexts parameter indicates that one or more contexts need to have a success status for the commit to be deployed, but one or more of the required contexts do not have a state of success.

Parameters

namerequireddescription
owneryes
repoyes
refyesThe ref to deploy. This can be a branch, tag, or SHA.
tasknoSpecifies a task to execute (e.g., `deploy` or `deploy:migrations`).
auto_mergenoAttempts to automatically merge the default branch into the requested ref, if it's behind the default branch.
required_contextsnoThe [status](https://developer.github.com/v3/repos/statuses/) contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts.
payloadnoJSON payload with extra information about the deployment.
environmentnoName for the target deployment environment (e.g., `production`, `staging`, `qa`).
descriptionnoShort description of the deployment.
transient_environmentnoSpecifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: `false` **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type.
production_environmentnoSpecifies if the given environment is one that end-users directly interact with. Default: `true` when `environment` is `production` and `false` otherwise. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type.
octokit.repos.createDeployment({
  owner,
  repo,
  ref
})

List deployment statuses

Users with pull access can view deployment statuses for a deployment:

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listDeploymentStatuses({
  owner,
  repo,
  deployment_id
})

Get a single deployment status

Users with pull access can view a deployment status for a deployment:

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes
status_idyes
octokit.repos.getDeploymentStatus({
  owner,
  repo,
  deployment_id,
  status_id
})

Create a deployment status

Users with push access can create deployment statuses for a given deployment.

GitHub Apps require read & write access to "Deployments" and read-only access to "Repo contents" (for private repos). OAuth Apps require the repo_deployment scope.

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes
stateyesThe state of the status. Can be one of `error`, `failure`, `inactive`, `in_progress`, `queued` `pending`, or `success`. **Note:** To use the `inactive` state, you must provide the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type. To use the `in_progress` and `queued` states, you must provide the [`application/vnd.github.flash-preview+json`](https://developer.github.com/v3/previews/#deployment-statuses) custom media type.
target_urlnoThe target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. **Note:** It's recommended to use the `log_url` parameter, which replaces `target_url`.
log_urlnoThe full URL of the deployment's output. This parameter replaces `target_url`. We will continue to accept `target_url` to support legacy uses, but we recommend replacing `target_url` with `log_url`. Setting `log_url` will automatically set `target_url` to the same value. Default: `""` **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type.
descriptionnoA short description of the status. The maximum description length is 140 characters.
environmentnoName for the target deployment environment, which can be changed when setting a deploy status. For example, `production`, `staging`, or `qa`. **Note:** This parameter requires you to use the [`application/vnd.github.flash-preview+json`](https://developer.github.com/v3/previews/#deployment-statuses) custom media type.
environment_urlnoSets the URL for accessing your environment. Default: `""` **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type.
auto_inactivenoAdds a new `inactive` status to all prior non-transient, non-production environment deployments with the same repository and `environment` name as the created status's deployment. An `inactive` status is only added to deployments that had a `success` state. Default: `true` **Note:** To add an `inactive` status to `production` environments, you must use the [`application/vnd.github.flash-preview+json`](https://developer.github.com/v3/previews/#deployment-statuses) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://developer.github.com/v3/previews/#enhanced-deployments) custom media type. **Note:** To add an `inactive` status to `production` environments, you must use the [`application/vnd.github.flash-preview+json`](https://developer.github.com/v3/previews/#deployment-statuses) custom media type.
octokit.repos.createDeploymentStatus({
  owner,
  repo,
  deployment_id,
  state
})

List downloads for a repository

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listDownloads({
  owner,
  repo
})

Get a single download

Parameters

namerequireddescription
owneryes
repoyes
download_idyes
octokit.repos.getDownload({
  owner,
  repo,
  download_id
})

Delete a download

Parameters

namerequireddescription
owneryes
repoyes
download_idyes
octokit.repos.deleteDownload({
  owner,
  repo,
  download_id
})

List forks

Parameters

namerequireddescription
owneryes
repoyes
sortnoThe sort order. Can be either `newest`, `oldest`, or `stargazers`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listForks({
  owner,
  repo
})

Create a fork

Create a fork for the authenticated user.

Note: Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact GitHub Support.

Parameters

namerequireddescription
owneryes
repoyes
organizationnoOptional parameter to specify the organization name if forking into an organization.
octokit.repos.createFork({
  owner,
  repo
})

List hooks

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listHooks({
  owner,
  repo
})

Get single hook

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes
octokit.repos.getHook({
  owner,
  repo,
  hook_id
})

Create a hook

Repositories can have multiple webhooks installed. Each webhook should have a unique config. Multiple webhooks can share the same config as long as those webhooks do not have any events that overlap.

Here's how you can create a hook that posts payloads in JSON format:

Parameters

namerequireddescription
owneryes
repoyes
namenoUse `web` to create a webhook. This parameter only accepts the value `web`.
configyesKey/value pairs to provide settings for this webhook. [These are defined below](#create-hook-config-params).
config.urlyesThe URL to which the payloads will be delivered.
config.content_typenoThe media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`.
config.secretnoIf provided, the `secret` will be used as the `key` to generate the HMAC hex digest value in the [`X-Hub-Signature`](https://developer.github.com/webhooks/#delivery-headers) header.
config.insecure_sslnoDetermines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.**
eventsnoDetermines what [events](https://developer.github.com/v3/activity/events/types/) the hook is triggered for.
activenoDetermines if notifications are sent when the webhook is triggered. Set to `true` to send notifications.
octokit.repos.createHook({
  owner,
  repo,
  config
})

Edit a hook

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes
confignoKey/value pairs to provide settings for this webhook. [These are defined below](#create-hook-config-params).
config.urlyesThe URL to which the payloads will be delivered.
config.content_typenoThe media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`.
config.secretnoIf provided, the `secret` will be used as the `key` to generate the HMAC hex digest value in the [`X-Hub-Signature`](https://developer.github.com/webhooks/#delivery-headers) header.
config.insecure_sslnoDetermines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.**
eventsnoDetermines what [events](https://developer.github.com/v3/activity/events/types/) the hook is triggered for. This replaces the entire array of events.
add_eventsnoDetermines a list of events to be added to the list of events that the Hook triggers for.
remove_eventsnoDetermines a list of events to be removed from the list of events that the Hook triggers for.
activenoDetermines if notifications are sent when the webhook is triggered. Set to `true` to send notifications.
octokit.repos.updateHook({
  owner,
  repo,
  hook_id
})

Test a push hook

This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook is not subscribed to push events, the server will respond with 204 but no test POST will be generated.

Note: Previously /repos/:owner/:repo/hooks/:hook_id/test

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes
octokit.repos.testPushHook({
  owner,
  repo,
  hook_id
})

Ping a hook

This will trigger a ping event to be sent to the hook.

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes
octokit.repos.pingHook({
  owner,
  repo,
  hook_id
})

Delete a hook

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes
octokit.repos.deleteHook({
  owner,
  repo,
  hook_id
})

List invitations for a repository

When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations.

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listInvitations({
  owner,
  repo
})

Delete a repository invitation

Parameters

namerequireddescription
owneryes
repoyes
invitation_idyes
octokit.repos.deleteInvitation({
  owner,
  repo,
  invitation_id
})

Update a repository invitation

Parameters

namerequireddescription
owneryes
repoyes
invitation_idyes
permissionsnoThe permissions that the associated user will have on the repository. Valid values are `read`, `write`, and `admin`.
octokit.repos.updateInvitation({
  owner,
  repo,
  invitation_id
})

List a user's repository invitations

When authenticating as a user, this endpoint will list all currently open repository invitations for that user.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listInvitationsForAuthenticatedUser()

Accept a repository invitation

Parameters

namerequireddescription
invitation_idyes
octokit.repos.acceptInvitation({
  invitation_id
})

Decline a repository invitation

Parameters

namerequireddescription
invitation_idyes
octokit.repos.declineInvitation({
  invitation_id
})

List deploy keys

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listDeployKeys({
  owner,
  repo
})

Get a deploy key

Parameters

namerequireddescription
owneryes
repoyes
key_idyes
octokit.repos.getDeployKey({
  owner,
  repo,
  key_id
})

Add a new deploy key

Here's how you can create a read-only deploy key:

Parameters

namerequireddescription
owneryes
repoyes
titlenoA name for the key.
keyyesThe contents of the key.
read_onlynoIf `true`, the key will only be able to read repository contents. Otherwise, the key will be able to read and write. Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "[Repository permission levels for an organization](https://help.github.com/articles/repository-permission-levels-for-an-organization/)" and "[Permission levels for a user account repository](https://help.github.com/articles/permission-levels-for-a-user-account-repository/)."
octokit.repos.addDeployKey({
  owner,
  repo,
  key
})

Remove a deploy key

Parameters

namerequireddescription
owneryes
repoyes
key_idyes
octokit.repos.removeDeployKey({
  owner,
  repo,
  key_id
})

Perform a merge

Parameters

namerequireddescription
owneryes
repoyes
baseyesThe name of the base branch that the head will be merged into.
headyesThe head to merge. This can be a branch name or a commit SHA1.
commit_messagenoCommit message to use for the merge commit. If omitted, a default message will be used.
octokit.repos.merge({
  owner,
  repo,
  base,
  head
})

Get information about a Pages site

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getPages({
  owner,
  repo
})

Enable a Pages site

Parameters

namerequireddescription
owneryes
repoyes
source[branch]noThe repository branch used to publish your [site's source files](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/). Can be either `master` or `gh-pages`.
source[path]noThe repository directory that includes the source files for the Pages site. When `branch` is `master`, you can change `path` to `/docs`. When `branch` is `gh-pages`, you are unable to specify a `path` other than `/`.
octokit.repos.enablePagesSite({
  owner,
  repo
})

Disable a Pages site

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.disablePagesSite({
  owner,
  repo
})

Update information about a Pages site

Parameters

namerequireddescription
owneryes
repoyes
cnamenoSpecify a custom domain for the repository. Sending a `null` value will remove the custom domain. For more about custom domains, see "[Using a custom domain with GitHub Pages](https://help.github.com/articles/using-a-custom-domain-with-github-pages/)."
sourcenoUpdate the source for the repository. Must include the branch name, and may optionally specify the subdirectory `/docs`. Possible values are `"gh-pages"`, `"master"`, and `"master /docs"`.
octokit.repos.updateInformationAboutPagesSite({
  owner,
  repo
})

Request a page build

You can request that your site be built from the latest revision on the default branch. This has the same effect as pushing a commit to your default branch, but does not require an additional commit. Manually triggering page builds can be helpful when diagnosing build warnings and failures.

Build requests are limited to one concurrent build per repository and one concurrent build per requester. If you request a build while another is still in progress, the second request will be queued until the first completes.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.requestPageBuild({
  owner,
  repo
})

List Pages builds

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listPagesBuilds({
  owner,
  repo
})

Get latest Pages build

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getLatestPagesBuild({
  owner,
  repo
})

Get a specific Pages build

Parameters

namerequireddescription
owneryes
repoyes
build_idyes
octokit.repos.getPagesBuild({
  owner,
  repo,
  build_id
})

List releases for a repository

This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the Repository Tags API.

Information about published releases are available to everyone. Only users with push access will receive listings for draft releases.

Parameters

namerequireddescription
owneryes
repoyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listReleases({
  owner,
  repo
})

Get a single release

Note: This returns an upload_url key corresponding to the endpoint for uploading release assets. This key is a hypermedia resource.

Parameters

namerequireddescription
owneryes
repoyes
release_idyes
octokit.repos.getRelease({
  owner,
  repo,
  release_id
})

Get the latest release

View the latest published full release for the repository.

The latest release is the most recent non-prerelease, non-draft release, sorted by the created_at attribute. The created_at attribute is the date of the commit used for the release, and not the date when the release was drafted or published.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getLatestRelease({
  owner,
  repo
})

Get a release by tag name

Get a published release with the specified tag.

Parameters

namerequireddescription
owneryes
repoyes
tagyes
octokit.repos.getReleaseByTag({
  owner,
  repo,
  tag
})

Create a release

Users with push access to the repository can create a release.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
owneryes
repoyes
tag_nameyesThe name of the tag.
target_commitishnoSpecifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists.
namenoThe name of the release.
bodynoText describing the contents of the tag.
draftno`true` to create a draft (unpublished) release, `false` to create a published one.
prereleaseno`true` to identify the release as a prerelease. `false` to identify the release as a full release.
octokit.repos.createRelease({
  owner,
  repo,
  tag_name
})

Edit a release

Users with push access to the repository can edit a release.

Parameters

namerequireddescription
owneryes
repoyes
release_idyes
tag_namenoThe name of the tag.
target_commitishnoSpecifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists.
namenoThe name of the release.
bodynoText describing the contents of the tag.
draftno`true` makes the release a draft, and `false` publishes the release.
prereleaseno`true` to identify the release as a prerelease, `false` to identify the release as a full release.
octokit.repos.updateRelease({
  owner,
  repo,
  release_id
})

Delete a release

Users with push access to the repository can delete a release.

Parameters

namerequireddescription
owneryes
repoyes
release_idyes
octokit.repos.deleteRelease({
  owner,
  repo,
  release_id
})

List assets for a release

Parameters

namerequireddescription
owneryes
repoyes
release_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listAssetsForRelease({
  owner,
  repo,
  release_id
})

Upload a release asset

This endpoint makes use of a Hypermedia relation to determine which URL to access. This endpoint is provided by a URI template in the release's API response. You need to use an HTTP client which supports SNI to make calls to this endpoint.

The asset data is expected in its raw binary form, rather than JSON. Everything else about the endpoint is the same as the rest of the API. For example, you'll still need to pass your authentication to be able to upload an asset.

Send the raw binary content of the asset as the request body.

This may leave an empty asset with a state of "new". It can be safely deleted.

Parameters

namerequireddescription
urlyes
headersyesRequest headers containing `content-type` and `content-length`
headers.content-lengthyesThe content size of the asset in bytes
headers.content-typeyesThe content type of the asset. This should be set in the Header. Example: `"application/zip"`. For a list of acceptable types, refer this list of [media types](https://www.iana.org/assignments/media-types/media-types.xhtml).
nameyesThe file name of the asset. This should be set in a URI query parameter.
labelnoAn alternate short description of the asset. Used in place of the filename. This should be set in a URI query parameter.
fileyes
octokit.repos.uploadReleaseAsset({
  url,
  headers,
  name,
  file
})

Get a single release asset

To download the asset's binary content, set the Accept header of the request to application/octet-stream. The API will either redirect the client to the location, or stream it directly if possible. API clients should handle both a 200 or 302 response.

Parameters

namerequireddescription
owneryes
repoyes
asset_idyes
octokit.repos.getReleaseAsset({
  owner,
  repo,
  asset_id
})

Edit a release asset

Users with push access to the repository can edit a release asset.

Parameters

namerequireddescription
owneryes
repoyes
asset_idyes
namenoThe file name of the asset.
labelnoAn alternate short description of the asset. Used in place of the filename.
octokit.repos.updateReleaseAsset({
  owner,
  repo,
  asset_id
})

Delete a release asset

Parameters

namerequireddescription
owneryes
repoyes
asset_idyes
octokit.repos.deleteReleaseAsset({
  owner,
  repo,
  asset_id
})

Get contributors list with additions, deletions, and commit counts

  • total - The Total number of commits authored by the contributor.

Weekly Hash (weeks array):

  • w - Start of the week, given as a Unix timestamp.
  • a - Number of additions
  • d - Number of deletions
  • c - Number of commits

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getContributorsStats({
  owner,
  repo
})

Get the last year of commit activity data

Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getCommitActivityStats({
  owner,
  repo
})

Get the number of additions and deletions per week

Returns a weekly aggregate of the number of additions and deletions pushed to a repository.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getCodeFrequencyStats({
  owner,
  repo
})

Get the weekly commit count for the repository owner and everyone else

Returns the total commit counts for the owner and total commit counts in all. all is everyone combined, including the owner in the last 52 weeks. If you'd like to get the commit counts for non-owners, you can subtract owner from all.

The array order is oldest week (index 0) to most recent week.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getParticipationStats({
  owner,
  repo
})

Get the number of commits per hour in each day

Each array contains the day number, hour number, and number of commits:

  • 0-6: Sunday - Saturday
  • 0-23: Hour of day
  • Number of commits

For example, [2, 14, 25] indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getPunchCardStats({
  owner,
  repo
})

Create a status

Users with push access in a repository can create commit statuses for a given SHA.

Note: there is a limit of 1000 statuses per sha and context within a repository. Attempts to create more than 1000 statuses will result in a validation error.

Parameters

namerequireddescription
owneryes
repoyes
shayes
stateyesThe state of the status. Can be one of `error`, `failure`, `pending`, or `success`.
target_urlnoThe target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the source of the status. For example, if your continuous integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA: `http://ci.example.com/user/repo/build/sha`
descriptionnoA short description of the status.
contextnoA string label to differentiate this status from the status of other systems.
octokit.repos.createStatus({
  owner,
  repo,
  sha,
  state
})

List statuses for a specific ref

Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one.

This resource is also available via a legacy route: GET /repos/:owner/:repo/statuses/:ref.

Parameters

namerequireddescription
owneryes
repoyes
refyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.repos.listStatusesForRef({
  owner,
  repo,
  ref
})

Get the combined status for a specific ref

Users with pull access in a repository can access a combined view of commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name.

The most recent status for each context is returned, up to 100. This field paginates if there are over 100 contexts.

Additionally, a combined state is returned. The state is one of:

  • failure if any of the contexts report as error or failure
  • pending if there are no statuses or a context is pending
  • success if the latest status for all contexts is success

Parameters

namerequireddescription
owneryes
repoyes
refyes
octokit.repos.getCombinedStatusForRef({
  owner,
  repo,
  ref
})

List referrers

Get the top 10 referrers over the last 14 days.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getTopReferrers({
  owner,
  repo
})

List paths

Get the top 10 popular contents over the last 14 days.

Parameters

namerequireddescription
owneryes
repoyes
octokit.repos.getTopPaths({
  owner,
  repo
})

Views

Get the total number of views and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.

Parameters

namerequireddescription
owneryes
repoyes
pernoMust be one of: `day`, `week`.
octokit.repos.getViews({
  owner,
  repo
})

Clones

Get the total number of clones and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.

Parameters

namerequireddescription
owneryes
repoyes
pernoMust be one of: `day`, `week`.
octokit.repos.getClones({
  owner,
  repo
})

scim

Get a list of provisioned identities

To filter for a specific email address, use the email query parameter and the eq operator:

Your filter would look like this cURL command:

Retrieves users that match the filter. In the example, we searched only for octocat@github.com.

Retrieves a paginated list of all provisioned organization members, including pending invitations.

Parameters

namerequireddescription
orgyes
startIndexnoUsed for pagination: the index of the first result to return.
countnoUsed for pagination: the number of results to return.
filternoFilters results using the equals query parameter operator (`eq`). You can filter results that are equal to `id`, `userName`, `emails`, and `external_id`. For example, to search for an identity with the `userName` Octocat, you would use this query: `?filter=userName%20eq%20\"Octocat\"`.
octokit.scim.listProvisionedIdentities({
  org
})

Get provisioning details for a single user

Parameters

namerequireddescription
orgyes
scim_user_idyes
external_identity_guidno
octokit.scim.getProvisioningDetailsForUser({
  org,
  scim_user_id
})

Provision and invite users

Provision organization membership for a user, and send an activation email to the email address.

As shown in the following example, you must at least provide the required values for the user: userName, name, and emails.

Parameters

namerequireddescription
orgyes
octokit.scim.provisionAndInviteUsers({
  org
})

Provision and invite users

Provision organization membership for a user, and send an activation email to the email address.

As shown in the following example, you must at least provide the required values for the user: userName, name, and emails.

Parameters

namerequireddescription
orgyes
octokit.scim.provisionInviteUsers({
  org
})

Replace a provisioned user's information

Replaces an existing provisioned user's information. You must provide all the information required for the user as if you were provisioning them for the first time. Any existing user information that you don't provide will be removed. If you want to only update a specific attribute, use the Update a user attribute endpoint instead.

As shown in the following example, you must at least provide the required values for the user: userName, name, and emails.

Warning: Setting active: false removes the user from the organization, deletes the external identity, and deletes the associated :scim_user_id.

Parameters

namerequireddescription
orgyes
scim_user_idyes
external_identity_guidno
octokit.scim.replaceProvisionedUserInformation({
  org,
  scim_user_id
})

Update a provisioned organization membership

Replaces an existing provisioned user's information. You must provide all the information required for the user as if you were provisioning them for the first time. Any existing user information that you don't provide will be removed. If you want to only update a specific attribute, use the Update a user attribute endpoint instead.

As shown in the following example, you must at least provide the required values for the user: userName, name, and emails.

Warning: Setting active: false removes the user from the organization, deletes the external identity, and deletes the associated :scim_user_id.

Parameters

namerequireddescription
orgyes
scim_user_idyes
external_identity_guidno
octokit.scim.updateProvisionedOrgMembership({
  org,
  scim_user_id
})

Update a user attribute

Allows you to change a provisioned user's individual attributes. To change a user's values, you must provide a specific Operations JSON format that contains at least one of the add, remove, or replace operations.

The following example shows adding a new email address and updating the user's given name. For other examples and more information on the SCIM operations format, see the SCIM specification.

Note: Complicated SCIM path selectors that include filters are not supported. For example, a path selector defined as "path": "emails[type eq \"work\"]" will not work.

Warning: If you set active:false using the replace operation (as shown in the JSON example below), it removes the user from the organization, deletes the external identity, and deletes the associated :scim_user_id.

{
  "Operations":[{
    "op":"replace",
    "value":{
      "active":false
    }
  }]
}

Parameters

namerequireddescription
orgyes
scim_user_idyes
external_identity_guidno
octokit.scim.updateUserAttribute({
  org,
  scim_user_id
})

Remove a user from the organization

Parameters

namerequireddescription
orgyes
scim_user_idyes
external_identity_guidno
octokit.scim.removeUserFromOrg({
  org,
  scim_user_id
})

Search repositories

Find repositories via various criteria. This method returns up to 100 results per page.

When searching for repositories, you can get text match metadata for the name and description fields when you pass the text-match media type. For more details about how to receive highlighted search results, see Text match metadata.

Suppose you want to search for popular Tetris repositories written in Assembly. Your query might look like this.

You can search for multiple topics by adding more topic: instances, and including the mercy-preview header. For example:

In this request, we're searching for repositories with the word tetris in the name, the description, or the README. We're limiting the results to only find repositories where the primary language is Assembly. We're sorting by stars in descending order, so that the most popular repositories appear first in the search results.

Parameters

namerequireddescription
qyesThe query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query). See "[Searching for repositories](https://help.github.com/articles/searching-for-repositories/)" for a detailed list of qualifiers.
sortnoSorts the results of your query by number of `stars`, `forks`, or `help-wanted-issues` or how recently the items were `updated`.
ordernoDetermines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.search.repos({
  q
})

Search commits

Find commits via various criteria. This method returns up to 100 results per page.

When searching for commits, you can get text match metadata for the message field when you provide the text-match media type. For more details about how to receive highlighted search results, see Text match metadata.

Considerations for commit search

Only the default branch is considered. In most cases, this will be the master branch.

Suppose you want to find commits related to CSS in the octocat/Spoon-Knife repository. Your query would look something like this:

Parameters

namerequireddescription
qyesThe query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query). See "[Searching commits](https://help.github.com/articles/searching-commits/)" for a detailed list of qualifiers.
sortnoSorts the results of your query by `author-date` or `committer-date`.
ordernoDetermines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.search.commits({
  q
})

Search code

Find file contents via various criteria. This method returns up to 100 results per page.

When searching for code, you can get text match metadata for the file content and file path fields when you pass the text-match media type. For more details about how to receive highlighted search results, see Text match metadata.

Note: You must authenticate to search for code across all public repositories.

Considerations for code search

Due to the complexity of searching code, there are a few restrictions on how searches are performed:

  • Only the default branch is considered. In most cases, this will be the master branch.
  • Only files smaller than 384 KB are searchable.
  • You must always include at least one search term when searching source code. For example, searching for language:go is not valid, while amazing language:go is.

Suppose you want to find the definition of the addClass function inside jQuery. Your query would look something like this:

Here, we're searching for the keyword addClass within a file's contents. We're making sure that we're only looking in files where the language is JavaScript. And we're scoping the search to the repo:jquery/jquery repository.

Parameters

namerequireddescription
qyesThe query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query). See "[Searching code](https://help.github.com/articles/searching-code/)" for a detailed list of qualifiers.
sortnoSorts the results of your query. Can only be `indexed`, which indicates how recently a file has been indexed by the GitHub search infrastructure.
ordernoDetermines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.search.code({
  q
})

Search issues and pull requests

Find issues by state and keyword. This method returns up to 100 results per page.

When searching for issues, you can get text match metadata for the issue title, issue body, and issue comment body fields when you pass the text-match media type. For more details about how to receive highlighted search results, see Text match metadata.

Let's say you want to find the oldest unresolved Python bugs on Windows. Your query might look something like this.

In this query, we're searching for the keyword windows, within any open issue that's labeled as bug. The search runs across repositories whose primary language is Python. We’re sorting by creation date in ascending order, so that the oldest issues appear first in the search results.

Parameters

namerequireddescription
qyesThe query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query). See "[Searching issues and pull requests](https://help.github.com/articles/searching-issues-and-pull-requests/)" for a detailed list of qualifiers.
sortnoSorts the results of your query by the number of `comments`, `reactions`, `reactions-+1`, `reactions--1`, `reactions-smile`, `reactions-thinking_face`, `reactions-heart`, `reactions-tada`, or `interactions`. You can also sort results by how recently the items were `created` or `updated`,
ordernoDetermines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.search.issuesAndPullRequests({
  q
})

Search issues

Find issues by state and keyword. This method returns up to 100 results per page.

When searching for issues, you can get text match metadata for the issue title, issue body, and issue comment body fields when you pass the text-match media type. For more details about how to receive highlighted search results, see Text match metadata.

Let's say you want to find the oldest unresolved Python bugs on Windows. Your query might look something like this.

In this query, we're searching for the keyword windows, within any open issue that's labeled as bug. The search runs across repositories whose primary language is Python. We’re sorting by creation date in ascending order, so that the oldest issues appear first in the search results.

Parameters

namerequireddescription
qyesThe query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query). See "[Searching issues and pull requests](https://help.github.com/articles/searching-issues-and-pull-requests/)" for a detailed list of qualifiers.
sortnoSorts the results of your query by the number of `comments`, `reactions`, `reactions-+1`, `reactions--1`, `reactions-smile`, `reactions-thinking_face`, `reactions-heart`, `reactions-tada`, or `interactions`. You can also sort results by how recently the items were `created` or `updated`,
ordernoDetermines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.search.issues({
  q
})

Search users

Find users via various criteria. This method returns up to 100 results per page.

When searching for users, you can get text match metadata for the issue login, email, and name fields when you pass the text-match media type. For more details about highlighting search results, see Text match metadata. For more details about how to receive highlighted search results, see Text match metadata.

Imagine you're looking for a list of popular users. You might try out this query:

Here, we're looking at users with the name Tom. We're only interested in those with more than 42 repositories, and only if they have over 1,000 followers.

Parameters

namerequireddescription
qyesThe query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query). See "[Searching users](https://help.github.com/articles/searching-users/)" for a detailed list of qualifiers.
sortnoSorts the results of your query by number of `followers` or `repositories`, or when the person `joined` GitHub.
ordernoDetermines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.search.users({
  q
})

Search topics

Find topics via various criteria. Results are sorted by best match. This method returns up to 100 results per page.

When searching for topics, you can get text match metadata for the topic's short_description, description, name, or display_name field when you pass the text-match media type. For more details about how to receive highlighted search results, see Text match metadata.

See "Searching topics" for a detailed list of qualifiers.

Suppose you want to search for topics related to Ruby that are featured on https://github.com/topics. Your query might look like this:

In this request, we're searching for topics with the keyword ruby, and we're limiting the results to find only topics that are featured. The topics that are the best match for the query appear first in the search results.

Note: A search for featured Ruby topics only has 6 total results, so a Link header indicating pagination is not included in the response.

Parameters

namerequireddescription
qyesThe query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query).
octokit.search.topics({
  q
})

Search labels

Find labels in a repository with names or descriptions that match search keywords. Returns up to 100 results per page.

When searching for labels, you can get text match metadata for the label name and description fields when you pass the text-match media type. For more details about how to receive highlighted search results, see Text match metadata.

Suppose you want to find labels in the linguist repository that match bug, defect, or enhancement. Your query might look like this:

The labels that best match for the query appear first in the search results.

Parameters

namerequireddescription
repository_idyesThe id of the repository.
qyesThe search keywords. This endpoint does not accept qualifiers in the query. To learn more about the format of the query, see [Constructing a search query](#constructing-a-search-query).
sortnoSorts the results of your query by when the label was `created` or `updated`.
ordernoDetermines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.
octokit.search.labels({
  repository_id,
  q
})

Search issues

Find issues by state and keyword.

Parameters

namerequireddescription
owneryes
repositoryyes
stateyesIndicates the state of the issues to return. Can be either `open` or `closed`.
keywordyesThe search term.
octokit.search.issuesLegacy({
  owner,
  repository,
  state,
  keyword
})

Search repositories

Find repositories by keyword. Note, this legacy method does not follow the v3 pagination pattern. This method returns up to 100 results per page and pages can be fetched using the start_page parameter.

Parameters

namerequireddescription
keywordyesThe search term.
languagenoFilter results by language.
start_pagenoThe page number to fetch.
sortnoThe sort field. One of `stars`, `forks`, or `updated`.
ordernoThe sort field. if `sort` param is provided. Can be either `asc` or `desc`.
octokit.search.reposLegacy({
  keyword
})

Search users

Find users by keyword.

Parameters

namerequireddescription
keywordyesThe search term.
start_pagenoThe page number to fetch.
sortnoThe sort field. One of `stars`, `forks`, or `updated`.
ordernoThe sort field. if `sort` param is provided. Can be either `asc` or `desc`.
octokit.search.usersLegacy({
  keyword
})

Email search

This API call is added for compatibility reasons only. There's no guarantee that full email searches will always be available. The @ character in the address must be left unencoded. Searches only against public email addresses (as configured on the user's GitHub profile).

Parameters

namerequireddescription
emailyesThe email address.
octokit.search.emailLegacy({
  email
})

teams

List teams

Parameters

namerequireddescription
orgyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.list({
  org
})

Get team

Parameters

namerequireddescription
team_idyes
octokit.teams.get({
  team_id
})

Get team by name

Gets a team using the team's slug. GitHub generates the slug from the team name.

Parameters

namerequireddescription
orgyes
team_slugyes
octokit.teams.getByName({
  org,
  team_slug
})

Create team

To create a team, the authenticated user must be a member or owner of :org. By default, organization members can create teams. Organization owners can limit team creation to organization owners. For more information, see "Setting team creation permissions."

Parameters

namerequireddescription
orgyes
nameyesThe name of the team.
descriptionnoThe description of the team.
maintainersnoThe logins of organization members to add as maintainers of the team.
repo_namesnoThe full name (e.g., "organization-name/repository-name") of repositories to add the team to.
privacynoThe level of privacy this team should have. The options are: **For a non-nested team:** \* `secret` - only visible to organization owners and members of this team. \* `closed` - visible to all members of this organization. Default: `secret` **For a parent or child team:** \* `closed` - visible to all members of this organization. Default for child team: `closed` **Note**: You must pass the `hellcat-preview` media type to set privacy default to `closed` for child teams. **For a parent or child team:**
permissionno**Deprecated**. The permission that new repositories will be added to the team with when none is specified. Can be one of: \* `pull` - team members can pull, but not push to or administer newly-added repositories. \* `push` - team members can pull and push, but not administer newly-added repositories. \* `admin` - team members can pull, push and administer newly-added repositories.
parent_team_idnoThe ID of a team to set as the parent team. **Note**: You must pass the `hellcat-preview` media type to use this parameter.
octokit.teams.create({
  org,
  name
})

Edit team

To edit a team, the authenticated user must either be an owner of the org that the team is associated with, or a maintainer of the team.

Note: With nested teams, the privacy for parent teams cannot be secret.

Parameters

namerequireddescription
team_idyes
nameyesThe name of the team.
descriptionnoThe description of the team.
privacynoThe level of privacy this team should have. Editing teams without specifying this parameter leaves `privacy` intact. The options are: **For a non-nested team:** \* `secret` - only visible to organization owners and members of this team. \* `closed` - visible to all members of this organization. **For a parent or child team:** \* `closed` - visible to all members of this organization.
permissionno**Deprecated**. The permission that new repositories will be added to the team with when none is specified. Can be one of: \* `pull` - team members can pull, but not push to or administer newly-added repositories. \* `push` - team members can pull and push, but not administer newly-added repositories. \* `admin` - team members can pull, push and administer newly-added repositories.
parent_team_idnoThe ID of a team to set as the parent team. **Note**: You must pass the `hellcat-preview` media type to use this parameter.
octokit.teams.update({
  team_id,
  name
})

Delete team

To delete a team, the authenticated user must be a team maintainer or an owner of the org associated with the team.

If you are an organization owner and you pass the hellcat-preview media type, deleting a parent team will delete all of its child teams as well.

Parameters

namerequireddescription
team_idyes
octokit.teams.delete({
  team_id
})

List child teams

At this time, the hellcat-preview media type is required to use this endpoint.

Parameters

namerequireddescription
team_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listChild({
  team_id
})

List team repos

Note: If you pass the hellcat-preview media type, the response will include any repositories inherited through a parent team.

Parameters

namerequireddescription
team_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listRepos({
  team_id
})

Check if a team manages a repository

Note: If you pass the hellcat-preview media type, repositories inherited through a parent team will be checked.

You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom media type via the Accept header:

Parameters

namerequireddescription
team_idyes
owneryes
repoyes
octokit.teams.checkManagesRepo({
  team_id,
  owner,
  repo
})

Add or update team repository

To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a 422 Unprocessable Entity status if you attempt to add a repository to a team that is not owned by the organization.

If you pass the hellcat-preview media type, you can modify repository permissions of child teams.

Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Parameters

namerequireddescription
team_idyes
owneryes
repoyes
permissionnoThe permission to grant the team on this repository. Can be one of: \* `pull` - team members can pull, but not push to or administer this repository. \* `push` - team members can pull and push, but not administer this repository. \* `admin` - team members can pull, push and administer this repository. If no permission is specified, the team's `permission` attribute will be used to determine what permission to grant the team on this repository. **Note**: If you pass the `hellcat-preview` media type, you can promote—but not demote—a `permission` attribute inherited through a parent team.
octokit.teams.addOrUpdateRepo({
  team_id,
  owner,
  repo
})

Remove team repository

If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. NOTE: This does not delete the repository, it just removes it from the team.

Parameters

namerequireddescription
team_idyes
owneryes
repoyes
octokit.teams.removeRepo({
  team_id,
  owner,
  repo
})

List user teams

List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user, repo, or read:org scope when authenticating via OAuth.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listForAuthenticatedUser()

List team projects

Lists the organization projects for a team. If you pass the hellcat-preview media type, the response will include projects inherited from a parent team.

Parameters

namerequireddescription
team_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listProjects({
  team_id
})

Review a team project

Checks whether a team has read, write, or admin permissions for an organization project. If you pass the hellcat-preview media type, the response will include projects inherited from a parent team.

Parameters

namerequireddescription
team_idyes
project_idyes
octokit.teams.reviewProject({
  team_id,
  project_id
})

Add or update team project

Adds an organization project to a team. To add a project to a team or update the team's permission on a project, the authenticated user must have admin permissions for the project. The project and team must be part of the same organization.

Parameters

namerequireddescription
team_idyes
project_idyes
permissionnoThe permission to grant to the team for this project. Can be one of: \* `read` - team members can read, but not write to or administer this project. \* `write` - team members can read and write, but not administer this project. \* `admin` - team members can read, write and administer this project. Default: the team's `permission` attribute will be used to determine what permission to grant the team on this project. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://developer.github.com/v3/#http-verbs)." **Note**: If you pass the `hellcat-preview` media type, you can promote—but not demote—a `permission` attribute inherited from a parent team.
octokit.teams.addOrUpdateProject({
  team_id,
  project_id
})

Remove team project

Removes an organization project from a team. An organization owner or a team maintainer can remove any project from the team. To remove a project from a team as an organization member, the authenticated user must have read access to both the team and project, or admin access to the team or project. Note: This endpoint removes the project from the team, but does not delete it.

Parameters

namerequireddescription
team_idyes
project_idyes
octokit.teams.removeProject({
  team_id,
  project_id
})

List comments

List all comments on a team discussion. OAuth access tokens require the read:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
directionnoSorts the discussion comments by the date they were created. To return the oldest comments first, set to `asc`. Can be one of `asc` or `desc`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listDiscussionComments({
  team_id,
  discussion_number
})

Get a single comment

Get a specific comment on a team discussion. OAuth access tokens require the read:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
comment_numberyes
octokit.teams.getDiscussionComment({
  team_id,
  discussion_number,
  comment_number
})

Create a comment

Creates a new comment on a team discussion. OAuth access tokens require the write:discussion scope.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
bodyyesThe discussion comment's body text.
octokit.teams.createDiscussionComment({
  team_id,
  discussion_number,
  body
})

Edit a comment

Edits the body text of a discussion comment. OAuth access tokens require the write:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
comment_numberyes
bodyyesThe discussion comment's body text.
octokit.teams.updateDiscussionComment({
  team_id,
  discussion_number,
  comment_number,
  body
})

Delete a comment

Deletes a comment on a team discussion. OAuth access tokens require the write:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
comment_numberyes
octokit.teams.deleteDiscussionComment({
  team_id,
  discussion_number,
  comment_number
})

List discussions

List all discussions on a team's page. OAuth access tokens require the read:discussion scope.

Parameters

namerequireddescription
team_idyes
directionnoSorts the discussion comments by the date they were created. To return the oldest comments first, set to `asc`. Can be one of `asc` or `desc`.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listDiscussions({
  team_id
})

Get a single discussion

Get a specific discussion on a team's page. OAuth access tokens require the read:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
octokit.teams.getDiscussion({
  team_id,
  discussion_number
})

Create a discussion

Creates a new discussion post on a team's page. OAuth access tokens require the write:discussion scope.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Parameters

namerequireddescription
team_idyes
titleyesThe discussion post's title.
bodyyesThe discussion post's body text.
privatenoPrivate posts are only visible to team members, organization owners, and team maintainers. Public posts are visible to all members of the organization. Set to `true` to create a private post.
octokit.teams.createDiscussion({
  team_id,
  title,
  body
})

Edit a discussion

Edits the title and body text of a discussion post. Only the parameters you provide are updated. OAuth access tokens require the write:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
titlenoThe discussion post's title.
bodynoThe discussion post's body text.
octokit.teams.updateDiscussion({
  team_id,
  discussion_number
})

Delete a discussion

Delete a discussion from a team's page. OAuth access tokens require the write:discussion scope.

Parameters

namerequireddescription
team_idyes
discussion_numberyes
octokit.teams.deleteDiscussion({
  team_id,
  discussion_number
})

List team members

If you pass the hellcat-preview media type, team members will include the members of child teams.

Parameters

namerequireddescription
team_idyes
rolenoFilters members returned by their role in the team. Can be one of: \* `member` - normal members of the team. \* `maintainer` - team maintainers. \* `all` - all members of the team.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listMembers({
  team_id
})

Get team member

The "Get team member" API (described below) is deprecated.

We recommend using the Get team membership API instead. It allows you to get both active and pending memberships.

To list members in a team, the team must be visible to the authenticated user.

Parameters

namerequireddescription
team_idyes
usernameyes
octokit.teams.getMember({
  team_id,
  username
})

Add team member

The "Add team member" API (described below) is deprecated.

We recommend using the Add team membership API instead. It allows you to invite new organization members to your teams.

To add a user to a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with, and the user being added must already be a member of at least one other team on the same organization.

Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

If you attempt to add an organization to a team, you will get this:

If you attempt to add a user to a team and that user is not a member of at least one other team on the same organization, you will get this:

Parameters

namerequireddescription
team_idyes
usernameyes
octokit.teams.addMember({
  team_id,
  username
})

Remove team member

The "Remove team member" API (described below) is deprecated.

We recommend using the Remove team membership API instead. It allows you to remove both active and pending memberships.

To remove a user from a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. NOTE: This does not delete the user, it just removes them from the team.

Parameters

namerequireddescription
team_idyes
usernameyes
octokit.teams.removeMember({
  team_id,
  username
})

Get team membership

If you pass the hellcat-preview media type, team members will include the members of child teams.

To get a user's membership with a team, the team must be visible to the authenticated user.

Note: The role for organization owners returns as maintainer. For more information about maintainer roles, see Create team.

Parameters

namerequireddescription
team_idyes
usernameyes
octokit.teams.getMembership({
  team_id,
  username
})

Add or update team membership

If the user is already a member of the team's organization, this endpoint will add the user to the team. To add a membership between an organization member and a team, the authenticated user must be an organization owner or a maintainer of the team.

If the user is unaffiliated with the team's organization, this endpoint will send an invitation to the user via email. This newly-created membership will be in the "pending" state until the user accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team. To add a membership between an unaffiliated user and a team, the authenticated user must be an organization owner.

If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a maintainer of the team.

If you attempt to add an organization to a team, you will get this:

Parameters

namerequireddescription
team_idyes
usernameyes
rolenoThe role that this user should have in the team. Can be one of: \* `member` - a normal member of the team. \* `maintainer` - a team maintainer. Able to add/remove other team members, promote other team members to team maintainer, and edit the team's name and description.
octokit.teams.addOrUpdateMembership({
  team_id,
  username
})

Remove team membership

To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. NOTE: This does not delete the user, it just removes their membership from the team.

Parameters

namerequireddescription
team_idyes
usernameyes
octokit.teams.removeMembership({
  team_id,
  username
})

List pending team invitations

The return hash contains a role field which refers to the Organization Invitation role and will be one of the following values: direct_member, admin, billing_manager, hiring_manager, or reinstate. If the invitee is not a GitHub member, the login field in the return hash will be null.

Parameters

namerequireddescription
team_idyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.teams.listPendingInvitations({
  team_id
})

users

Get a single user

Provides publicly available information about someone with a GitHub account.

The email key in the following response is the publicly visible email address from your GitHub profile page. When setting up your profile, you can select a primary email address to be “public” which provides an email entry for this endpoint. If you do not set a public email address for email, then it will have a value of null. You only see publicly visible email addresses when authenticated with GitHub. For more information, see Authentication.

The Emails API enables you to list all of your email addresses, and toggle a primary email to be visible publicly. For more information, see "Emails API".

Parameters

namerequireddescription
usernameyes
octokit.users.getByUsername({
  username
})

Get the authenticated user

Lists public and private profile information when authenticated through basic auth or OAuth with the user scope.

Lists public profile information when authenticated through OAuth without the user scope.

Parameters

namerequireddescription
octokit.users.getAuthenticated()

Update the authenticated user

Note: If your email is set to private and you send an email parameter as part of this request to update your profile, your privacy settings are still enforced: the email address will not be displayed on your public profile or via the API.

Parameters

namerequireddescription
namenoThe new name of the user.
emailnoThe publicly visible email address of the user.
blognoThe new blog URL of the user.
companynoThe new company of the user.
locationnoThe new location of the user.
hireablenoThe new hiring availability of the user.
bionoThe new short biography of the user.
octokit.users.updateAuthenticated()

Get contextual information about a user

Provides hovercard information when authenticated through basic auth or OAuth with the repo scope. You can find out more about someone in relation to their pull requests, issues, repositories, and organizations.

The subject_type and subject_id parameters provide context for the person's hovercard, which returns more information than without the parameters. For example, if you wanted to find out more about octocat who owns the Spoon-Knife repository via cURL, it would look like this:

Parameters

namerequireddescription
usernameyes
subject_typenoIdentifies which additional information you'd like to receive about the person's hovercard. Can be `organization`, `repository`, `issue`, `pull_request`. **Required** when using `subject_id`.
subject_idnoUses the ID for the `subject_type` you specified. **Required** when using `subject_type`.
octokit.users.getContextForUser({
  username
})

Get all users

Lists all users, in the order that they signed up on GitHub. This list includes personal user accounts and organization accounts.

Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of users.

Parameters

namerequireddescription
sincenoThe integer ID of the last User that you've seen.
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.list()

List blocked users

List the users you've blocked on your personal account.

Parameters

namerequireddescription
octokit.users.listBlocked()

Check whether you've blocked a user

If the user is blocked:

If the user is not blocked:

Parameters

namerequireddescription
usernameyes
octokit.users.checkBlocked({
  username
})

Block a user

Parameters

namerequireddescription
usernameyes
octokit.users.block({
  username
})

Unblock a user

Parameters

namerequireddescription
usernameyes
octokit.users.unblock({
  username
})

List email addresses for a user

Lists all of your email addresses, and specifies which one is visible to the public. This endpoint is accessible with the user:email scope.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listEmails()

List public email addresses for a user

Lists your publicly visible email address, which you can set with the Toggle primary email visibility endpoint. This endpoint is accessible with the user:email scope.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listPublicEmails()

Add email address(es)

This endpoint is accessible with the user scope.

Parameters

namerequireddescription
emailsyesAdds one or more email addresses to your GitHub account. Must contain at least one email address. **Note:** Alternatively, you can pass a single email address or an `array` of emails addresses directly, but we recommend that you pass an object using the `emails` key.
octokit.users.addEmails({
  emails
})

Delete email address(es)

This endpoint is accessible with the user scope.

Parameters

namerequireddescription
emailsyesDeletes one or more email addresses from your GitHub account. Must contain at least one email address. **Note:** Alternatively, you can pass a single email address or an `array` of emails addresses directly, but we recommend that you pass an object using the `emails` key.
octokit.users.deleteEmails({
  emails
})

Toggle primary email visibility

Sets the visibility for your primary email addresses.

Parameters

namerequireddescription
emailyesSpecify the _primary_ email address that needs a visibility change.
visibilityyesUse `public` to enable an authenticated user to view the specified email address, or use `private` so this primary email address cannot be seen publicly.
octokit.users.togglePrimaryEmailVisibility({
  email,
  visibility
})

List a user's followers

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listFollowersForUser({
  username
})

List the authenticated user's followers

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listFollowersForAuthenticatedUser()

List who a user is following

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listFollowingForUser({
  username
})

List who the authenticated user is following

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listFollowingForAuthenticatedUser()

Check if you are following a user

Parameters

namerequireddescription
usernameyes
octokit.users.checkFollowing({
  username
})

Check if one user follows another

Parameters

namerequireddescription
usernameyes
target_useryes
octokit.users.checkFollowingForUser({
  username,
  target_user
})

Follow a user

Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Following a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope.

Parameters

namerequireddescription
usernameyes
octokit.users.follow({
  username
})

Unfollow a user

Unfollowing a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope.

Parameters

namerequireddescription
usernameyes
octokit.users.unfollow({
  username
})

List GPG keys for a user

Lists the GPG keys for a user. This information is accessible by anyone.

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listGpgKeysForUser({
  username
})

List your GPG keys

Lists the current user's GPG keys. Requires that you are authenticated via Basic Auth or via OAuth with at least read:gpg_key scope.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listGpgKeys()

Get a single GPG key

View extended details for a single GPG key. Requires that you are authenticated via Basic Auth or via OAuth with at least read:gpg_key scope.

Parameters

namerequireddescription
gpg_key_idyes
octokit.users.getGpgKey({
  gpg_key_id
})

Create a GPG key

Adds a GPG key to the authenticated user's GitHub account. Requires that you are authenticated via Basic Auth, or OAuth with at least write:gpg_key scope.

Parameters

namerequireddescription
armored_public_keynoYour GPG key, generated in ASCII-armored format. See "[Generating a new GPG key](https://help.github.com/articles/generating-a-new-gpg-key/)" for help creating a GPG key.
octokit.users.createGpgKey()

Delete a GPG key

Removes a GPG key from the authenticated user's GitHub account. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:gpg_key scope.

Parameters

namerequireddescription
gpg_key_idyes
octokit.users.deleteGpgKey({
  gpg_key_id
})

List public keys for a user

Lists the verified public SSH keys for a user. This is accessible by anyone.

Parameters

namerequireddescription
usernameyes
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listPublicKeysForUser({
  username
})

List your public keys

Lists the public SSH keys for the authenticated user's GitHub account. Requires that you are authenticated via Basic Auth or via OAuth with at least read:public_key scope.

Parameters

namerequireddescription
per_pagenoResults per page (max 100)
pagenoPage number of the results to fetch.
octokit.users.listPublicKeys()

Get a single public key

View extended details for a single public SSH key. Requires that you are authenticated via Basic Auth or via OAuth with at least read:public_key scope.

Parameters

namerequireddescription
key_idyes
octokit.users.getPublicKey({
  key_id
})

Create a public key

Adds a public SSH key to the authenticated user's GitHub account. Requires that you are authenticated via Basic Auth, or OAuth with at least write:public_key scope.

Parameters

namerequireddescription
titlenoA descriptive name for the new key. Use a name that will help you recognize this key in your GitHub account. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air".
keynoThe public SSH key to add to your GitHub account. See "[Generating a new SSH key](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/)" for guidance on how to create a public SSH key.
octokit.users.createPublicKey()

Delete a public key

Removes a public SSH key from the authenticated user's GitHub account. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope.

Parameters

namerequireddescription
key_idyes
octokit.users.deletePublicKey({
  key_id
})