GitLab.Client 2.0.0

dotnet add package GitLab.Client --version 2.0.0
                    
NuGet\Install-Package GitLab.Client -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GitLab.Client" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GitLab.Client" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="GitLab.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GitLab.Client --version 2.0.0
                    
#r "nuget: GitLab.Client, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GitLab.Client@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GitLab.Client&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=GitLab.Client&version=2.0.0
                    
Install as a Cake Tool

GitLab.Client

SDK .NET typé pour l’API REST v4 et l’API GraphQL de GitLab. GitLab.Client cible GitLab 19.x et versions ultérieures, avec GitLab 19.0 comme version minimale prise en charge.

Installation

dotnet add package GitLab.Client

Un seul package est nécessaire. Il contient la façade publique, les DTO, le route builder et le transport HTTP ; il n’existe pas de packages GitLab.Client complémentaires à installer.

Prérequis

Élément Valeur
Runtime .NET 10, net10.0
Langage C# 14
GitLab 19.0 ou version ultérieure
APIs REST v4 et GraphQL
Injection de dépendances Microsoft.Extensions.DependencyInjection

Un jeton GitLab est requis. Le SDK prend en charge les jetons personnels, OAuth Bearer et les jetons de job GitLab.

Démarrage rapide

using GitLab.Client.Abstractions;
using GitLab.Client.Models;

using Microsoft.Extensions.DependencyInjection;

ServiceCollection services = new();

services.AddGitLabClient(options =>
{
    options.AccessToken = Environment.GetEnvironmentVariable("GITLAB_TOKEN")
        ?? throw new InvalidOperationException("The GITLAB_TOKEN environment variable is required.");
});

await using ServiceProvider provider = services.BuildServiceProvider();

IGitLabClient gitLab = provider.GetRequiredService<IGitLabClient>();
GitLabProject project = await gitLab.Projects.GetAsync("group/project");

Console.WriteLine(project.WebUrl);

Pour une instance auto gérée, configurez l’adresse REST avec son slash final.

services.AddGitLabClient(options =>
{
    options.BaseAddress = new Uri("https://gitlab.example.com/api/v4/");
    options.AccessToken = Environment.GetEnvironmentVariable("GITLAB_TOKEN");
});

Une application peut aussi lier la section GitLab d’un IConfiguration existant.

builder.Services.AddGitLabClient(builder.Configuration);

Capacités principales

  1. Clients REST directs, DTO et requêtes typés pour les domaines GitLab, disponibles via IGitLabClient ou par injection d’une interface précise comme IProjectsClient.

  2. Pagination par IAsyncEnumerable<T> et annulation par CancellationToken sur les appels asynchrones.

  3. Exceptions GitLab typées pour l’authentification, les autorisations, les ressources absentes, la validation, les conflits, les limites de débit et les erreurs serveur.

  4. API GraphQL avec exécuteur de documents typés, multiplexage de documents de même forme et façade Work Items.

  5. Batch client asynchrone à concurrence bornée pour réunir des appels REST et GraphQL indépendants sans simuler un endpoint REST batch inexistant.

  6. Mappers purs pour composer localement des DTO déjà obtenus, sans I/O cachée.

Native AOT et génération de source

La bibliothèque est conçue pour Native AOT et le trimming sur .NET 10. Les contrats JSON reposent sur System.Text.Json généré à la compilation, sans sérialisation JSON par réflexion. Le binding de configuration et le câblage DI utilisent également des générateurs de source ou du code déterministe, sans scan d’assembly ni dynamic.

Pour exécuter un document GraphQL personnalisé, fournissez le JsonTypeInfo<T> produit par le contexte System.Text.Json généré dans votre application. Le contrat reste ainsi visible au compilateur AOT.

Documentation

Le README complet, les scénarios REST, GraphQL, batch et mappers sont disponibles dans le dépôt GitHub.

Les références GitLab officielles sont disponibles pour REST et GraphQL.

Licence

Distribué sous licence MIT.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 0 9/11/2026
1.0.0 57 9/8/2026