Skip to content

Check whether a user is a repository member

GET /api/v5/repos/{owner}/{repo}/collaborators/{username}

This endpoint checks whether the specified user is a member of the specified repository, using the namespace address of the repository, the repository path, and the user name. It returns status code 204 if the user is a repository member and 404 otherwise.

Supported access tokens

  • AtomGit user access tokens

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes Namespace address of the repository (address path of the enterprise, organization, or individual)
repo path string Yes Repository path (path)
username path string Yes User name (username/login)
access_token query string Yes User authorization code

Response parameters

On success (the user is a repository member), the endpoint returns 204 No Content with an empty response body. If the user is not a repository member, it returns 404 Not Found with the following body:

Field Type Always returned Nullable Description
message string Yes No Error message; the value is 404 Not Found

Error responses

Callers need to know what a failure looks like in order to write error handling. The only business error response of this endpoint is "the user is not a repository member", which returns 404.

404 The user is not a repository member

{
  "message": "404 Not Found"
}

HTTP status codes

Status code Description
204 The user is a repository member (No Content, empty response body)
404 The user is not a repository member (Not Found)
401 Authentication required (Requires authentication)
403 Access denied (Forbidden)

Request example

Parameter notes

The placeholders in the example mean the following:

Replace <owner> with the namespace address of the repository (address path of the enterprise, organization, or individual); replace <repo> with the repository path (path); replace <username> with the user name (username/login); replace <token> with your AtomGit user access token.

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/collaborators/<username>?access_token=<token>' \
  -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch(
  "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/collaborators/<username>?access_token=<token>",
  {
    headers: {
      "Accept": "application/json",
    },
  }
);

if (response.status === 204) {
  console.log("The user is a repository member");
} else if (response.status === 404) {
  console.log("The user is not a repository member");
} else {
  throw new Error(`Request failed: ${response.status}`);
}

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/collaborators/<username>",
    params={"access_token": "<token>"},
    headers={"Accept": "application/json"},
    timeout=10,
)

if resp.status_code == 204:
    print("The user is a repository member")
elif resp.status_code == 404:
    print("The user is not a repository member")
else:
    resp.raise_for_status()

Response example

Status code: 204

The user is a repository member, and the response body is empty (No Content).

Status code: 404

The user is not a repository member:

{
  "message": "404 Not Found"
}

Error codes

Error code Description
204 The user is a repository member (No Content)
404 The user is not a repository member (Not Found)
401 Unauthenticated or invalid credentials (missing or invalid access token)
403 Access denied
429 Too many requests; rate limit triggered
500 Internal server error

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