|
| 1 | +"""TCGdex REST API v2 response shapes (https://tcgdex.dev/).""" |
| 2 | + |
| 3 | +from typing import Any, NotRequired, TypedDict |
| 4 | + |
| 5 | + |
| 6 | +class TcgdexCardCount(TypedDict, total=False): |
| 7 | + """Card counts inside a set or nested ``set`` on a card.""" |
| 8 | + |
| 9 | + total: int |
| 10 | + official: int |
| 11 | + firstEd: int |
| 12 | + holo: int |
| 13 | + normal: int |
| 14 | + reverse: int |
| 15 | + |
| 16 | + |
| 17 | +class TcgdexSetBrief(TypedDict, total=False): |
| 18 | + """Row from ``GET /v2/{locale}/sets`` (may omit optional fields).""" |
| 19 | + |
| 20 | + id: str |
| 21 | + name: str |
| 22 | + logo: str |
| 23 | + symbol: str |
| 24 | + cardCount: TcgdexCardCount |
| 25 | + |
| 26 | + |
| 27 | +class TcgdexAbbreviation(TypedDict, total=False): |
| 28 | + """Official / internal product codes when present.""" |
| 29 | + |
| 30 | + official: str |
| 31 | + |
| 32 | + |
| 33 | +class TcgdexSerieRef(TypedDict, total=False): |
| 34 | + """Parent series reference on a set.""" |
| 35 | + |
| 36 | + id: str |
| 37 | + name: str |
| 38 | + |
| 39 | + |
| 40 | +class TcgdexSeriesBrief(TypedDict, total=False): |
| 41 | + """Row from ``GET /v2/{locale}/series``.""" |
| 42 | + |
| 43 | + id: str |
| 44 | + name: str |
| 45 | + logo: str |
| 46 | + |
| 47 | + |
| 48 | +class TcgdexSeriesDetail(TypedDict, total=False): |
| 49 | + """Full series from ``GET /v2/{locale}/series/{seriesId}`` (includes nested sets).""" |
| 50 | + |
| 51 | + id: str |
| 52 | + name: str |
| 53 | + logo: str |
| 54 | + releaseDate: str |
| 55 | + firstSet: TcgdexSetBrief |
| 56 | + lastSet: TcgdexSetBrief |
| 57 | + sets: list[TcgdexSetBrief] |
| 58 | + |
| 59 | + |
| 60 | +class TcgdexSetLegal(TypedDict, total=False): |
| 61 | + """Play format flags.""" |
| 62 | + |
| 63 | + standard: bool |
| 64 | + expanded: bool |
| 65 | + |
| 66 | + |
| 67 | +class TcgdexCardInSetBrief(TypedDict, total=False): |
| 68 | + """Card stub embedded in a full set payload.""" |
| 69 | + |
| 70 | + id: str |
| 71 | + localId: str |
| 72 | + name: str |
| 73 | + image: str |
| 74 | + |
| 75 | + |
| 76 | +class TcgdexSetDetail(TypedDict, total=False): |
| 77 | + """Full set from ``GET /v2/{locale}/sets/{setId}`` (superset of TcgdexSetBrief).""" |
| 78 | + |
| 79 | + id: str |
| 80 | + name: str |
| 81 | + logo: str |
| 82 | + symbol: str |
| 83 | + cardCount: TcgdexCardCount |
| 84 | + cards: list[TcgdexCardInSetBrief] |
| 85 | + releaseDate: str |
| 86 | + serie: TcgdexSerieRef |
| 87 | + tcgOnline: str |
| 88 | + abbreviation: TcgdexAbbreviation |
| 89 | + legal: TcgdexSetLegal |
| 90 | + |
| 91 | + |
| 92 | +class TcgdexSetNestedOnCard(TypedDict, total=False): |
| 93 | + """``set`` object on a single-card response (subset of set fields).""" |
| 94 | + |
| 95 | + id: str |
| 96 | + name: str |
| 97 | + logo: str |
| 98 | + symbol: str |
| 99 | + cardCount: TcgdexCardCount |
| 100 | + |
| 101 | + |
| 102 | +class TcgdexCardDetail(TypedDict, total=False): |
| 103 | + """Single card from ``GET /v2/{locale}/cards/{cardId}``.""" |
| 104 | + |
| 105 | + id: str |
| 106 | + localId: str |
| 107 | + name: str |
| 108 | + image: str |
| 109 | + rarity: str |
| 110 | + category: str |
| 111 | + set: TcgdexSetNestedOnCard |
| 112 | + pricing: dict[str, Any] |
0 commit comments