Cardspine 0.1.0

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

Cardspine

Typed client for the Cardspine trading card catalog API. .NET 8 or later, no dependencies beyond the framework.

dotnet add package Cardspine

Quickstart

using Cardspine;

using var cardspine = new CardspineClient(); // reads CARDSPINE_API_KEY, or pass the key

var results = await cardspine.SearchAsync(new SearchParams { Game = "pokemon", Q = "charizard 4/102" });
var product = await cardspine.GetProductAsync(results.Items[0].TcgplayerProductId);
Console.WriteLine($"{product.Name} {cardspine.RateLimit}");

The models (ProductV1, SearchResponseV1 and the rest) are generated from the OpenAPI document. The key is sent in the X-Api-Key header only. It never appears in URLs, exception messages or ToString(). Redirects are refused rather than followed with the key. To share an HttpClient, pass it as the second constructor argument, built on a handler with AllowAutoRedirect = false: the default handler follows redirects and forwards X-Api-Key to wherever they point.

Calls

Method Endpoint
GetMeAsync() GET /api/v1/me
ListGamesAsync(), GetGameAsync(game) GET /api/v1/games, GET /api/v1/games/{game}
ListSetsAsync(game, sort, release) GET /api/v1/games/{game}/sets
ListSetAliasesAsync(game, source) GET /api/v1/games/{game}/set-aliases
GetProductAsync(id) GET /api/v1/products/tcgplayer/{productId}
GetProductsAsync(ids) GET /api/v1/products/tcgplayer?ids= (up to 100)
GetAllProductsAsync(ids) the same, 100 ids per call, merged
ReplaceContentsAsync(id, edit) PUT /api/v1/products/tcgplayer/{productId}/contents
GetRawPricesAsync(id, filters) GET /api/v1/products/tcgplayer/{productId}/prices/raw
GetRawPricesBatchAsync(request) POST /api/v1/prices/raw (up to 100)
GetAllRawPricesAsync(ids, filters) the same, 100 ids per call, merged
SearchAsync(search), SearchPagesAsync(search) GET /api/v1/search
RecordSelectionAsync(selection) POST /api/v1/search/selections
GetChangesAsync(after, limit), ChangePagesAsync(after) GET /api/v1/changes
DownloadCatalogAsync(ifNoneMatch) GET /api/v1/catalog/download

Pages, batches and the catalog

await foreach (var page in cardspine.SearchPagesAsync(new SearchParams { Game = "pokemon", Sets = [604], Sort = "number", PageSize = 100 }))
    Console.WriteLine(page.Items.Count);

var result = await cardspine.GetAllProductsAsync(ids);
if (result.StoppedBy is { } limited)
    Console.WriteLine($"Rate limited; retry {result.Pending.Count} ids after {limited.RetryAfter}");

await using var download = await cardspine.DownloadCatalogAsync(savedEtag);
if (download is not null)
{
    await foreach (var item in download.ReadProductsAsync())
        Save(item);
    await foreach (var page in cardspine.ChangePagesAsync(after: download.ChangeCursor ?? 0))
    {
        Apply(page.Changes);
        SaveCursor(page.Cursor);
    }
}

SearchPagesAsync follows NextCursor where the API sets one, and otherwise walks page numbers up to the 1,000-result window. The catalog is streamed and decompressed as it arrives, never held in memory whole. The timeout covers a download only until its headers arrive, since the file can take minutes.

Errors, retries and limits

Error answers throw CardspineException with Status, Title, Detail, Type, Code, RetryAfter and RateLimit, parsed from the problem details body. Subclasses: CardspineAuthException (401, 403), CardspineNotFoundException (404), CardspineGoneException (410: the change cursor is too old, so download the catalog again and resume from its ChangeCursor), CardspineRateLimitException (429) and CardspineConnectionException (no answer).

Reads are retried up to 3 times: on 429 and 503 after the Retry-After interval, and on other 5xx and network failures with exponential backoff and jitter. A Retry-After over 60 seconds, such as a spent monthly allowance, is not waited out; the call throws at once. RecordSelectionAsync and ReplaceContentsAsync are never retried. cardspine.RateLimit holds the X-RateLimit-* and X-Quota-* values of the latest response.

new CardspineClient(new CardspineClientOptions
{
    ApiKey = "...",
    BaseUrl = "https://api.cardspine.com",
    ApiPath = "/api/v1",
    MaxRetries = 3,
    Timeout = TimeSpan.FromSeconds(30),
    MaxRetryAfter = TimeSpan.FromSeconds(60),
});

License

MIT

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.
  • net8.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 0 11/30/2026