Cardspine SDKs for JavaScript, Python and C#
Typed clients for the v1 API, generated from the same OpenAPI document as the endpoint reference. Each is MIT licensed and works with a key on any plan.
Install
npm install cardspineFirst call
Each snippet reads your key from CARDSPINE_KEY, set as in the quickstart. With no key passed, a client reads CARDSPINE_API_KEY instead.
import { Cardspine } from 'cardspine'
const cardspine = new Cardspine({ apiKey: process.env.CARDSPINE_KEY })
const results = await cardspine.search({ game: 'pokemon', q: 'charizard 4/102' })
const product = await cardspine.getProduct(results.items[0].tcgplayerProductId)
const prices = await cardspine.getRawPrices(product.tcgplayerProductId)The key goes in the X-Api-Key header only. It never appears in a URL, an error message or a printed client, and the clients refuse redirects rather than send the key on. Run them on a server: a key shipped in a web page or an app can be read by whoever uses it.
What they handle
- Paging. Search pages follow the cursor where the API sets one, and otherwise walk page numbers up to the 1,000-result window.
- Batches. Product and price lookups take any number of ids, call 100 at a time and merge the answers. When a rate limit stops a run, you get what came back, the ids still pending and when to try again.
- The catalog download. The file is streamed and decompressed as it arrives, never held in memory whole, and the change feed picks up from the cursor it carries. See Catalog download.
- Limits. The client keeps the
X-RateLimit-*andX-Quota-*values from the latest response. See Limits and errors.
Errors and retries
An error answer is raised as a Cardspine error carrying the status, title, detail, code and any Retry-After, read from the problem details body. There are separate types for 401 and 403, 404, 410 (the change cursor is too old, so download the catalog again), 429, and no answer at all.
Reads are retried up to three times: on 429 and 503 after the Retry-After interval, and on other server errors and network failures with backoff. A Retry-After over 60 seconds, such as a spent monthly allowance, is not waited out. Writes are never retried.