Metron.Api 0.1.0

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

Metron.Api

A C# client library for the Metron comic book database API, targeting .NET 10.

  • Covers the full API surface: arcs, characters, creators, credits, imprints, issues, publishers, series, series types, teams, universes, variants, roles, plus the authenticated-user resources (collection, pull list, reading list, wish list).
  • Implements the dual rate limits (burst + sustained) described in Metron's RATELIMIT.md: tracks the X-RateLimit-* response headers, throttles proactively before either counter would be exhausted, and honors Retry-After on a 429 with bounded retries.
  • Authenticates with a bearer API token.

Installation

dotnet add package Metron.Api

Or reference the project directly, or build and pack it yourself:

dotnet pack src/Metron.Api/Metron.Api.csproj

Usage

using Metron.Api;
using Metron.Api.Filters;

using var client = new MetronClient(new MetronClientOptions
{
    ApiToken = "your-metron-api-token",
});

var arc = await client.Arc.GetAsync(42);

await foreach (var issue in client.Issue.ListAllAsync(new IssueFilter { SeriesId = 7 }))
{
    Console.WriteLine(issue.Number);
}

// Latest known rate-limit snapshot, updated after every request.
Console.WriteLine(client.RateLimitStatus?.BurstRemaining);

MetronClientOptions also accepts BaseAddress, UserAgent, MaxRetryAttempts (default 3), and an optional TransportHandler for tests or custom HttpMessageHandler pipelines.

Writes

All create/update/partial-update calls are sent as multipart/form-data, since several Metron resources (arc, character, creator, imprint, publisher, team, universe) don't accept a JSON body:

var created = await client.Arc.CreateAsync(new Arc { Name = "Infinity Gauntlet" });
await client.Arc.PartialUpdateAsync(created.Id!.Value, new PatchedArc { Desc = "..." });

Errors

Non-success responses throw MetronApiException (status code + the API's detail message). A request still throttled after MaxRetryAttempts retries throws MetronRateLimitException (carries RetryAfter and the last known RateLimitStatus).

Project layout

src/Metron.Api/
  MetronClient.cs, MetronClientOptions.cs   Facade + options
  Http/                                      Rate-limit handler/tracker, multipart & query builders
  Exceptions/                                MetronApiException, MetronRateLimitException
  Models/Generated/, Filters/                Generated from the OpenAPI schema (see below)
  Models/PagedResult.cs, CollectionStats.cs  Hand-written models
  Resources/                                 One client per resource group (Arc, Issue, Series, ...)
tools/codegen/generate_models.py             Regenerates Models/Generated and Filters
tests/Metron.Api.Tests/                      xUnit tests

Regenerating models

Models/Generated/*.cs and Filters/*.cs are generated from Metron Comicbook Database.yaml (the OpenAPI schema at the repo root) and committed to the repo. Re-run the generator whenever the schema changes:

python3 tools/codegen/generate_models.py

Requires Python 3 with PyYAML (pip install pyyaml). The script also has its own test suite (python3 -m unittest discover -s tools/codegen) and a --check mode that verifies the committed files match what generation would produce, without writing anything -- this runs in CI so a schema change nobody regenerated for gets caught automatically.

Running tests

dotnet test

Known limitations

  • Issue.Price is typed as string?. The schema allows either a plain decimal string (USD) or an {amount, currency} object for non-USD prices; only the plain-string form is supported directly through the typed model.
  • Every generated model property is nullable, regardless of the schema's required list, so read and write DTOs stay interchangeable without constructor boilerplate.
  • Retrying a request that carries a non-seekable file Stream (e.g. a manually attached image upload) after a 429 isn't supported; retries re-read buffered content, which requires seekable/re-readable request bodies.

License

GPL-3.0-or-later

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.
  • net10.0

    • No dependencies.

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.1.0 101 8/1/2026