Skip to main content

📣 Please do not share this URL publicly. This page contains content about an early access feature.

GitHub Copilot usage REST API [alpha]

Learn how to use the REST API to access GitHub Copilot usage metrics for your organization or enterprise with a Copilot Business subscription.

Note: These endpoints are in alpha and are subject to change

You can use these endpoints to see a daily breakdown of aggregated Copilot usage metrics across your organization or enterprise members for the past 28 days, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day. The usage metrics are processed once per day for the previous day, and the response will only include data up until yesterday.

Get a summary of Copilot usage for organization members

get/orgs/{org}/copilot/usage

Gets a summary of Copilot usage across all organization members, with a breakdown by language and editor.

You must be an owner or billing manager of an organization with a Copilot Business subscription, or an owner or billing manager of its parent enterprise, to view Copilot usage metrics.

You can authenticate using an access token with the copilot, manage_billing:copilot, admin:org, admin:enterprise, or manage_billing:enterprise scopes to use this endpoint.

Headers

NameTypeDescription
acceptstringSetting to application/vnd.github+json is recommended.

Path parameters

NameTypeRequiredDescription
orgstringYesThe organization name. The name is not case sensitive.

Example Response

[
  {
    "day": "2023-10-15",
    "total_suggestions_count": 1000,
    "total_acceptances_count": 800,
    "total_lines_suggested": 1800,
    "total_lines_accepted": 1200,
    "total_active_users": 8,
    "breakdown": [
      {
        "language": "python",
        "editor": "vscode",
        "suggestions_count": 300,
        "acceptances_count": 250,
        "lines_suggested": 900,
        "lines_accepted": 700,
        "active_users": 5
      },
      {
        "language": "python",
        "editor": "jetbrains",
        "suggestions_count": 300,
        "acceptances_count": 200,
        "lines_suggested": 400,
        "lines_accepted": 300,
        "active_users": 2
      },
      {
        "language": "ruby",
        "editor": "vscode",
        "suggestions_count": 400,
        "acceptances_count": 350,
        "lines_suggested": 500,
        "lines_accepted": 200,
        "active_users": 4
      }
    ]
  },
  {
    "day": "2023-10-14",
    "total_suggestions_count": 800,
    "total_acceptances_count": 500,
    "total_lines_suggested": 1100,
    "total_lines_accepted": 700,
    "total_active_users": 8,
    "breakdown": [
      {
        "language": "python",
        "editor": "vscode",
        "suggestions_count": 300,
        "acceptances_count": 200,
        "lines_suggested": 600,
        "lines_accepted": 300,
        "active_users": 2
      },
      {
        "language": "python",
        "editor": "jetbrains",
        "suggestions_count": 300,
        "acceptances_count": 150,
        "lines_suggested": 300,
        "lines_accepted": 250,
        "active_users": 6
      },
      {
        "language": "ruby",
        "editor": "vscode",
        "suggestions_count": 200,
        "acceptances_count": 150,
        "lines_suggested": 200,
        "lines_accepted": 150,
        "active_users": 3
      }
    ]
  }
]

Code Samples

cURL

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/orgs/ORG/copilot/usage

JavaScript

// Octokit.js
// https://github.com/octokit/core.js#readme
const octokit = new Octokit({
  auth: 'YOUR-TOKEN'
})

await octokit.request('GET /orgs/{org}/copilot/usage', {
  org: 'ORG',
  headers: {
    'X-GitHub-Api-Version': '2022-11-28'
  }
})

GitHub CLI

# GitHub CLI api
# https://cli.github.com/manual/gh_api

gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  /orgs/ORG/copilot/usage

Get a summary of Copilot usage for enterprise members

get/enterprises/{enterprise}/copilot/usage

Gets a summary of Copilot usage for members of all Copilot Business enabled organizations within the enterprise, with a breakdown by language and editor.

You must be an owner or billing manager of an enterprise with a Copilot Business subscription to view Copilot usage metrics.

You can authenticate using an access token with the copilot, manage_billing:copilot, admin:enterprise, or manage_billing:enterprise scopes to use this endpoint.

Headers

NameTypeDescription
acceptstringSetting to application/vnd.github+json is recommended.

Path parameters

NameTypeDescription
enterprisestringRequired. The slug version of the enterprise name. You can also substitute this value with the enterprise id.

Example Response

