手足口不能吃什么食物| 双性恋是什么意思| 嘴歪是什么病的前兆| 二月份出生的是什么星座| 缱绻旖旎是什么意思| 观音菩萨是属什么生肖| 为什么医院都让喝雀巢奶粉| 狗可以吃什么| 云南有什么| 7月15日是什么节日| 吃什么不会胖| 男人脚底发热是什么病| 猪生肠是什么部位| 肾阴虚什么症状| 隐喻的意思是什么| 一带一路是指什么| 吃什么有助于排便| 什么情什么意| 柠檬水喝了有什么好处| 鸡胸是什么| 夵是什么意思| 双龙戏珠是什么意思| 张国立的老婆叫什么名字| 着床什么意思| 颈部淋巴结肿大是什么原因| 1947年属猪的是什么命| 营业执照什么时候年审| 美妙绝伦是什么意思| 印度人为什么用手抓饭吃| 高压偏低是什么原因造成的| 巴郎子是什么意思| 右小腿抽筋是什么原因| 埋线是什么| 小姑子是什么关系| 天台种什么植物好| 侄女结婚送什么礼物最好| 廉航是什么意思| 小儿咳嗽吃什么药| 血常规异常是什么意思| 已所不欲勿施于人是什么意思| 莳字五行属什么| 汗毛重的女人意味着什么| 白天咳嗽晚上不咳嗽是什么原因| 磕头虫吃什么| 拜金是什么意思| ect是什么检查| 什么情况下怀疑白血病| 70年的狗是什么命| 口腔检查挂什么科| 心电监护pr是什么意思| 黄瓜什么时候种| 狗的鼻子为什么是湿的| 睡觉梦到蛇是什么意思| 梦见大火烧房子是什么意思| 医学ace是什么意思| vd是什么| 什么弟什么兄| 糖尿病吃什么菜最好| 喝酒后胃疼吃什么药| positive是什么意思| 小鱼的尾巴有什么作用| 塑料袋是什么材质| 球迷是什么意思| 金蟾是什么| 男性感染支原体有什么症状| 什么是关键词| 七月十日是什么日子| 逗闷子是什么意思| 胰腺炎不能吃什么| 春天是什么样子的| 五谷指的是什么| 浅褐色是什么颜色| ppa是什么药| 心电图显示窦性心律是什么意思| 窦骁的父母是干什么的| 女性多吃什么滋补卵巢| 什么什么各异| 金不换是什么菜| 双相情感障碍是什么病| 虚有其表的意思是什么| 福禄安康是什么意思| 飒什么意思| 吃东西就吐是什么原因| 梦见苍蝇是什么预兆| 宫颈非典型鳞状细胞是什么意思| 靖五行属性是什么| 太阳鱼是什么鱼| 福德是什么意思| 幻和是什么意思| 金卡有什么好处和坏处| 止咳化痰吃什么药| 1984年属鼠五行属什么| 美籍华人是什么意思| 陆代表什么数字| 人乳头瘤病毒33型阳性是什么意思| 报销是什么意思| 智齿不拔有什么危害| 吃什么可以补胶原蛋白| 下雨为什么会打雷闪电| 梦见掉牙齿是什么征兆| 恶心想吐吃什么药好| 激素药是什么意思| 梦到黄鳝是什么意思| 尿里有结晶是什么原因| 现在买什么股票好| 痔疮坐浴用什么药效果好| 不完全性右束支阻滞是什么意思| 西游记什么时候拍的| 什么可以保护眼睛| 梦见打死蛇是什么预兆| 碳13是检查什么的| 什么石头最值钱| 初级会计什么时候拿证| 耵聍是什么意思| 有什么有什么| 什么叫熬夜| 什么药补血效果最好最快| 纳呆什么意思| 骨髓穿刺是检查什么病| 孔子是什么学派的创始人| 鸡皮肤用什么药膏最好| ad滴剂什么牌子好| 匿名是什么意思| t波改变是什么意思| 吃猪脑有什么好处和坏处| 嘴上有痣代表什么| 暴跳如雷是什么意思| 燕子进屋来有什么兆头| 李商隐被称为什么| 梦见自己升职了是什么预兆| 紫花地丁有什么功效| 高炮是什么| 明月几时有的下一句是什么| 功名利禄是什么意思| 前列腺液和精液有什么区别| 咳血是什么原因| 端午节干什么| rad是什么单位| 今年26岁属什么生肖| 睾丸痛吃什么消炎药| 郭德纲什么学历| 一树梨花压海棠什么意思| 拖鞋买什么材质的好| 心脏做什么检查最准确| 梦见一条小蛇是什么意思| 饭后呕吐是什么原因引起的| 一毛不拔指什么生肖| 左侧卵巢囊性结构什么意思| 1月24日什么星座| 儿童节吃什么| 什么茶解暑| 拔智齿需要注意什么| 医保是什么意思| 肝病看什么科室| 黑蝴蝶代表什么| 脉压差大是什么原因| 缺乏维生素b12的症状是什么| 平五行属什么| 尿道口长肉芽是什么| 儿童抗o高会引起什么病| 吃什么可以壮阳| 上什么环最好最安全伤害小| 旻字五行属什么| 女生做彩超是检查什么| 平躺头晕是什么原因| 嫌恶是什么意思| 淋巴结肿大看什么科| 梦见缝被子是什么意思| 微信为什么发不了视频| 胃痛可以吃什么| 杠杆是什么意思| 摇粒绒是什么面料| 弯的直的什么意思| x是什么品牌| 头疼喝什么药| 杭州灵隐寺求什么最灵| 胃胀吃什么药效果最好| 蚊子爱咬什么样的人| 复古是什么意思| 舌头起泡什么原因| 九死一生什么意思| 糖尿病早餐吃什么好| 消渴是什么意思| 一月7日是什么星座| 锲而不舍下一句是什么| 蒙蒙的什么| 朝鲜面是什么原料做的| 为什么会起湿疹| 黄历破屋是什么意思| 婚姻是爱情的坟墓是什么意思| 什么叫代孕| 马拉松是什么意思| 退化是什么意思| 佟丽娅是什么民族| 被蜜蜂蛰了有什么好处| 师范类是什么意思| 岳字五行属什么| 车前草有什么作用| 什么叫台风| 男生肚子疼是什么原因| 哈尼是什么意思| 脂肪瘤吃什么药可以消除| 一什么石头| 新生儿囟门什么时候闭合| 脸很黄是什么原因| 单核细胞比率偏高说明什么| 偶像包袱是什么意思| 肾病挂什么科| 法国铁塔叫什么| 古代内衣叫什么| 李什么名字好听| 盆腔少量积液是什么问题| 什么原因得湿疹| 怀孕排卵试纸显示什么| 甲肝戊肝是什么病| 96199是什么电话| 尖锐湿疣是什么样的| camouflage什么意思| 子宫纵隔什么意思| 斯文败类是什么意思| 肝肾两虚吃什么中成药| 男怕初一女怕十五是什么意思| 口缘字一半念什么| 汤去掉三点水念什么| 纵隔淋巴结转移是什么意思| 我流是什么意思| 小白加小白等于什么| 孕妇用什么驱蚊最安全| 什么上树全靠一张嘴| 什么的鱼| 孕妇吃什么好对胎儿好三个月前期| 田园生活是什么意思| 赤潮是什么| 什么人不能坐飞机| 耳朵疼吃什么药| 用什么方法可以戒酒| 阴道发臭是什么原因| 宫颈糜烂用什么药最好| bq是什么意思啊| 老年人吃什么钙片补钙好| 逸五行属什么| 神经官能症挂什么科| 10万个为什么| 周遭是什么意思| 脉弱是什么意思| 眉毛上长痣代表什么| 什么的舞台| 什么叫细胞| 莫逆是什么意思| 一个叉念什么| 暴饮暴食会得什么病| 长方形纸可以折什么| 心脏早博是什么意思| 精分是什么意思| 鲽鱼是什么鱼| 月经期间喝酒会有什么影响| 做梦吃酒席什么预兆| 野鸭吃什么| 平时血压高突然变低什么原因| 什么是手足口病| 什么叫糖化血红蛋白| 梦到自己结婚什么意思| 婴儿不睡觉是什么原因| 广州为什么叫花城| 百度
Skip to main content

