Skip to main content
Nous publions des mises à jour fréquentes de notre documentation, et la traduction de cette page peut encore être en cours. Pour obtenir les informations les plus actuelles, consultez la documentation anglaise.

Nous avons récemment déplacé une partie de la documentation de l’API REST. Si vous ne trouvez pas ce que vous recherchez, vous pouvez essayer les nouvelles pages d’API REST Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks.

Pages

Utilisez l’API REST pour interagir avec des sites et des builds GitHub Pages.

Get a GitHub Enterprise Server Pages site

Compatible avec GitHub Apps

Paramètres pour « Get a GitHub Enterprise Server Pages site »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Codes d’état de la réponse HTTP pour « Get a GitHub Enterprise Server Pages site »

Code d’étatDescription
200

OK

404

Resource not found

Exemples de code pour « Get a GitHub Enterprise Server Pages site »

get/repos/{owner}/{repo}/pages
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages

Response

Status: 200
{ "url": "https://HOSTNAME/repos/github/developer.github.com/pages", "status": "built", "cname": "developer.github.com", "custom_404": false, "html_url": "https://developer.github.com", "source": { "branch": "master", "path": "/" }, "public": true, "https_certificate": { "state": "approved", "description": "Certificate is approved", "domains": [ "developer.github.com" ], "expires_at": "2021-05-22" }, "https_enforced": true }

Create a GitHub Enterprise Server Pages site

Compatible avec GitHub Apps

Configures a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages."

To use this endpoint, you must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. A token with the repo scope or Pages write permission is required. GitHub Apps must have the administration:write and pages:write permissions.

Paramètres pour « Create a GitHub Enterprise Server Pages site »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Paramètres du corps
Nom, Type, Description
build_typestring

The process in which the Page will be built. Possible values are "legacy" and "workflow".

Peut être: legacy, workflow

sourceobject

The source branch and directory used to publish your Pages site.

Nom, Type, Description
branchstringObligatoire

The repository branch used to publish your site's source files.

pathstring

The repository directory that includes the source files for the Pages site. Allowed paths are / or /docs. Default: /

Default: /

Peut être: /, /docs

Codes d’état de la réponse HTTP pour « Create a GitHub Enterprise Server Pages site »

Code d’étatDescription
201

Created

409

Conflict

422

Validation failed, or the endpoint has been spammed.

Exemples de code pour « Create a GitHub Enterprise Server Pages site »

post/repos/{owner}/{repo}/pages
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages \ -d '{"source":{"branch":"main","path":"/docs"}}'

Response

Status: 201
{ "url": "https://HOSTNAME/repos/github/developer.github.com/pages", "status": "built", "cname": "developer.github.com", "custom_404": false, "html_url": "https://developer.github.com", "source": { "branch": "master", "path": "/" }, "public": true, "https_certificate": { "state": "approved", "description": "Certificate is approved", "domains": [ "developer.github.com" ], "expires_at": "2021-05-22" }, "https_enforced": true }

Update information about a GitHub Enterprise Server Pages site

Compatible avec GitHub Apps

Updates information for a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages.

To use this endpoint, you must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. A token with the repo scope or Pages write permission is required. GitHub Apps must have the administration:write and pages:write permissions.

Paramètres pour « Update information about a GitHub Enterprise Server Pages site »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Paramètres du corps
Nom, Type, Description
cnamestring or null

Specify 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_enforcedboolean

Specify whether HTTPS should be enforced for the repository.

build_typestring

The process by which the GitHub Pages site will be built. workflow means that the site is built by a custom GitHub Actions workflow. legacy means that the site is built by GitHub when changes are pushed to a specific branch.

Peut être: legacy, workflow

sourceobject

Update the source for the repository. Must include the branch name and path.

Nom, Type, Description
branchstringObligatoire

The repository branch used to publish your site's source files.

pathstringObligatoire

The repository directory that includes the source files for the Pages site. Allowed paths are / or /docs.

Peut être: /, /docs

Codes d’état de la réponse HTTP pour « Update information about a GitHub Enterprise Server Pages site »

Code d’étatDescription
204

No Content

400

Bad Request

409

Conflict

422

Validation failed, or the endpoint has been spammed.

Exemples de code pour « Update information about a GitHub Enterprise Server Pages site »

put/repos/{owner}/{repo}/pages
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages \ -d '{"cname":"octocatblog.com","source":{"branch":"main","path":"/"}}'

Response

Status: 204

Delete a GitHub Enterprise Server Pages site

Compatible avec GitHub Apps

Deletes a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages.

To use this endpoint, you must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. A token with the repo scope or Pages write permission is required. GitHub Apps must have the administration:write and pages:write permissions.

Paramètres pour « Delete a GitHub Enterprise Server Pages site »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Codes d’état de la réponse HTTP pour « Delete a GitHub Enterprise Server Pages site »

Code d’étatDescription
204

No Content

404

Resource not found

409

Conflict

422

