Python client for the Pkmn Prices API
Project description
pkmnprices
Python client for the Pkmn Prices API. Pokemon TCG card pricing from TCGPlayer, Cardmarket, and eBay.
Sync and async clients, both built on httpx. Typed responses, typed errors, and iterators that page through results for you. Python 3.10+.
Install
pip install pkmnprices
Usage
from pkmnprices import PkmnPrices
client = PkmnPrices("pk_your_key_here")
page = client.cards.list(name="charizard", per_page=10)
card = client.cards.get(page.data[0].id)
for price in card.prices:
symbol = "€" if price.currency == "EUR" else "$"
print(f"{price.source}: {symbol}{price.market_price}")
client.close()
The client is also a context manager:
with PkmnPrices("pk_...") as client:
health = client.health()
Async
import asyncio
from pkmnprices import AsyncPkmnPrices
async def main():
async with AsyncPkmnPrices("pk_...") as client:
page = await client.cards.list(name="charizard")
async for card in client.cards.iterate(name="charizard"):
print(card.name)
asyncio.run(main())
Get an API key from https://pkmnprices.com/dashboard.
Options
PkmnPrices(
"pk_...", # API key, sent as the x-api-key header
max_retries=2, # retries on 429 rate limits and 5xx/network errors
timeout=30.0, # per-request timeout in seconds
)
Rate-limit 429s are retried with backoff. Credit-limit 429s (credit_limit_exceeded) are not, since they don't reset until the next day.
Pagination
List endpoints return a Page (.data, .pagination). Listing endpoints (eBay/Cardmarket/TCGplayer) return a CursorPage. Both resources expose iterators so you don't track pages or cursors:
for card in client.cards.iterate(name="charizard"):
print(card.name)
all_sets = client.sets.list_all(language="english")
for sale in client.cards.listings.iterate_ebay(789, grader="PSA", grade="10"):
print(sale.title, sale.price)
for offer in client.cards.listings.iterate_tcgplayer(789, condition="Near Mint"):
print(offer.seller_name, offer.price, offer.shipping_price)
Currency
Every price has a currency field. Pass currency="usd" or currency="eur" to filter, or leave it off to get everything your plan allows. EUR (Cardmarket) prices need a Pro plan; a free key asking for eur raises ForbiddenError.
card = client.cards.get(789, currency="usd")
Errors
Everything raised subclasses PkmnPricesError, which carries status, code, rate_limit, and retry_after.
from pkmnprices import ForbiddenError, NotFoundError, RateLimitError
try:
client.cards.get(789, currency="eur")
except ForbiddenError:
... # needs a higher plan
except NotFoundError:
... # no such card
except RateLimitError:
... # ran out of retries
Subclasses: BadRequestError (400), UnauthorizedError (401), ForbiddenError (403), NotFoundError (404), ConflictError (409), CreditLimitError and RateLimitError (429), InternalServerError (5xx), APIConnectionError (network/timeout).
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pkmnprices-1.0.3.tar.gz.
File metadata
- Download URL: pkmnprices-1.0.3.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28898af6991abf6d237a4e6e0203501b97c4efd1c0add36d54fb0a5d067ce424
|
|
| MD5 |
e092359797898c7b221aec1735de4cd1
|
|
| BLAKE2b-256 |
b8b525c14bf2e99daf5997ca6489bb445a22efb13bd712063451798812fe7e2f
|
Provenance
The following attestation bundles were made for pkmnprices-1.0.3.tar.gz:
Publisher:
publish.yml on preaverage/pkmnprices-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pkmnprices-1.0.3.tar.gz -
Subject digest:
28898af6991abf6d237a4e6e0203501b97c4efd1c0add36d54fb0a5d067ce424 - Sigstore transparency entry: 1852418228
- Sigstore integration time:
-
Permalink:
preaverage/pkmnprices-py@7ab04445ecab49bacc2fd92f49a1ce157fe12683 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/preaverage
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7ab04445ecab49bacc2fd92f49a1ce157fe12683 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pkmnprices-1.0.3-py3-none-any.whl.
File metadata
- Download URL: pkmnprices-1.0.3-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99d9859be1b3607b94539b5e7d286519de564c9df16965aa4ec9a10d62dccbbb
|
|
| MD5 |
689dfc1e56fad81667524d76164b1efd
|
|
| BLAKE2b-256 |
6123c5ed4c3036fa64f4d76ed912612bc8978696749a3737a8c57bb5a0ec2fe6
|
Provenance
The following attestation bundles were made for pkmnprices-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on preaverage/pkmnprices-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pkmnprices-1.0.3-py3-none-any.whl -
Subject digest:
99d9859be1b3607b94539b5e7d286519de564c9df16965aa4ec9a10d62dccbbb - Sigstore transparency entry: 1852418318
- Sigstore integration time:
-
Permalink:
preaverage/pkmnprices-py@7ab04445ecab49bacc2fd92f49a1ce157fe12683 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/preaverage
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7ab04445ecab49bacc2fd92f49a1ce157fe12683 -
Trigger Event:
release
-
Statement type: