.NET API reference

Every public type and member of the Sponsorkit .NET package, generated from the source and its XML doc comments.

On this page

The Sponsorkit NuGet package targets netstandard2.0 and net8.0. Everything public lives in the Sponsorkit namespace:

using Sponsorkit;
Terminal
dotnet add package Sponsorkit

Start with SponsorkitClient in your app and SponsorkitServer on your backend. For a guided tour, read the .NET guide; for the rules every SDK follows, see the error contract.

This reference is generated from the compiled assembly and its XML documentation comments by sdks/dotnet/scripts/gen-docs.sh.

Entry points#

TypeKindDescription
SponsorkitClientclassThe Sponsorkit client: reports what the current user has contributed to your GitHub Sponsors / Open Collective accounts, sends them to contribute, and helps you nag politely.
SponsorkitNagclassDecides when to show a "please support this project" message.
SponsorkitServerstatic classBackend helpers.

Options#

TypeKindDescription
CheckoutOptionsclassOptions for SponsorkitClient.OpenCheckoutAsync.
CheckoutUrlOptionsclassOptions for SponsorkitClient.CheckoutUrl.
NagOptionsclassOptions for SponsorkitClient.Nag.
SignInOptionsclassOptions for SponsorkitClient.SignInAsync.
SponsorkitMockclassMock-mode data for SponsorkitOptions.Mock.
SponsorkitOptionsclassConfiguration for SponsorkitClient.
VerifySessionOptionsclassOptions for SponsorkitServer.VerifySessionAsync: the target set your backend expects.

Results and data#

TypeKindDescription
CheckoutResultclassThe result of SponsorkitClient.OpenCheckoutAsync.
ContributionclassA sponsorship (GitHub) or order (Open Collective) to one of the configured targets.
ContributionResultclassWhat the current user has contributed to the configured targets.
IdentityclassOne of the supporter's signed-in provider accounts.
MoneyclassAn amount of money in minor units (cents).
SponsorEntityclassWho actually pays for a contribution: the supporter, or an organization they belong to.
SupporterclassThe signed-in supporter.
TierclassThe provider tier of a contribution.

Enums#

TypeKindDescription
CheckoutStatusenumThe outcome of SponsorkitClient.OpenCheckoutAsync.
SignInMethodenumHow SponsorkitClient.SignInAsync lets the supporter sign in.

Constants#

TypeKindDescription
ContributionKindsstatic classValues of Contribution.Kind.
ContributionStatusesstatic classValues of Contribution.Status.
Frequenciesstatic classContribution frequencies (Contribution.Frequency and checkout options).
Providersstatic classProvider identifiers used in targets, identities and contributions.
SponsorkitErrorCodesstatic classThe values of SponsorkitError.Code.

Errors#

TypeKindDescription
SponsorkitErrorexceptionThe exception type for every error Sponsorkit raises on purpose.

Interfaces#

TypeKindDescription
ISponsorkitStorageinterfaceA storage backend for the per-target-set state (session token, cache, nag counters).

Error codes#

Every error the SDK raises on purpose is a SponsorkitError whose Code is one of these strings. Invalid arguments throw the standard ArgumentException or ArgumentNullException, and cancelling a CancellationToken throws OperationCanceledException from GetFinancialContributionAsync, SponsorkitNag.DueAsync, SponsorkitServer.VerifySessionAsync and SignOutAsync; see errors & cancellation.

CodeConstantMeaning
invalid_configSponsorkitErrorCodes.InvalidConfigMissing or invalid configuration: no targets, a malformed target, an unknown mock preset, invalid checkout options, or (dev-time check) a target that does not exist.
disabledSponsorkitErrorCodes.DisabledSponsorkit is disabled through SPONSORKIT_DISABLE.
popup_blockedSponsorkitErrorCodes.PopupBlockedBrowser only; never thrown by the .NET SDK.
access_deniedSponsorkitErrorCodes.AccessDeniedThe supporter denied access at the provider.
invalid_stateSponsorkitErrorCodes.InvalidStateThe sign-in state expired or could not be verified.
provider_errorSponsorkitErrorCodes.ProviderErrorThe provider failed during sign-in.
invalid_codeSponsorkitErrorCodes.InvalidCodeThe API rejected the sign-in code exchange (400 invalid_code): the code is malformed or expired, or the PKCE verifier did not match.
cancelledSponsorkitErrorCodes.CancelledSign-in was abandoned or cancelled through its CancellationToken, or no paste-back code was entered.
timeoutSponsorkitErrorCodes.TimeoutSign-in did not complete within SponsorkitOptions.SignInTimeout (default 5 minutes).
network_errorSponsorkitErrorCodes.NetworkErrorDuring sign-in or SponsorkitServer.VerifySessionAsync, the API could not be reached or answered 5xx, 429 or an unexpected response.
session_invalidSponsorkitErrorCodes.SessionInvalidThe session token is invalid or expired.
targets_mismatchSponsorkitErrorCodes.TargetsMismatchThe session is bound to a different target set.