Meteroid 0.28.0

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

Meteroid .NET SDK

The official C# / .NET SDK for Meteroid, the open-source billing and pricing platform. Meteroid manages subscriptions, usage-based billing and metering, invoicing and revenue analytics; this library calls its REST API and verifies its webhooks, against Meteroid Cloud (https://api.meteroid.com) or a self-hosted instance.

Website · Documentation · API reference · Meteroid on GitHub

Install

dotnet add package Meteroid

Targets .NET 8, trimming and native AOT safe. Every method of the API is listed in api.md.

Usage

using Meteroid;

using var client = new MeteroidClient("your-api-key");

var addOn = await client.AddOns.RetrieveAsync("addon_id");
Console.WriteLine(addOn);

new MeteroidClient() reads the key from METEROID_API_KEY, and METEROID_BASE_URL overrides the base URL; what you pass, in the constructor or in MeteroidClientOptions, wins. The default base URL is https://api.meteroid.com. Create one client and reuse it: it is thread-safe and pools connections. To send requests through your own HttpClient, pass it first: new MeteroidClient(httpClient, "your-api-key").

Resources hang off the client as properties. Every method is async and takes an optional RequestOptions (headers, timeout, retries, idempotency key) and a CancellationToken. Models are records with init properties, compared by value:

using Meteroid.Models;

var onboardingLinkResponse = await client.Connect.CreateOnboardingLinkAsync("id", new CreateOnboardingLinkRequest { RedirectUrl = "redirect_url" });

Properties this SDK version does not know are kept in AdditionalProperties and sent back. Unions are abstract records to match on, and enums keep unknown values too (IsKnown); switch on status.Value with the Status.Values constants.

Errors

Everything the SDK throws derives from MeteroidException:

try
{
    await client.AddOns.RetrieveAsync("addon_id");
}
catch (NotFoundException e)
{
    Console.WriteLine($"{e.StatusCode} {e.RequestId}: {e.Error}");
}
catch (ApiTimeoutException) { /* no response in time, after the retries */ }
catch (ApiConnectionException) { /* the API could not be reached */ }

Error responses are ApiExceptions, as a subclass per status (BadRequestException, UnauthorizedException, NotFoundException, RateLimitException, ServerErrorException...), with the raw Body, the Headers, and Error: the body parsed as the error model the operation declares for the status, else a JsonElement. GetError<T>() parses it as any model. A successful response the SDK cannot read throws an ApiDecodeException.

Retries and timeouts

Connection errors, timeouts, 408, 429 and 5xx responses are retried twice with jittered backoff (0.5s, then 1s), honoring Retry-After and retry-after-ms up to a minute (the backoff otherwise), when the request is idempotent or carries an Idempotency-Key. Each attempt times out after 60 seconds.

var client = new MeteroidClient(options: new() { MaxRetries = 5, Timeout = TimeSpan.FromSeconds(20) });
await client.AddOns.RetrieveAsync("addon_id", requestOptions: new RequestOptions { MaxRetries = 0, Timeout = TimeSpan.FromSeconds(5) });

Pagination

The method of a paginated operation returns a pager. await it for the first page, which has the properties of the response body, the page's Items, HasNextPage and GetNextPageAsync(); await foreach over it (or over a page) yields every item, fetching the pages as it goes:

var page = await client.AddOns.ListAsync();
Console.WriteLine(page.PaginationMeta);
foreach (var addOn in page.Items)
{
    Console.WriteLine(addOn);
}
if (page.HasNextPage)
{
    page = await page.GetNextPageAsync();
}

await foreach (var addOn in client.AddOns.ListAsync())
{
    Console.WriteLine(addOn);
}

await foreach (var each in client.AddOns.ListAsync().AsPagesAsync())
{
    Console.WriteLine(each.Items.Count);
}

page.Body is the decoded body itself, with the properties a paging member (Items, Body, HasNextPage...) shadows on the page. The CancellationToken of the call also cancels the requests of the following pages; WithCancellation(token) adds one to an enumeration.

Raw responses

WithRawResponse returns the status and headers with the decoded body:

var response = await client.AddOns.WithRawResponse.RetrieveAsync("addon_id");
Console.WriteLine($"{response.StatusCode} {response.RequestId}");

Tests

IMeteroidClient and an interface per resource let you substitute a fake. Each call is an Activity of the Meteroid ActivitySource, for OpenTelemetry.

Generated by perseid.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  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
0.28.0 0 10/7/2026
0.27.1 36 10/6/2026
0.27.0 39 10/6/2026