Collaborators

Learn and practice the functionalities of collaborators in the GitHub API.

Overview

Collaborators are the users invited by the owner to help in software development. The read and write permissions mean that the collaborators can pull the contents of the repository, make the required changes, and push the content back. A repository owner sends a collaboration invite to the user they wish to collaborate with. This invite needs to be accepted within seven days, after which it expires. There’s no limit to the number of collaborators that can be added to a specific repository.

List the collaborators of a repository

Authenticated users with the push access can use this endpoint. Authentication can be done by providing the access token. The list of collaborators includes all the members who have access to the repository with the default permissions.

Request Parameter

Parameters

Type

Description

repository

String

The name of the repository whose collaborators are to be listed

The code below retrieves the list of collaborators of a repository:

Press + to interact
Please provide values for the following:
ACCESS_TOKEN
Not Specified...
USERNAME
Not Specified...
REPOSITORY
Not Specified...
const endpointUrl = 'https://api.github.com/repos/{{USERNAME}}/{{REPOSITORY}}/collaborators';
const headers = {
Authorization: 'token {{ACCESS_TOKEN}}',
Accept: 'application/vnd.github.v3+json',
};
const options = {
method: 'GET',
headers,
};
async function GetCollaborators() {
try {
const response = await fetch(endpointUrl, options);
printResponse(response);
} catch (error) {
printErrors(error);
}
};
GetCollaborators();

In case of successful execution of the above code, it will return a response code 200.

Let’s look at a brief explanation of the above code:

  • Line 1: We define the URL of the endpoint.
  • Lines 13–20: We define the async function that will call the defined endpoint.
    • Line 16: In case of a successful request, the response of the API call is printed by invoking the
...