Gandi 0.0.0-alpha4

This is a prerelease version of Gandi.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Gandi --version 0.0.0-alpha4                
NuGet\Install-Package Gandi -Version 0.0.0-alpha4                
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="Gandi" Version="0.0.0-alpha4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gandi --version 0.0.0-alpha4                
#r "nuget: Gandi, 0.0.0-alpha4"                
#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.
// Install Gandi as a Cake Addin
#addin nuget:?package=Gandi&version=0.0.0-alpha4&prerelease

// Install Gandi as a Cake Tool
#tool nuget:?package=Gandi&version=0.0.0-alpha4&prerelease                

Gandi

NuGet GitHub Workflow Status Testspace Coveralls

.NET REST client for the Gandi v5 API

This library allows you to create, read, update, and delete LiveDNS DNS records in your Gandi domains.

It's similar to G6.GandiLiveDns, but it's compatible with both Personal Access Token and API Key authentication, public types have interfaces so you can mock and actually test your dependent code, and it's compatible with a wider variety of runtimes.

  1. Prerequisites
  2. Installation
  3. Configuration
  4. Usage

Prerequisites

  • .NET runtime compatible with .NET Standard 2.0
    • .NET 5 or later
    • .NET Core 2 or later
    • .NET Framework 4.6.2 or later
  • Gandi domain name
    • ✅ Domain must be using LiveDNS, the default for new domains (ns-*-*.gandi.net)
    • ❌ Classic DNS (*.dns.gandi.net) is incompatible; you will need to migrate to LiveDNS
    • ❌ External nameservers (with glue records) are incompatible; you will need to update the record on the external nameserver instead of on Gandi's nameservers

Installation

This library is available in the Gandi package on NuGet Gallery.

dotnet add package Gandi

Configuration

  1. Get a Gandi API authentication token, and pass it to the AuthToken property of IGandiClient. This token can be either an API Key or Personal Access Token.
    • If you already have a Gandi API Key, you can use it to authenticate this client to your Gandi account.
      • If your Gandi account doesn't already have an API Key, it's too late, you can't make one anymore.
      • If you don't remember your API Key, you can regenerate it using Account › Authentication options › Developer access › API key.
    • You can always create a Personal Access Token.
      1. Go to either User Settings or Organizations › ⚙ Manage.
      2. Click Create a token.
      3. If prompted, choose the organization which owns the domain whose DNS records you want to manage, then click Next.
      4. Choose a name and expiration period for the token.
      5. Choose whether the token will be allowed to access all domains in the organization, or just a subset of them.
      6. Allow permission to "Manage domain name technical configurations."
      7. Click Create.
      8. Copy the token text. Keep it somewhere safe, because Gandi won't show it to you again.
      9. Set a calendar reminder to notify you before this token expires. There is no way for Gandi to notify you or for clients to refresh or renew tokens, so you will have to repeat all of these steps when your token eventually expires.
      10. Click Done.
    • If you need to change the auth token of an existing GandiClient instance, for example if the old token expires and a new one is written to a configuration file that reloads on changes, you can set the IGandiClient.AuthToken property.
  2. Construct a new instance of GandiClient, passing the Personal Access Token or API Key to the constructor.
    using Gandi;
    
    using IGandiClient gandi = new GandiClient("<auth token>");
    
Advanced configuration
  • You can access the HttpClient instance used by GandiClient if you want to configure timeouts, extra request headers, or add requests or response filters.
  • If you want to provide your own HttpClient, you can pass it to the GandiClient(HttpClient?) constructor. Make sure the HttpClient's HttpMessageHandler inherits from IUnfuckedHttpHandler (one easy way to do this is for HttpClient to be an UnfuckedHttpClient) so that client request authentication filters and JSON serialization work correctly.

Usage

LiveDNS

Get a LiveDNS API client for your second-level/registered domain name using IGandiClient.LiveDns(string). This object has async methods on it that perform HTTP calls to Gandi's LiveDNS API.

var liveDns = gandi.LiveDns("mydomain.com");
Find DNS records

Return a list of all DNS records in the domain, optionally filtered by name or type (A, CNAME, etc). If no results are found, returns an empty enumeration.

var liveDns = gandi.LiveDns("mydomain.com");
IEnumerable<DnsRecord> allRecords = await liveDns.List();
IEnumerable<DnsRecord> cnames     = await liveDns.List(type: RecordType.CNAME);
IEnumerable<DnsRecord> www        = await liveDns.List(name: "www");
Get a DNS record

Return one DNS record in the domain with the given name and type, or null if it was not found.

DnsRecord? wwwRecord = await liveDns.Get(RecordType.A, "www");
Create or update a DNS record

Set a DNS record's value, automatically creating it if it didn't already exist, or modifying it if it already existed (upserting). To specify a record at the root/origin of your domain, pass @ as the name. The time to live is optional, defaults to 3 hours if you set it to null, and is clipped to the allowed range [5 minutes, 30 days]. You must supply at least one value for the record.

await liveDns.Set(new DnsRecord(RecordType.A, "www", TimeToLive.FromHours(1), "1.2.3.4"));
Delete a record

Remove a record with the given name and optionally the given type. If the type is not specified, records of all types with the given name are deleted. This method returns successfully even if the record did not exist, because either way it doesn't exist after the method completes, so it's in the desired state.

await liveDns.Delete(RecordTytpe.CNAME, "www");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.0.0-alpha5 19 3/11/2025
0.0.0-alpha4 66 3/9/2025
0.0.0-alpha3 39 3/8/2025
0.0.0-alpha2 161 3/6/2025
0.0.0-alpha1 162 3/6/2025
0.0.0-alpha0 280 3/5/2025