故宫停售“俏格格娃娃” 已售出的一律退款召回

百度 但是,大众如何根据车架号判断是否召回,客服没有进一步说明。

Learn how to connect to the API, store data, and analyze usage trends.

Who can use this feature?

Organization owners, enterprise owners, and billing managers

GitHub Copilot Business or GitHub Copilot Enterprise

Introduction

You can use the REST API endpoints for Copilot metrics to see trends in how users are adopting GitHub Copilot. During a rollout of GitHub Copilot, it's useful to view these trends to check that people are using their assigned licenses, see which features people are using, and understand the effect of your company's enablement plan on developers.

The API includes:

  • Data for the last 28 days
  • Numbers of active users and engaged users
  • Breakdowns by language and IDE
  • The option to view metrics for an enterprise, organization, or team

This guide demonstrates how to query the API, store data, and analyze a trend for changes to the number of users per week. The examples in this guide use the endpoint for an organization, but you can adapt the examples to meet your needs.

About endpoint availability

Endpoints are available to get data for an enterprise, organization, organization team, or enterprise team on GitHub.com.

  • If you have a Copilot Business or Copilot Enterprise plan as part of a regular organization or enterprise, you can use the endpoints for an enterprise, an organization, or an organization team. You don't have access to enterprise teams unless you're enrolled in a preview.
  • If you use a dedicated enterprise for GitHub Copilot Business—an enterprise account without the ability to create organizations—you can use the endpoints for an enterprise or an enterprise team.

