Skip to content

List the Users Followed by a Specified User

GET /api/v5/users/{username}/following

Lists the users that the specified user follows, returning an array of basic user information objects; results are paginated by page and per_page.

Access Token Support

  • AtomGit user access tokens

Anonymous Access Allowed

This endpoint allows anonymous access.

Request Parameters

Parameter Location Type Required Description
username path string Yes Username (username/login)
page query integer No Current page number, must be greater than 0; defaults to 1
per_page query integer No Number of items per page, must be greater than 0 and no more than 100; defaults to 30

Response Parameters

Field Type Always Returned Nullable Description
avatar_url string Yes Yes Avatar URL
events_url string No Yes Events list API URL; not returned by this endpoint
followers_url string Yes Yes Followers list API URL
following_url string No Yes Following list API URL; returned only when the object type is User
gists_url string No Yes Gists API URL; not returned by this endpoint
html_url string Yes Yes Page URL of the user or organization
id string Yes Yes Identifier of the user or organization
object_id string Yes Yes User object identifier
login string Yes Yes Username or organization path
member_role string No Yes Member role; not returned by this endpoint
name string Yes Yes User nickname or organization name
organizations_url string No Yes Organizations list API URL; not returned by this endpoint
received_events_url string No Yes Received events list API URL; not returned by this endpoint
remark string No Yes Enterprise remark name; not returned by this endpoint
repos_url string No Yes Repositories list API URL; not returned by this endpoint
starred_url string No Yes Starred repositories list API URL; not returned by this endpoint
subscriptions_url string No Yes Subscriptions list API URL; not returned by this endpoint
type string Yes No Object type: User means user, Organization means organization
url string Yes Yes Details API URL of the user or organization

Note: The response body is an array of the objects above; each array element may be a user (type is User) or an organization (type is Organization); organization elements do not return following_url.

Failure Responses

In addition to the success response, this endpoint returns the corresponding error status when authentication fails, parameters are invalid, the user does not exist, or rate limiting is triggered.

400 Parameter error

{
  "message": "page must be greater than 0",
  "status": 400
}

401 Unauthenticated

{
  "message": "Bad credentials",
  "status": 401
}

404 User does not exist or information is hidden

{
  "message": "Not Found",
  "status": 404
}

Note: When the target user has enabled personal information hiding and the requester is not that user, the endpoint returns 404.

HTTP Response Status Codes

Status Code Description
200 Success (OK)
400 Bad Request
401 Authentication required or invalid credentials (Unauthorized)
403 Forbidden
404 User does not exist or information is hidden (Not Found)
429 Too Many Requests
500 Internal Server Error

Request Example

Parameter Description

Replace <username> with the target user's username (username/login); replace <token> with your AtomGit user access token. This endpoint allows anonymous access and can also be called with a token.

cURL

curl -X GET 'https://api.atomgit.com/api/v5/users/<username>/following?page=1&per_page=30' \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
  "https://api.atomgit.com/api/v5/users/<username>/following?page=1&per_page=30",
  {
    headers: {
      "Accept": "application/json",
      "Authorization": "Bearer <YOUR-TOKEN>",
    },
  },
);

if (!response.ok) {
  throw new Error(`请求失败: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/users/<username>/following",
    params={"page": 1, "per_page": 30},
    headers={
        "Accept": "application/json",
        "Authorization": "Bearer <YOUR-TOKEN>",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response Example

Status code: 200

[
  {
    "avatar_url": "https://api.atomgit.com/avatar/octocat.png",
    "followers_url": "https://api.atomgit.com/api/v5/users/octocat/followers",
    "following_url": "https://api.atomgit.com/api/v5/users/octocat/following",
    "html_url": "https://api.atomgit.com/octocat",
    "id": "496",
    "object_id": "496",
    "login": "octocat",
    "name": "octocat",
    "type": "User",
    "url": "https://api.atomgit.com/api/v5/users/octocat"
  },
  {
    "avatar_url": "https://api.atomgit.com/avatar/gitcode-org.png",
    "followers_url": "https://api.atomgit.com/api/v5/orgs/gitcode-org/followers",
    "html_url": "https://api.atomgit.com/gitcode-org",
    "id": "137117",
    "object_id": "137117",
    "login": "gitcode-org",
    "name": "AtomGit 组织",
    "type": "Organization",
    "url": "https://api.atomgit.com/api/v5/orgs/gitcode-org"
  }
]

Error Codes

Error Code Description
400 Parameter error or the request cannot be parsed (e.g., invalid page / per_page)
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
403 Access forbidden
404 The user does not exist, or the user has enabled personal information hiding
429 Too many requests; rate limit triggered
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc