Skip to content

Commit 3ba2be4

Browse files
authored
Update README.md
Add API connection details.
1 parent 9b62429 commit 3ba2be4

File tree

1 file changed

+50
-5
lines changed

1 file changed

+50
-5
lines changed

README.md

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,56 @@ Located in the `./samples` directory you'll find sample JSON and PBIX files use
2121

2222
3. Open the **Power Query Editor** by right clicking the `GH Copilot - Details` and selecting **Edit query**.
2323
4. Modify the **Source** step by clicking the settings icon, selecting your JSON file and clicking **OK**.
24-
![Image of a data source selector in Power Query Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Modify_JSON_source.png)
25-
5. Repeat steps 3 and 4 for the `GH Copilot - Summary` **Source**.
26-
6. Click **Close and Apply** in the top-left of the **Power Query Editor**.
27-
7. On the **Report View** page click **Refresh** to load the new data into your dashboard.
28-
8. **Happy Customizing!**
24+
![Image of a data source selector in Power Query Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Modify_JSON_source.png)
25+
6. Repeat steps 3 and 4 for the `GH Copilot - Summary` **Source**.
26+
7. Click **Close and Apply** in the top-left of the **Power Query Editor**.
27+
8. On the **Report View** page click **Refresh** to load the new data into your dashboard.
28+
9. **Happy Customizing!**
29+
30+
## Connect to Metrics API
31+
> Notes: The REST API provides metrics for the previous 28 days and is refreshed daily with the previous days data. This is currently in beta, so please ensure you are using the latest version of the [REST API](https://docs.github.com/en/rest/copilot/copilot-usage).
32+
33+
In order to connect we'll need to generate a token and link to your metrics data:
34+
1. Determine if you'll be using the `Enterprise`: **/enterprises/<ENTERPRISE>/copilot/usage** or `Organization`: **/orgs/<ORG>/copilot/usage** URL.
35+
2. Follow the instructions below to generate a token with permissions to access the API:
36+
[REST API endpoints for GitHub Copilot usage metrics - GitHub Docs](https://docs.github.com/en/rest/copilot/copilot-usage)
37+
4. Open the **Power Query Editor** by right clicking the `GH Copilot - Details` and selecting **Edit query**.
38+
5. Select **Advanced editor**.
39+
40+
![Image of Power Query Advanced Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Advanced_editor.png)
41+
6. Replace lines 1 and 2 with following, ensure to replace <YOUR-TOKEN> and <ORG> with your values.
42+
43+
**Organization**
44+
```powerquery
45+
let
46+
// Replace <YOUR-TOKEN> and <ORG> with your actual token and enterprise name.
47+
url = "https://api.github.com/orgs/<ORG>/copilot/usage",
48+
headers = [
49+
#"Accept" = "application/vnd.github+json",
50+
#"Authorization" = "Bearer <YOUR-TOKEN>",
51+
#"X-GitHub-Api-Version" = "2022-11-28"
52+
],
53+
Source = Json.Document(Web.Contents(url, [Headers=headers])),
54+
```
55+
**Enterprise**
56+
```powerquery
57+
let
58+
// Replace <YOUR-TOKEN> and <ENTERPRISE> with your actual token and enterprise name.
59+
url = "https://api.github.com/enterprises/<ENTERPRISE>/copilot/usage",
60+
headers = [
61+
#"Accept" = "application/vnd.github+json",
62+
#"Authorization" = "Bearer <YOUR-TOKEN>",
63+
#"X-GitHub-Api-Version" = "2022-11-28"
64+
],
65+
Source = Json.Document(Web.Contents(url, [Headers=headers])),
66+
```
67+
68+
7. Your Power Query will look something like this:
69+
![Image of Power Query Advanced Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Advanced_editor_query.png)
70+
8. Click **OK** to close the editor and select `Anonymous` authentication if prompted.
71+
9. Repeat steps 3 and 8 for the `GH Copilot - Summary` **Source**.
72+
10. Click **Close and Apply** in the top-left of the **Power Query Editor**.
73+
11. On the **Report View** page click **Refresh** to load the new data into your dashboard.
2974

3075

3176

0 commit comments

Comments
 (0)