Skip to main content
github.com/itemshop/sdk-go — no dependencies (just net/http), Go ≥ 1.23 (iter.Seq2 iterators). Every method takes a context.Context and returns (result, error).

Installation

Storefront (no key)

  • Checkout.Create fills in consents.legalVersion from Shop.Legal.Version and always sends an Idempotency-Key (generated or input.IdempotencyKey), so a retry after a dropped connection never creates a second order. The Turnstile token is optional.
  • A cart has 1–20 lines (Items); two or more form one payment group (GroupID, OrderIDs in the result), more than 20 → CART_TOO_LARGE. The old OrderIDFromReturnURL / Orders.Status serve pre-3.0 orders only.
  • Vouchers.Redeem is not retried (except on 429).
  • Widgets: sf.Widgets.RecentPurchases, TopSpenders, MonthlyGoal, OnlinePlayers — switched off by the owner they return empty results, not an error.
  • nullable fields in response types are pointers.

API client (with a key)

Services: Shops, Servers, Products, PaymentMethods, PaymentErrors, Blacklist, Discounts, Vouchers, Stats, Uploads, Orders plus the hand-written Site, Templates, Workspace, Agents, Skills. Workspace tokens need a panel session — with an API key you get 401/403. For an endpoint without a method: client.Do(ctx, "GET", "/api/v2/…", nil, &out). Optional fields in api.* types are pointers — helpers itemshop.String/Bool/Float/Int/Ptr.

Errors

Every failure is an *itemshop.Error (the storefront package uses the same type):
SDK codes: BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT, VALIDATION_FAILED, RATE_LIMITED, SERVER_ERROR, NETWORK_ERROR, TIMEOUT, ABORTED… — the same as in the TypeScript SDK.

Retries, timeouts, idempotency

  • 2 retries by default (WithMaxRetries), backoff 300 ms·2ⁿ (max 5 s) with jitter; Retry-After replaces the delay.
  • GET/HEAD and requests carrying an Idempotency-Key (Orders.Create, Checkout.Create, itemshop.WithIdempotencyKey) are retried on network errors, timeouts and 408/425/429/500/502/503/504.
  • Other writes — only on 429.
  • WithTimeout limits one attempt (30 s default); the context bounds the whole call including retries.
  • Options: WithBaseURL (or $ITEMSHOP_API_BASE), WithHTTPClient, WithUserAgent, WithLocale, WithHeader.

Webhooks

The backend sends no signed webhooks to shop owners (notifications go to Discord — see Webhooks), so the SDK has no signature verifier.

Storefront API

The endpoints under the SDK.

Errors and limits

Error codes and rate limits.