Skip to main content
L’API REST est maintenant versionnée. Pour plus d’informations, consultez « À propos des versions de l’API ».

Rapports d'utilisation

Utilisez l’API REST pour créer et récupérer des exportations de rapports d’utilisation pour une entreprise.

List usage report exports

Note

This endpoint is in public preview and is subject to change.

Lists all usage report exports for an enterprise. The authenticated user must be an enterprise admin or billing manager.

Jetons d’accès affinés pour « List usage report exports »

Ce point de terminaison fonctionne avec les types de jetons précis suivants:

Le jeton précis doit avoir l’ensemble d’autorisations suivant:

  • "Enterprise administration" enterprise permissions (write)

Paramètres pour « List usage report exports »

En-têtes
Nom, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Paramètres de chemin d’accès
Nom, Type, Description
enterprise string Requis

The slug version of the enterprise name.

Codes d’état de la réponse HTTP pour « List usage report exports »

Code d’étatDescription
200

List of usage report exports

401

Requires authentication

403

Forbidden

404

Resource not found

500

Internal Error

503

Service unavailable

Exemples de code pour « List usage report exports »

Si vous accédez à GitHub à GHE.com, remplacez api.github.com par le sous-domaine dédié de votre entreprise à api.SUBDOMAIN.ghe.com.

Exemple de requête

get/enterprises/{enterprise}/settings/billing/reports
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/settings/billing/reports

List of usage report exports

Status: 200
{ "usage_report_exports": [ { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "report_type": "detailed", "start_date": "2024-01-01", "end_date": "2024-01-31", "status": "completed", "download_urls": [ "https://github.com/enterprises/github/metered_exports/1234" ], "created_at": "2024-01-15T10:30:00Z", "actor": "monalisa" }, { "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901", "report_type": "summarized", "start_date": "2024-01-01", "end_date": "2024-01-31", "status": "processing", "created_at": "2024-01-14T09:00:00Z", "actor": "monalisa" }, { "id": "c3d4e5f6-a7b8-9012-cdef-123456789012", "report_type": "premium_request", "start_date": "2024-01-01", "end_date": "2024-01-31", "status": "processing", "created_at": "2024-01-13T08:00:00Z", "actor": "octocat" } ] }

Create a usage report export

Note

This endpoint is in public preview and is subject to change.

Initiates the generation of a usage report export for an enterprise. The report will be processed asynchronously and can be downloaded once completed. The authenticated user must be an enterprise admin or billing manager.

Jetons d’accès affinés pour « Create a usage report export »

Ce point de terminaison fonctionne avec les types de jetons précis suivants:

Le jeton précis doit avoir l’ensemble d’autorisations suivant:

  • "Enterprise administration" enterprise permissions (write)

Paramètres pour « Create a usage report export »

En-têtes
Nom, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Paramètres de chemin d’accès
Nom, Type, Description
enterprise string Requis

The slug version of the enterprise name.

Paramètres du corps
Nom, Type, Description
report_type string Requis

The type of usage report to generate

Peut être: detailed, summarized, premium_request

start_date string Requis

The start date for the report in YYYY-MM-DD format

end_date string

The end date for the report in YYYY-MM-DD format. Defaults to today (UTC) if not provided.

send_email boolean

Whether to send an email notification to the requester when the report is ready. Defaults to false.

Default: false

Codes d’état de la réponse HTTP pour « Create a usage report export »

Code d’étatDescription
202

Report export request accepted

400

Bad Request

401

Requires authentication

403

Forbidden

404

Resource not found

500

Internal Error

503

Service unavailable

Exemples de code pour « Create a usage report export »

Si vous accédez à GitHub à GHE.com, remplacez api.github.com par le sous-domaine dédié de votre entreprise à api.SUBDOMAIN.ghe.com.

Exemple de requête

post/enterprises/{enterprise}/settings/billing/reports
curl -L \ -X POST \ -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/settings/billing/reports \ -d '{"report_type":"detailed","start_date":"2024-01-01","end_date":"2024-01-31"}'

Report export request accepted

Status: 202
{ "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "report_type": "detailed", "start_date": "2024-01-01", "end_date": "2024-01-31", "status": "completed", "download_urls": [ "https://github.com/enterprises/github/metered_exports/1234" ], "created_at": "2024-01-15T10:30:00Z", "actor": "monalisa" }

Get a usage report export

Note

This endpoint is in public preview and is subject to change.

Gets the status and details of a usage report export by ID. The authenticated user must be an enterprise admin or billing manager.

Jetons d’accès affinés pour « Get a usage report export »

Ce point de terminaison fonctionne avec les types de jetons précis suivants:

Le jeton précis doit avoir l’ensemble d’autorisations suivant:

  • "Enterprise administration" enterprise permissions (write)

Paramètres pour « Get a usage report export »

En-têtes
Nom, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Paramètres de chemin d’accès
Nom, Type, Description
enterprise string Requis

The slug version of the enterprise name.

report_id string Requis

The unique identifier (UUID) for the usage report export.

Codes d’état de la réponse HTTP pour « Get a usage report export »

Code d’étatDescription
200

Usage report export details

401

Requires authentication

403

Forbidden

404

Resource not found

500

Internal Error

503

Service unavailable

Exemples de code pour « Get a usage report export »

Si vous accédez à GitHub à GHE.com, remplacez api.github.com par le sous-domaine dédié de votre entreprise à api.SUBDOMAIN.ghe.com.

Exemple de requête

get/enterprises/{enterprise}/settings/billing/reports/{report_id}
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/settings/billing/reports/REPORT_ID

Usage report export details

Status: 200
{ "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "report_type": "detailed", "start_date": "2024-01-01", "end_date": "2024-01-31", "status": "completed", "download_urls": [ "https://github.com/enterprises/github/metered_exports/1234" ], "created_at": "2024-01-15T10:30:00Z", "actor": "monalisa" }