cardspine
Typed client for the Cardspine trading card catalog API. Python 3.9 or later; its one dependency is httpx.
pip install cardspine
Quickstart
from cardspine import Cardspine
with Cardspine() as cardspine: # reads CARDSPINE_API_KEY, or pass the key
results = cardspine.search(game="pokemon", q="charizard 4/102")
product = cardspine.get_product(results["items"][0]["tcgplayerProductId"])
print(product["name"], cardspine.rate_limit)
Responses are plain dicts typed with TypedDict models generated from the OpenAPI document (cardspine.models). The key is sent in the X-Api-Key header only. It never appears in URLs, error messages or repr, and redirects are never followed with it, even on an http_client you pass in.
Calls
| Method | Endpoint |
|---|---|
me() |
GET /api/v1/me |
list_games(), get_game(game) |
GET /api/v1/games, GET /api/v1/games/{game} |
list_sets(game, sort=, release=) |
GET /api/v1/games/{game}/sets |
list_set_aliases(game, source=) |
GET /api/v1/games/{game}/set-aliases |
get_product(id) |
GET /api/v1/products/tcgplayer/{productId} |
get_products(ids) |
GET /api/v1/products/tcgplayer?ids= (up to 100) |
get_all_products(ids) |
the same, 100 ids per call, merged |
replace_contents(id, edit) |
PUT /api/v1/products/tcgplayer/{productId}/contents |
get_raw_prices(id, condition=, ...) |
GET /api/v1/products/tcgplayer/{productId}/prices/raw |
get_raw_prices_batch(ids, ...) |
POST /api/v1/prices/raw (up to 100) |
get_all_raw_prices(ids, ...) |
the same, 100 ids per call, merged |
search(...), search_pages(...) |
GET /api/v1/search |
record_selection(product_id=) |
POST /api/v1/search/selections |
get_changes(after=, limit=), change_pages(after=) |
GET /api/v1/changes |
download_catalog(if_none_match=) |
GET /api/v1/catalog/download |
Pages, batches and the catalog
for page in cardspine.search_pages(game="pokemon", sets=[604], sort="number", page_size=100):
print(len(page["items"]))
result = cardspine.get_all_products(ids)
if result.stopped_by:
print(f"Rate limited; retry {len(result.pending)} ids after {result.stopped_by.retry_after} s")
download = cardspine.download_catalog(if_none_match=saved_etag)
if download:
with download:
for product in download.products():
save(product)
for page in cardspine.change_pages(after=download.change_cursor):
apply(page["changes"])
save_cursor(page["cursor"])
search_pages 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 raise CardspineError with status, title, detail, type, code, retry_after and rate_limit, parsed from the problem details body. Subclasses: CardspineAuthError (401, 403), CardspineNotFoundError (404), CardspineGoneError (410: the change cursor is too old, so download the catalog again and resume from its change_cursor), CardspineRateLimitError (429) and CardspineConnectionError (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 raises at once. record_selection and replace_contents are never retried. cardspine.rate_limit holds the X-RateLimit-* and X-Quota-* values of the latest response.
Cardspine(
"your key",
base_url="https://api.cardspine.com",
api_path="/api/v1",
max_retries=3,
timeout=30.0,
max_retry_after=60.0,
)
License
MIT
Metadata
Release files for cardspine 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cardspine-0.1.0.tar.gz | 17.6 kB | Without provenance | Details for cardspine-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cardspine-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cardspine-0.1.0-py3-none-any.whl |
Total release size: 33.5 kB
Release files / cardspine-0.1.0.tar.gz
| Download URL | cardspine-0.1.0.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83b64a718e069514e94f21ca60f011c4bb92872f526db8f8f1b2182afaa91851
|
|
BLAKE2b-256 checksum How to use checksums |
baea498b42c2596fa4a79c939e4479009eae30a9cfe4e89e49e04d5f9547584a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / cardspine-0.1.0-py3-none-any.whl
| Download URL | cardspine-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5391361eee069d94a5f89d9d07d2553b7997f81a4aceb0ad63b68038f690bcc
|
|
BLAKE2b-256 checksum How to use checksums |
a65f9894989b3589fbf8400fb90b229047149786411b95c5a193a47224259db0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for cardspine 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.