NaturalApi 1.0.6

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

NaturalApi

Fluent API testing that actually reads like English

NaturalApi turns your API tests into sentences you can read aloud. No boilerplate. No ceremony. Just clarity.


Why another API library?

Because this...

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/users/1");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var user = JsonSerializer.Deserialize<User>(content);
Assert.AreEqual(200, (int)response.StatusCode);
Assert.IsNotNull(user);

…is the kind of code people write once, copy forever, and never want to look at again.

Now read this:

var user = await Api.For("/users/1")
    .UsingAuth("Bearer token")
    .Get()
    .ShouldReturn<User>();

That's not just cleaner...it's readable. It says exactly what it does. And when you come back to it six months later, you'll still know what it means.


Quick Start

dotnet add package NaturalApi
using NaturalApi;

// Simple GET request
var users = await Api.For("https://api.example.com/users")
    .Get()
    .ShouldReturn<List<User>>();

// POST with authentication
var newUser = await Api.For("/users")
    .UsingAuth("Bearer your-token")
    .Post(new { name = "John", email = "john@example.com" })
    .ShouldReturn<User>(status: 201);

Get started β†’


Documentation

Getting Started

Core Features

Advanced Topics

Reference

Design & Philosophy


The Core Grammar

Every test reads like this:

Api.For(endpoint)
   .WithHeaders(...)      // Optional
   .WithQueryParams(...)  // Optional
   .UsingAuth(...)        // Optional
   .<HttpVerb>(body)      // GET, POST, PUT, etc.
   .ShouldReturn<T>(...)  // Validate response

Or in practice:

await Api.For("/orders/123")
    .UsingAuth("Bearer token")
    .Get()
    .ShouldReturn<Order>(status: 200, body: o => o.Total > 0);

You can actually read that aloud. And it still compiles.

πŸ“š Learn More: See the complete Fluent Syntax Reference for all available methods and patterns.


Five things you can express in one line

// 1. Simple GET
await Api.For("/users").Get().ShouldReturn<List<User>>();

// 2. POST with validation
await Api.For("/users").Post(newUser).ShouldReturn<User>(status: 201);

// 3. Authenticated request
await Api.For("/protected").UsingAuth("Bearer token").Get();

// 4. Query parameters
await Api.For("/search").WithQueryParam("q", "api testing").Get();

// 5. Delete with assertion
await Api.For("/users/1").Delete().ShouldReturn(204);

Readable, predictable, and type-safe. Because testing APIs shouldn't feel like writing networking code.

πŸ”— Related: Learn about HTTP Verbs, Assertions, and Authentication for more advanced patterns.


License

MIT. Do what you want, just don't ruin the readability.


Contributing

Good ideas welcome. Over-engineering isn't. See our Contributing Guide for details.


Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 was computed.  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.6 194 11/26/2025
1.0.5 134 10/10/2025
1.0.4 154 10/10/2025
1.0.3 140 10/10/2025
1.0.2 154 10/10/2025

Initial release of NaturalApi - Fluent API testing that reads like English