Skip to main content
Die REST-API verfügt jetzt über eine Versionskontrolle. Weitere Informationen findest du unter Informationen zur API-Versionsverwaltung.

REST-API-Endpunkte zum Blockieren von Benutzern

Verwende die REST-API, um blockierte Benutzer*innen zu verwalten.

Informationen zum Blockieren von Benutzern

Wenn eine Anforderungs-URL keinen {username}-Parameter enthält, gilt die Antwort für dendie angemeldeten Benutzerin (und Sie müssen Authentifizierungsinformationen mit Ihrer Anforderung übergeben). Zusätzliche private Informationen, z. B. ob eine Benutzer*in die Zwei-Faktor-Authentifizierung aktiviert hat, wird bei der Authentifizierung über OAuth mit dem user-Bereich eingeschlossen.

List users blocked by the authenticated user

List the users you've blocked on your personal account.

Differenzierte Zugriffstoken für "List users blocked by the authenticated user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • blocking:read

Parameter für „List users blocked by the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

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

Abfrageparameter
Name, type, BESCHREIBUNG
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Standard: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Standard: 1

HTTP-Antwortstatuscodes für „List users blocked by the authenticated user“

StatuscodeBESCHREIBUNG
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

Codebeispiele für „List users blocked by the authenticated user“

Beispiel für eine Anfrage

get/user/blocks
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/user/blocks

Response

Status: 200
[ { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } ]

Check if a user is blocked by the authenticated user

Returns a 204 if the given user is blocked by the authenticated user. Returns a 404 if the given user is not blocked by the authenticated user, or if the given user account has been identified as spam by GitHub.

Differenzierte Zugriffstoken für "Check if a user is blocked by the authenticated user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • blocking:read

Parameter für „Check if a user is blocked by the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

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

Pfadparameter
Name, type, BESCHREIBUNG
username string Erforderlich

The handle for the GitHub user account.

HTTP-Antwortstatuscodes für „Check if a user is blocked by the authenticated user“

StatuscodeBESCHREIBUNG
204

If the user is blocked

304

Not modified

401

Requires authentication

403

Forbidden

404

If the user is not blocked

Codebeispiele für „Check if a user is blocked by the authenticated user“

Beispiel für eine Anfrage

get/user/blocks/{username}
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/user/blocks/USERNAME

If the user is blocked

Status: 204

Block a user

Blocks the given user and returns a 204. If the authenticated user cannot block the given user a 422 is returned.

Differenzierte Zugriffstoken für "Block a user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • blocking:write

Parameter für „Block a user“

Header
Name, type, BESCHREIBUNG
accept string

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

Pfadparameter
Name, type, BESCHREIBUNG
username string Erforderlich

The handle for the GitHub user account.

HTTP-Antwortstatuscodes für „Block a user“

StatuscodeBESCHREIBUNG
204

No Content

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Codebeispiele für „Block a user“

Beispiel für eine Anfrage

put/user/blocks/{username}
curl -L \ -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/user/blocks/USERNAME

Response

Status: 204

Unblock a user

Unblocks the given user and returns a 204.

Differenzierte Zugriffstoken für "Unblock a user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • blocking:write

Parameter für „Unblock a user“

Header
Name, type, BESCHREIBUNG
accept string

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

Pfadparameter
Name, type, BESCHREIBUNG
username string Erforderlich

The handle for the GitHub user account.

HTTP-Antwortstatuscodes für „Unblock a user“

StatuscodeBESCHREIBUNG
204

No Content

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

Codebeispiele für „Unblock a user“

Beispiel für eine Anfrage

delete/user/blocks/{username}
curl -L \ -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/user/blocks/USERNAME

Response

Status: 204