[
  {
    "day": "2023-10-15",
    "total_suggestions_count": 5000,
    "total_acceptances_count": 3000,
    "total_lines_suggested": 7000,
    "total_lines_accepted": 3500,
    "total_active_users": 15,
    "breakdown": [
      {
        "language": "python",
        "editor": "vscode",
        "suggestions_count": 3000,
        "acceptances_count": 2000,
        "lines_suggested": 3000,
        "lines_accepted": 1500,
        "active_users": 5
      },
      {
        "language": "python",
        "editor": "jetbrains",
        "suggestions_count": 1000,
        "acceptances_count": 500,
        "lines_suggested": 2000,
        "lines_accepted": 1000,
        "active_users": 5
      },
      {
        "language": "javascript",
        "editor": "vscode",
        "suggestions_count": 1000,
        "acceptances_count": 500,
        "lines_suggested": 2000,
        "lines_accepted": 1000,
        "active_users": 5
      }
    ]
  },
  {
    "day": "2023-10-14",
    "total_suggestions_count": 5200,
    "total_acceptances_count": 4900,
    "total_lines_suggested": 5500,
    "total_lines_accepted": 5200,
    "total_active_users": 15,
    "breakdown": [
      {
        "language": "python",
        "editor": "vscode",
        "suggestions_count": 3100,
        "acceptances_count": 3000,
        "lines_suggested": 3200,
        "lines_accepted": 3100,
        "active_users": 5
      },
      {
        "language": "python",
        "editor": "jetbrains",
        "suggestions_count": 1100,
        "acceptances_count": 1000,
        "lines_suggested": 1200,
        "lines_accepted": 1100,
        "active_users": 5
      },
      {
        "language": "javascript",
        "editor": "vscode",
        "suggestions_count": 1000,
        "acceptances_count": 900,
        "lines_suggested": 1100,
        "lines_accepted": 1000,
        "active_users": 5
      }
    ]
  }
]

Code samples

cURL

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/enterprises/ENTERPRISE/copilot/usage

JavaScript

// Octokit.js
// https://github.com/octokit/core.js#readme
const octokit = new Octokit({
  auth: 'YOUR-TOKEN'
})

await octokit.request('GET /enterprises/{enterprise}/copilot/usage', {
  enterprise: 'ENTERPRISE',
  headers: {
    'X-GitHub-Api-Version': '2022-11-28'
  }
})

GitHub CLI

# GitHub CLI api
# https://cli.github.com/manual/gh_api

gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  /enterprises/ENTERPRISE/copilot/usage

Response Schema

{
  "type": "array",
  "description": "Summary of Copilot usage for the last 28 days.",
  "items": {
    "type": "object",
    "description": "Summary of Copilot usage for the given day.",
    "properties": {
      "day": {
        "type": "string",
        "format": "date",
        "description": "The date for which the usage metrics are reported, in `YYYY-MM-DD` format."
      },
      "total_suggestions_count": {
        "type": "integer",
        "description": "The total number of Copilot suggestions shown to users for the day specified."
      },
      "total_acceptances_count": {
        "type": "integer",
        "description": "The total number of Copilot suggestions accepted by users for the day specified."
      },
      "total_lines_suggested": {
        "type": "integer",
        "description": "The total number of lines of code suggested by Copilot for the day specified."
      },
      "total_lines_accepted": {
        "type": "integer",
        "description": "The total number of suggested lines of code accepted by users for the day specified."
      },
      "total_active_users": {
        "type": "integer",
        "description": "The total number of users who were shown Copilot suggestions for the day specified."
      },
      "breakdown": {
        "type": "array",
        "description": "Breakdown of Copilot usage by language and editor",
        "nullable": true,
        "items": {
          "type": "object",
          "description": "Copilot usage by editor for this language",
          "additionalProperties": true,
          "properties": {
            "language": {
              "type": "string",
              "description": "The language in which suggestions were shown to users in the specified editor."
            },
            "editor": {
              "type": "string",
              "description": "The editor in which Copilot suggestions were shown to users for the specified language."
            },
            "suggestions_count": {
              "type": "integer",
              "description": "The number of Copilot suggestions shown to users for the language and editor specified for the day specified."
            },
            "acceptances_count": {
              "type": "integer",
              "description": "The number of Copilot suggestions accepted by users for the language and editor specified for the day specified."
            },
            "lines_suggested": {
              "type": "integer",
              "description": "The number of lines of code suggested by Copilot for the language and editor specified for the day specified."
            },
            "lines_accepted": {
              "type": "integer",
              "description": "The number of lines of suggested code accepted by users for the language and editor specified for the day specified."
            },
            "active_users": {
              "type": "integer",
              "description": "The number of users who were shown Copilot suggestions for the language and editor specified for the day specified."
            }
          }
        }
      }
    }
  }
}