N8N.Api 1.0.0

dotnet add package N8N.Api --version 1.0.0
                    
NuGet\Install-Package N8N.Api -Version 1.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="N8N.Api" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="N8N.Api" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="N8N.Api" />
                    
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 N8N.Api --version 1.0.0
                    
#r "nuget: N8N.Api, 1.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 N8N.Api@1.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=N8N.Api&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=N8N.Api&version=1.0.0
                    
Install as a Cake Tool

A strongly-typed .NET client for the n8n Public API, generated from the official OpenAPI specification. One typed interface per resource (IWorkflowApi, IExecutionApi, ITagsApi, IUserApi, ...)

Installation

dotnet add package N8N.Api

Setup

The simplest way to register the client is the AddN8NApi(baseUrl, apiKey) extension. It wires up the typed API clients and configures X-N8N-API-KEY authentication for you.

ASP.NET Core (Program.cs)

using N8N.Api.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddN8NApi(
    baseUrl: builder.Configuration["N8N:BaseUrl"]!,
    apiKey:  builder.Configuration["N8N:ApiKey"]!);

builder.Services.AddControllers();

var app = builder.Build();
app.MapControllers();
app.Run();

The same extension is available on IHostBuilder for generic hosts / workers:

var host = Host.CreateDefaultBuilder(args)
    .AddN8NApi(baseUrl: "https://n8n.example.com/api/v1/", apiKey: "<your api key>")
    .Build();

Advanced setup

If you need to customize the HttpClient (e.g. add Polly policies, change the token provider, or register custom JSON converters), drop down to the underlying AddApi / ConfigureApi extensions:

builder.Services.AddApi(options =>
{
    options.AddTokens(new ApiKeyToken(
        value: builder.Configuration["N8N:ApiKey"]!,
        header: ClientUtils.ApiKeyHeader.X_N_N_API_KEY,
        prefix: ""));

    options.AddApiHttpClients(
        client => client.BaseAddress = new Uri(builder.Configuration["N8N:BaseUrl"]!),
        builder => builder
            .AddRetryPolicy(2)
            .AddTimeoutPolicy(TimeSpan.FromSeconds(30)));
});
Extension Lives on Use when
AddN8NApi(baseUrl, apiKey) IServiceCollection / IHostBuilder You just need the basics
AddApi(options => ...) IServiceCollection You need to customize the HttpClient, token provider, or JSON options
ConfigureApi((ctx, services, options) => ...) IHostBuilder Same as above, but inside a generic host builder

Configuration (appsettings.json)

{
  "N8N": {
    "BaseUrl": "https://n8n.example.com/api/v1/",
    "ApiKey": "<your n8n api key>"
  }
}

Usage

Once registered, inject any of the I*Api interfaces into your services or controllers.

Example: workflow controller

using Microsoft.AspNetCore.Mvc;
using N8N.Api.Api;
using N8N.Api.Client;
using N8N.Api.Model;

[ApiController]
[Route("workflows")]
public class WorkflowsController(IWorkflowApi workflows) : ControllerBase
{
    [HttpGet]
    public async Task<ActionResult<WorkflowList>> List(CancellationToken ct)
    {
        var response = await workflows.WorkflowsGetAsync(
            active: new Option<bool>(true),
            cancellationToken: ct);

        // Ok() returns the deserialized 200 payload or throws if the response wasn't 2xx.
        return Ok(response.Ok());
    }

    [HttpGet("{id}")]
    public async Task<ActionResult<Workflow>> Get(string id, CancellationToken ct)
    {
        var response = await workflows.WorkflowsIdGetOrDefaultAsync(id, cancellationToken: ct);

        // *OrDefault variants return null instead of throwing on non-2xx.
        var workflow = response?.Ok();
        return workflow is null ? NotFound() : Ok(workflow);
    }

    [HttpPost("{id}/activate")]
    public async Task<IActionResult> Activate(string id, CancellationToken ct)
    {
        var response = await workflows.WorkflowsIdActivatePostAsync(id, cancellationToken: ct);
        return Ok(response.Ok());
    }
}

Response patterns

Every operation has two variants:

  • XxxAsync(...) — returns IXxxApiResponse. Call .Ok() to get the typed payload; it throws if the HTTP response wasn't successful.
  • XxxOrDefaultAsync(...) — returns IXxxApiResponse?. Returns null on failure instead of throwing. Useful for "not found" style flows.

Optional query/body parameters use Option<T> — pass default to omit, or new Option<T>(value) to send.

Regenerating the client

The client is regenerated from api/openapi.yaml via Generate.ps1. The script preprocesses the spec to strip PascalCase $ref-only aliases that collide with their lowercase originals (otherwise the C# generator skips emitting those model classes).

./Generate.ps1

Requires openapi-generator-cli on the PATH.

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
1.0.0 96 5/10/2026