The Wayback Machine - https://web.archive.org/web/20230105012527/https://docs.github.com/fr/rest/interactions/repos
Skip to main content
The REST API is now versioned. For more information, see "About API versioning."

Interactions de référentiel

L’API d’interactions de référentiel permet aux personnes disposant d’un accès propriétaire ou administrateur de restreindre temporairement le type d’utilisateur qui peut commenter, ouvrir des problèmes ou créer des demandes de tirage dans un référentiel public.

À propos de l’API d’interactions de référentiel

L’API d’interactions de référentiel permet aux personnes disposant d’un accès propriétaire ou administrateur de restreindre temporairement le type d’utilisateur qui peut commenter, ouvrir des problèmes ou créer des demandes de tirage dans un référentiel public. Lorsque des restrictions sont activées, seul le type spécifié d’utilisateur GitHub pourra participer aux interactions. Les restrictions expirent automatiquement après une durée définie. Voici plus d’informations sur les types d’utilisateurs GitHub :

  • Utilisateurs existants : Lorsque vous limitez les interactions aux existing_users, les nouveaux utilisateurs avec des comptes de moins de 24 heures qui n’ont pas déjà contribué et qui ne sont pas collaborateurs seront temporairement limités. dans le référentiel.
  • Contributeurs uniquement : Lorsque vous limitez les interactions aux contributors_only, les utilisateurs qui n’ont pas déjà contribué et qui ne sont pas collaborateurs sont temporairement limités. dans le référentiel.
  • Collaborateurs uniquement : lorsque vous limitez les interactions en choisissant collaborators_only, les utilisateurs qui ne sont pas des collaborateurs sont temporairement limités dans le référentiel.

Si une limite d’interaction est activée pour l’utilisateur ou l’organisation propriétaire du référentiel, la limite ne peut pas être modifiée pour le référentiel individuel. Utilisez plutôt des points de terminaison d’interaction utilisateur ou d’organisation pour modifier la limite d’interaction.

Get interaction restrictions for a repository

Fonctionne avec GitHub Apps

Shows which type of GitHub user can interact with this repository and when the restriction expires. If there are no restrictions, you will see an empty response.

Paramètres

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

Codes de statut de réponse HTTP

Code d’étatDescription
200

OK

Exemples de code

get/repos/{owner}/{repo}/interaction-limits
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/interaction-limits

Response

Status: 200
{ "limit": "collaborators_only", "origin": "repository", "expires_at": "2018-08-17T04:18:39Z" }

Set interaction restrictions for a repository

Fonctionne avec GitHub Apps

Temporarily restricts interactions to a certain type of GitHub user within the given repository. You must have owner or admin access to set these restrictions. If an interaction limit is set for the user or organization that owns this repository, you will receive a 409 Conflict response and will not be able to use this endpoint to change the interaction limit for a single repository.

Paramètres

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

Body parameters
Name, Type, Description
limitstringRequired

The type of GitHub user that can comment, open issues, or create pull requests while the interaction limit is in effect.

Can be one of: existing_users, contributors_only, collaborators_only

expirystring

The duration of the interaction restriction. Default: one_day.

Can be one of: one_day, three_days, one_week, one_month, six_months

Codes de statut de réponse HTTP

Code d’étatDescription
200

OK

409

Conflict

Exemples de code

put/repos/{owner}/{repo}/interaction-limits
curl \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/interaction-limits \ -d '{"limit":"collaborators_only","expiry":"one_day"}'

Response

Status: 200
{ "limit": "collaborators_only", "origin": "repository", "expires_at": "2018-08-17T04:18:39Z" }

Remove interaction restrictions for a repository

Fonctionne avec GitHub Apps

Removes all interaction restrictions from the given repository. You must have owner or admin access to remove restrictions. If the interaction limit is set for the user or organization that owns this repository, you will receive a 409 Conflict response and will not be able to use this endpoint to change the interaction limit for a single repository.

Paramètres

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

Codes de statut de réponse HTTP

Code d’étatDescription
204

No Content

409

Conflict

Exemples de code

delete/repos/{owner}/{repo}/interaction-limits
curl \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/interaction-limits

Response

Status: 204