Note

The Copilot metrics endpoints are not available for GitHub Enterprise Cloud with data residency on GHE.com.

Prerequisites

1. Create a personal access token

For our example, to get metrics for an organization, we'll create a personal access token (classic) with the manage_billing:copilot scope. See Managing your personal access tokens.

If you're using another endpoint, you may need different scopes. See REST API endpoints for Copilot metrics.

2. Connect to the API

We will call the API from a script and save the response as a variable. We can then store the data externally and analyze trends in the data.

The following example uses the Octokit client for JavaScript. You can use other methods to call the API, such as cURL or the GitHub CLI.

Example

In this example:

  • Replace YOUR_TOKEN with your personal access token.
  • Replace YOUR_ORG with your organization name, such as octo-org.
JavaScript
import { Octokit } from "octokit";

Import Octokit

const octokit = new Octokit({
  auth: 'YOUR_TOKEN'
});
const org = 'YOUR_ORG';

Set your token and organization

/*
const team = 'YOUR_TEAM';
const enterprise = 'YOUR_ENTERPRISE';
const entTeam = 'YOUR_ENTERPRISE_TEAM';
*/

Set other variables if required for the endpoint you're using

async function orgMetrics() {
  const resp = await octokit.request(`GET /orgs/${org}/copilot/metrics`, {
    org: 'ORG',
    headers: {
      'X-GitHub-Api-Version': '2025-08-05'
    }
  });
  const copilotUsage = resp.data;
  console.log(copilotUsage);
  }

Call the API

orgMetrics();

Call the function

// Import Octokit
import { Octokit } from "octokit";

// Set your token and organization
const octokit = new Octokit({
  auth: 'YOUR_TOKEN'
});
const org = 'YOUR_ORG';

// Set other variables if required for the endpoint you're using
/*
const team = 'YOUR_TEAM';
const enterprise = 'YOUR_ENTERPRISE';
const entTeam = 'YOUR_ENTERPRISE_TEAM';
*/

// Call the API
async function orgMetrics() {
  const resp = await octokit.request(`GET /orgs/${org}/copilot/metrics`, {
    org: 'ORG',
    headers: {
      'X-GitHub-Api-Version': '2025-08-05'
    }
  });

  const copilotUsage = resp.data;

  console.log(copilotUsage);
  }

// Call the function
orgMetrics();

Run the script locally

To test the script locally, save the file as copilot.mjs, then run node copilot.mjs.

Important

The .mjs file type is important. The import { Octokit } statement may not work with a regular .js file.

In your terminal, you should see output with a JSON array like the following.