Validation failed, or the endpoint has been spammed.

Exemples de code pour « Delete a GitHub Enterprise Server Pages site »

delete/repos/{owner}/{repo}/pages
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages

Response

Status: 204

List GitHub Enterprise Server Pages builds

Compatible avec GitHub Apps

Paramètres pour « List GitHub Enterprise Server Pages builds »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Paramètres de requête
Nom, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

Codes d’état de la réponse HTTP pour « List GitHub Enterprise Server Pages builds »

Code d’étatDescription
200

OK

Exemples de code pour « List GitHub Enterprise Server Pages builds »

get/repos/{owner}/{repo}/pages/builds
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds

Response

Status: 200
[ { "url": "https://HOSTNAME/repos/github/developer.github.com/pages/builds/5472601", "status": "built", "error": { "message": null }, "pusher": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://HOSTNAME/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://HOSTNAME/users/octocat/followers", "following_url": "https://HOSTNAME/users/octocat/following{/other_user}", "gists_url": "https://HOSTNAME/users/octocat/gists{/gist_id}", "starred_url": "https://HOSTNAME/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://HOSTNAME/users/octocat/subscriptions", "organizations_url": "https://HOSTNAME/users/octocat/orgs", "repos_url": "https://HOSTNAME/users/octocat/repos", "events_url": "https://HOSTNAME/users/octocat/events{/privacy}", "received_events_url": "https://HOSTNAME/users/octocat/received_events", "type": "User", "site_admin": false }, "commit": "351391cdcb88ffae71ec3028c91f375a8036a26b", "duration": 2104, "created_at": "2014-02-10T19:00:49Z", "updated_at": "2014-02-10T19:00:51Z" } ]

Request a GitHub Enterprise Server Pages build

Compatible avec GitHub Apps

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.

Paramètres pour « Request a GitHub Enterprise Server Pages build »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Codes d’état de la réponse HTTP pour « Request a GitHub Enterprise Server Pages build »

Code d’étatDescription
201

Created

Exemples de code pour « Request a GitHub Enterprise Server Pages build »

post/repos/{owner}/{repo}/pages/builds
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds

Response

Status: 201
{ "url": "https://HOSTNAME/repos/github/developer.github.com/pages/builds/latest", "status": "queued" }

Get latest Pages build

Compatible avec GitHub Apps

Paramètres pour « Get latest Pages build »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Codes d’état de la réponse HTTP pour « Get latest Pages build »

Code d’étatDescription
200

OK

Exemples de code pour « Get latest Pages build »

get/repos/{owner}/{repo}/pages/builds/latest
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds/latest

Response

Status: 200
{ "url": "https://HOSTNAME/repos/github/developer.github.com/pages/builds/5472601", "status": "built", "error": { "message": null }, "pusher": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://HOSTNAME/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://HOSTNAME/users/octocat/followers", "following_url": "https://HOSTNAME/users/octocat/following{/other_user}", "gists_url": "https://HOSTNAME/users/octocat/gists{/gist_id}", "starred_url": "https://HOSTNAME/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://HOSTNAME/users/octocat/subscriptions", "organizations_url": "https://HOSTNAME/users/octocat/orgs", "repos_url": "https://HOSTNAME/users/octocat/repos", "events_url": "https://HOSTNAME/users/octocat/events{/privacy}", "received_events_url": "https://HOSTNAME/users/octocat/received_events", "type": "User", "site_admin": false }, "commit": "351391cdcb88ffae71ec3028c91f375a8036a26b", "duration": 2104, "created_at": "2014-02-10T19:00:49Z", "updated_at": "2014-02-10T19:00:51Z" }

Get GitHub Enterprise Server Pages build

Compatible avec GitHub Apps

Paramètres pour « Get GitHub Enterprise Server Pages build »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

build_idintegerObligatoire

Codes d’état de la réponse HTTP pour « Get GitHub Enterprise Server Pages build »

Code d’étatDescription
200

OK

Exemples de code pour « Get GitHub Enterprise Server Pages build »

get/repos/{owner}/{repo}/pages/builds/{build_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds/BUILD_ID

Response

Status: 200
{ "url": "https://HOSTNAME/repos/github/developer.github.com/pages/builds/5472601", "status": "built", "error": { "message": null }, "pusher": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://HOSTNAME/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://HOSTNAME/users/octocat/followers", "following_url": "https://HOSTNAME/users/octocat/following{/other_user}", "gists_url": "https://HOSTNAME/users/octocat/gists{/gist_id}", "starred_url": "https://HOSTNAME/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://HOSTNAME/users/octocat/subscriptions", "organizations_url": "https://HOSTNAME/users/octocat/orgs", "repos_url": "https://HOSTNAME/users/octocat/repos", "events_url": "https://HOSTNAME/users/octocat/events{/privacy}", "received_events_url": "https://HOSTNAME/users/octocat/received_events", "type": "User", "site_admin": false }, "commit": "351391cdcb88ffae71ec3028c91f375a8036a26b", "duration": 2104, "created_at": "2014-02-10T19:00:49Z", "updated_at": "2014-02-10T19:00:51Z" }

Create a GitHub Pages deployment

Compatible avec GitHub Apps

Create a GitHub Pages deployment for a repository.

Users must have write permissions. GitHub Apps must have the pages:write permission to use this endpoint.

Paramètres pour « Create a GitHub Pages deployment »

En-têtes
Nom, Type, Description
acceptstring

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

Paramètres de chemin d’accès
Nom, Type, Description
ownerstringObligatoire

The account owner of the repository. The name is not case sensitive.

repostringObligatoire

The name of the repository. The name is not case sensitive.

Paramètres du corps
Nom, Type, Description
artifact_urlstringObligatoire

The URL of an artifact that contains the .zip or .tar of static assets to deploy. The artifact belongs to the repository.

environmentstring

The target environment for this GitHub Pages deployment.

Default: github-pages

pages_build_versionstringObligatoire

A unique string that represents the version of the build for this deployment.

Default: GITHUB_SHA

oidc_tokenstringObligatoire

The OIDC token issued by GitHub Actions certifying the origin of the deployment.

Codes d’état de la réponse HTTP pour « Create a GitHub Pages deployment »

Code d’étatDescription
200

OK

400

Bad Request

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Exemples de code pour « Create a GitHub Pages deployment »

post/repos/{owner}/{repo}/pages/deployment
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/deployment \ -d '{"artifact_url":"https://downloadcontent/","environment":"github-pages","pages_build_version":"4fd754f7e594640989b406850d0bc8f06a121251","oidc_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlV2R1h4SUhlY0JFc1JCdEttemUxUEhfUERiVSIsImtpZCI6IjUyRjE5N0M0ODFERTcwMTEyQzQ0MUI0QTlCMzdCNTNDN0ZDRjBEQjUifQ.eyJqdGkiOiJhMWIwNGNjNy0zNzZiLTQ1N2QtOTMzNS05NTY5YmVjZDExYTIiLCJzdWIiOiJyZXBvOnBhcGVyLXNwYS9taW55aTplbnZpcm9ubWVudDpQcm9kdWN0aW9uIiwiYXVkIjoiaHR0cHM6Ly9naXRodWIuY29tL3BhcGVyLXNwYSIsInJlZiI6InJlZnMvaGVhZHMvbWFpbiIsInNoYSI6ImEyODU1MWJmODdiZDk3NTFiMzdiMmM0YjM3M2MxZjU3NjFmYWM2MjYiLCJyZXBvc2l0b3J5IjoicGFwZXItc3BhL21pbnlpIiwicmVwb3NpdG9yeV9vd25lciI6InBhcGVyLXNwYSIsInJ1bl9pZCI6IjE1NDY0NTkzNjQiLCJydW5fbnVtYmVyIjoiMzQiLCJydW5fYXR0ZW1wdCI6IjYiLCJhY3RvciI6IllpTXlzdHkiLCJ3b3JrZmxvdyI6IkNJIiwiaGVhZF9yZWYiOiIiLCJiYXNlX3JlZiI6IiIsImV2ZW50X25hbWUiOiJwdXNoIiwicmVmX3R5cGUiOiJicmFuY2giLCJlbnZpcm9ubWVudCI6IlByb2R1Y3Rpb24iLCJqb2Jfd29ya2Zsb3dfcmVmIjoicGFwZXItc3BhL21pbnlpLy5naXRodWIvd29ya2Zsb3dzL2JsYW5rLnltbEByZWZzL2hlYWRzL21haW4iLCJpc3MiOiJodHRwczovL3Rva2VuLmFjdGlvbnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwibmJmIjoxNjM5MDAwODU2LCJleHAiOjE2MzkwMDE3NTYsImlhdCI6MTYzOTAwMTQ1Nn0.VP8WictbQECKozE2SgvKb2FqJ9hisWsoMkYRTqfBrQfZTCXi5IcFEdgDMB2X7a99C2DeUuTvHh9RMKXLL2a0zg3-Sd7YrO7a2ll2kNlnvyIypcN6AeIc7BxHsTTnZN9Ud_xmEsTrSRGOEKmzCFkULQ6N4zlVD0sidypmXlMemmWEcv_ZHqhioEI_VMp5vwXQurketWH7qX4oDgG4okyYtPrv5RQHbfQcVo9izaPJ_jnsDd0CBA0QOx9InjPidtIkMYQLyUgJy33HLJy86EFNUnAf8UhBQuQi5mAsEpEzBBuKpG3PDiPtYCHOk64JZkZGd5mR888a5sbHRiaF8hm8YA","preview":false}'

Response

Status: 200
{ "status_url": "https://HOSTNAME/repos/github/developer.github.com/pages/deployments/4fd754f7e594640989b406850d0bc8f06a121251/status", "page_url": "developer.github.com" }