-
Notifications
You must be signed in to change notification settings - Fork 0
api reference REST Client
Phil Hennel edited this page Oct 20, 2025
·
1 revision
Complete API reference for the REST client used to interact with GitLab's REST API v4.
GitLabRestClient provides access to GitLab resources only available via REST API, including commits, file contents, and repository data.
Location: src/api/gitlabRestClient.ts
new GitLabRestClient(
baseUrl: string,
accessToken: string,
options?: {
timeout?: number;
retries?: number;
}
)Parameters:
-
baseUrl(string): GitLab instance URL -
accessToken(string): Authentication token -
options(object, optional):-
timeout(number): Request timeout in ms (default: 30000) -
retries(number): Max retry attempts (default: 3)
-
Example:
import { GitLabRestClient } from './api';
const client = new GitLabRestClient(
'https:--gitlab.com',
'glpat-xxxxxxxxxxxxxxxxxxxx',
{ timeout: 60000 }
);Make a GET request to the REST API.
Signature:
async get<T>(
endpoint: string,
params?: Record<string, any>
): Promise<T>Example:
const project = await client.get('-projects-123');Get all pages of a paginated endpoint.
Signature:
async getAll<T>(
endpoint: string,
params?: Record<string, any>
): Promise<T[]>Example:
const commits = await client.getAll(
'-projects-123-repository-commits'
);Get commits for a project.
Signature:
async getCommits(
projectId: string | number,
options?: {
ref?: string;
since?: string;
until?: string;
per_page?: number;
}
): Promise<Commit[]>Example:
const commits = await client.getCommits('123', {
ref: 'main',
per_page: 100
});Get branches for a project.
Example:
const branches = await client.getBranches('123');Get file contents from repository.
Example:
const readme = await client.getFile(
'123',
'README.md',
'main'
);Last Updated: 2025-10-20