[
  {
    date: '2024-11-07',
    copilot_ide_chat: { editors: [Array], total_engaged_users: 14 },
    total_active_users: 28,
    copilot_dotcom_chat: { models: [Array], total_engaged_users: 4 },
    total_engaged_users: 28,
    copilot_dotcom_pull_requests: { total_engaged_users: 0 },
    copilot_ide_code_completions: { editors: [Array], total_engaged_users: 22 }
  },
...

3. Store the data

To analyze trends over longer than 28 days, you will need to:

  • Call the API daily, using a cron job or scheduled GitHub Actions workflow.
  • Store data locally or with a database service such as MySQL.
  • Query the data to identify trends over time.

Example

In this example we'll save the data to a local .json file. To do this, we will import some modules for working with files, and update the orgMetrics function to save the response data.

The function saves new data that is returned each day, without overwriting old data in the file.

New steps are annotated in bold.

JavaScript
import { Octokit } from "octokit";

Import Octokit

import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

Import modules for working with files

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

Declare variables for working with files

const octokit = new Octokit({
  auth: 'YOUR_TOKEN'
});
const org = 'YOUR_ORG';

Set your token and organization

async function orgMetrics() {
  const resp = await octokit.request(`GET /orgs/${org}/copilot/metrics`, {
    org: 'ORG',
    headers: {
      'X-GitHub-Api-Version': '2025-08-05'
    }
  });
  const copilotUsage = resp.data;

Call the API

  const dataFilePath = path.join(__dirname, 'copilotMetricsData.json');

Define the path to the local file where data will be stored

  let existingData = [];
  if (fs.existsSync(dataFilePath)) {
    const fileContent = fs.readFileSync(dataFilePath, 'utf8');
    existingData = JSON.parse(fileContent);
  }

Read existing data from the file, if it exists

  const newData = copilotUsage.filter(entry => !existingData.some(existingEntry => existingEntry.date === entry.date));

Filter out the new data that is not already in the existing data

  if (newData.length > 0) {
    existingData = existingData.concat(newData);

Append new data to the existing data

    fs.writeFileSync(dataFilePath, JSON.stringify(existingData, null, 2));
    console.log(`Saved ${newData.length} new entries.`);
  } else {
    console.log('No new data to save.');
  }
}

Save the updated data back to the file

orgMetrics();

Call the function

// Import Octokit
import { Octokit } from "octokit";

// **Import modules for working with files**
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

// **Declare variables for working with files**
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

// Set your token and organization
const octokit = new Octokit({
  auth: 'YOUR_TOKEN'
});

const org = 'YOUR_ORG';

// Call the API
async function orgMetrics() {
  const resp = await octokit.request(`GET /orgs/${org}/copilot/metrics`, {
    org: 'ORG',
    headers: {
      'X-GitHub-Api-Version': '2025-08-05'
    }
  });

  const copilotUsage = resp.data;

  // **Define the path to the local file where data will be stored**
  const dataFilePath = path.join(__dirname, 'copilotMetricsData.json');

  // **Read existing data from the file, if it exists**
  let existingData = [];
  if (fs.existsSync(dataFilePath)) {
    const fileContent = fs.readFileSync(dataFilePath, 'utf8');
    existingData = JSON.parse(fileContent);
  }

  // **Filter out the new data that is not already in the existing data**
  const newData = copilotUsage.filter(entry => !existingData.some(existingEntry => existingEntry.date === entry.date));

  // **Append new data to the existing data**
  if (newData.length > 0) {
    existingData = existingData.concat(newData);

    // **Save the updated data back to the file**
    fs.writeFileSync(dataFilePath, JSON.stringify(existingData, null, 2));
    console.log(`Saved ${newData.length} new entries.`);
  } else {
    console.log('No new data to save.');
  }
}

// Call the function
orgMetrics();

Run the script locally

After running the script with node copilot.mjs, you should have a new file in your directory called copilotMetricsData.json. The file should contain data from the API response.

If you run the script again tomorrow, it should only save data for one new day to the file.

You can work with the data from the API to identify trends over the last 28 days or, if you've stored data from previous API calls, over a longer period.

Example

In the following example, we update the orgMetrics function to extract the total and average number of active and engaged users per week. We could then use that data to track changes over time. This example uses the data returned directly from the API, and doesn't require stored data.

New steps are annotated in bold.

JavaScript
async function orgMetrics() {
  const resp = await octokit.request(`GET /orgs/${org}/copilot/metrics`, {
    org: 'ORG',
    headers: {
      'X-GitHub-Api-Version': '2025-08-05'
    }
  });
  const copilotUsage = resp.data;

Call the API

  let userTrends ={
    week1: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
    week2: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
    week3: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
    week4: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
  };

Create an object to store data for each week

 for (let i =0; i<copilotUsage.length; i++) {

Iterate over the data

    const week = Math.ceil((i+1)/7);

Determine the week number (1-4) based on the index

    userTrends[`week${week}`].days += 1;
    userTrends[`week${week}`].activeUsers += copilotUsage[i].total_active_users;
    userTrends[`week${week}`].engagedUsers += copilotUsage[i].total_engaged_users;
  }

Increment userTrends for the current week

 for (const week in userTrends) {
  userTrends[week].avgActiveUsers = (userTrends[week].activeUsers / userTrends[week].days).toFixed(2);
  userTrends[week].avgEngagedUsers = (userTrends[week].engagedUsers / userTrends[week].days).toFixed(2);
  }

Calculate the average number of active and engaged users per day for each week, rounded to two decimal places

  console.log(userTrends);
}

Output to the console

// Call the API
async function orgMetrics() {
  const resp = await octokit.request(`GET /orgs/${org}/copilot/metrics`, {
    org: 'ORG',
    headers: {
      'X-GitHub-Api-Version': '2025-08-05'
    }
  });

  const copilotUsage = resp.data;

  // **Create an object to store data for each week**
  let userTrends ={
    week1: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
    week2: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
    week3: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
    week4: {
      days:0,
      activeUsers:0,
      engagedUsers:0,
    },
  };

 // **Iterate over the data**
 for (let i =0; i<copilotUsage.length; i++) {
    // **Determine the week number (1-4) based on the index**
    const week = Math.ceil((i+1)/7);
    // **Increment userTrends for the current week**
    userTrends[`week${week}`].days += 1;
    userTrends[`week${week}`].activeUsers += copilotUsage[i].total_active_users;
    userTrends[`week${week}`].engagedUsers += copilotUsage[i].total_engaged_users;
  }

 // **Calculate the average number of active and engaged users per day for each week, rounded to two decimal places**
 for (const week in userTrends) {
  userTrends[week].avgActiveUsers = (userTrends[week].activeUsers / userTrends[week].days).toFixed(2);
  userTrends[week].avgEngagedUsers = (userTrends[week].engagedUsers / userTrends[week].days).toFixed(2);
  }

  // Output to the console
  console.log(userTrends);
}

Run the script locally

After running the script with node copilot.mjs, you should see output in your terminal like the following.

{
  week1: {
    days: 7,
    activeUsers: 174,
    engagedUsers: 174,
    avgActiveUsers: '24.86',
    avgEngagedUsers: '24.86'
  },
  week2: {
    days: 7,
    activeUsers: 160,
    engagedUsers: 151,
    avgActiveUsers: '22.86',
    avgEngagedUsers: '21.57'
  },
  week3: {
    days: 7,
    activeUsers: 134,
    engagedUsers: 123,
    avgActiveUsers: '19.14',
    avgEngagedUsers: '17.57'
  },
  week4: {
    days: 6,
    activeUsers: 143,
    engagedUsers: 132,
    avgActiveUsers: '23.83',
    avgEngagedUsers: '22.00'
  }
}
低血压吃什么调理 疳是什么意思 命里缺金取什么名字好 下眼袋大是什么原因引起的 ysl是什么品牌
英短蓝猫吃什么猫粮好 海豚吃什么食物 hcg什么时候开始下降 吃什么东西增强免疫力 过年吃什么
个性是什么意思 华国锋为什么辞职 公园里有什么有什么还有什么 过敏性咳嗽用什么药 在家里做什么能赚钱
蛇五行属什么 辣条吃多了有什么危害 血红蛋白是什么意思 骨龄挂什么科 水什么
现在最好的避孕方法是什么hcv7jop6ns1r.cn 家里为什么有蜈蚣hcv8jop4ns2r.cn 热感冒吃什么药好cj623037.com 什么是cdhcv9jop6ns8r.cn 细菌性阴道炎吃什么药好hcv9jop7ns2r.cn
光明会到底是干什么的ff14chat.com 心动过速吃什么药最好hcv8jop3ns1r.cn 检查有没有怀孕挂什么科hcv8jop5ns8r.cn 什么病会导致不来月经0297y7.com 吃不胖是什么原因hcv9jop2ns8r.cn
辞职是什么意思xinmaowt.com 美味佳肴是什么意思hcv9jop7ns4r.cn 手突然抖动是什么原因hcv9jop0ns8r.cn 经常放屁是什么原因造成的shenchushe.com 龙代表什么象征意义hcv8jop9ns9r.cn
什么的青年hcv9jop8ns0r.cn 姜什么时候种植最好hcv9jop1ns3r.cn 备孕前吃什么调理身体hcv9jop3ns9r.cn 拉泡泡屎是什么原因hcv9jop0ns5r.cn 孕吐喝什么水可以缓解xianpinbao.com
百度