Points de terminaison d’API REST pour les abonnés
Utilisez l’API REST pour obtenir des informations sur les abonnés des utilisateurs authentifiés.
À propos de la gestion des abonnés
Si une URL de requête n’inclut pas de paramètre {username}, la réponse est destinée à l’utilisateur connecté (et vous devez transmettre des informations d’authentification avec votre demande). Des informations privées supplémentaires, telles que l'activation de l'authentification à deux facteurs, sont incluses lorsqu'un utilisateur est authentifié par le biais de l'authentification de base ou de l'authentification de base. Basic Authentication ou OAuth avec la portée user.
List followers of the authenticated user
Lists the people following the authenticated user.
Jetons d'accès granulaires pour «List followers of the authenticated user»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Followers" user permissions (read)
Paramètres pour «List followers of the authenticated user »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Par défaut: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Par défaut: |
Codes d’état de réponse HTTP pour «List followers of the authenticated user »
| Code de statut | Description |
|---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
Exemples de code pour «List followers of the authenticated user »
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/user/followersResponse
Status: 200[
{
"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
}
]List the people the authenticated user follows
Lists the people who the authenticated user follows.
Jetons d'accès granulaires pour «List the people the authenticated user follows»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Followers" user permissions (read)
Paramètres pour «List the people the authenticated user follows »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Par défaut: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Par défaut: |
Codes d’état de réponse HTTP pour «List the people the authenticated user follows »
| Code de statut | Description |
|---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
Exemples de code pour «List the people the authenticated user follows »
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/user/followingResponse
Status: 200[
{
"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
}
]Check if a person is followed by the authenticated user
Jetons d'accès granulaires pour «Check if a person is followed by the authenticated user»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Followers" user permissions (read)
Paramètres pour «Check if a person is followed by the authenticated user »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
username string RequisThe handle for the GitHub user account. |
Codes d’état de réponse HTTP pour «Check if a person is followed by the authenticated user »
| Code de statut | Description |
|---|---|
204 | if the person is followed by the authenticated user |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | if the person is not followed by the authenticated user |
Exemples de code pour «Check if a person is followed by the authenticated user »
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/user/following/USERNAMEif the person is followed by the authenticated user
Status: 204Follow a user
Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."
OAuth app tokens and personal access tokens (classic) need the user:follow scope to use this endpoint.
Jetons d'accès granulaires pour «Follow a user»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Followers" user permissions (write)
Paramètres pour «Follow a user »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
username string RequisThe handle for the GitHub user account. |
Codes d’état de réponse HTTP pour «Follow a user »
| Code de statut | Description |
|---|---|
204 | No Content |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
Exemples de code pour «Follow a user »
Exemple de requête
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/user/following/USERNAMEResponse
Status: 204Unfollow a user
OAuth app tokens and personal access tokens (classic) need the user:follow scope to use this endpoint.
Jetons d'accès granulaires pour «Unfollow a user»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Followers" user permissions (write)
Paramètres pour «Unfollow a user »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
username string RequisThe handle for the GitHub user account. |
Codes d’état de réponse HTTP pour «Unfollow a user »
| Code de statut | Description |
|---|---|
204 | No Content |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Exemples de code pour «Unfollow a user »
Exemple de requête
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/user/following/USERNAMEResponse
Status: 204List followers of a user
Lists the people following the specified user.
Jetons d'accès granulaires pour «List followers of a user»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Tokens d’accès personnel à granularité fine
Le token à granularité fine ne nécessite aucune autorisation.
Ce point de terminaison peut être utilisé sans authentification ou si seules les ressources publiques sont demandées.
Paramètres pour «List followers of a user »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
username string RequisThe handle for the GitHub user account. |
| Nom, Type, Description |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Par défaut: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Par défaut: |
Codes d’état de réponse HTTP pour «List followers of a user »
| Code de statut | Description |
|---|---|
200 | OK |
Exemples de code pour «List followers of a user »
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/users/USERNAME/followersResponse
Status: 200[
{
"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
}
]List the people a user follows
Lists the people who the specified user follows.
Jetons d'accès granulaires pour «List the people a user follows»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Tokens d’accès personnel à granularité fine
Le token à granularité fine ne nécessite aucune autorisation.
Ce point de terminaison peut être utilisé sans authentification ou si seules les ressources publiques sont demandées.
Paramètres pour «List the people a user follows »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
username string RequisThe handle for the GitHub user account. |
| Nom, Type, Description |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Par défaut: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Par défaut: |
Codes d’état de réponse HTTP pour «List the people a user follows »
| Code de statut | Description |
|---|---|
200 | OK |
Exemples de code pour «List the people a user follows »
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/users/USERNAME/followingResponse
Status: 200[
{
"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
}
]Check if a user follows another user
Jetons d'accès granulaires pour «Check if a user follows another user»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Tokens d’accès personnel à granularité fine
Le token à granularité fine ne nécessite aucune autorisation.
Ce point de terminaison peut être utilisé sans authentification ou si seules les ressources publiques sont demandées.
Paramètres pour «Check if a user follows another user »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
username string RequisThe handle for the GitHub user account. |
target_user string Requis |
Codes d’état de réponse HTTP pour «Check if a user follows another user »
| Code de statut | Description |
|---|---|
204 | if the user follows the target user |
404 | if the user does not follow the target user |
Exemples de code pour «Check if a user follows another user »
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/users/USERNAME/following/TARGET_USERif the user follows the target user
Status: 204