Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions api/app_types/tcgdex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"""TCGdex REST API v2 response shapes (https://tcgdex.dev/)."""

from typing import Any, NotRequired, TypedDict


class TcgdexCardCount(TypedDict, total=False):
"""Card counts inside a set or nested ``set`` on a card."""

total: int
official: int
firstEd: int
holo: int
normal: int
reverse: int


class TcgdexSetBrief(TypedDict, total=False):
"""Row from ``GET /v2/{locale}/sets`` (may omit optional fields)."""

id: str
name: str
logo: str
symbol: str
cardCount: TcgdexCardCount


class TcgdexAbbreviation(TypedDict, total=False):
"""Official / internal product codes when present."""

official: str


class TcgdexSerieRef(TypedDict, total=False):
"""Parent series reference on a set."""

id: str
name: str


class TcgdexSeriesBrief(TypedDict, total=False):
"""Row from ``GET /v2/{locale}/series``."""

id: str
name: str
logo: str


class TcgdexSeriesDetail(TypedDict, total=False):
"""Full series from ``GET /v2/{locale}/series/{seriesId}`` (includes nested sets)."""

id: str
name: str
logo: str
releaseDate: str
firstSet: TcgdexSetBrief
lastSet: TcgdexSetBrief
sets: list[TcgdexSetBrief]


class TcgdexSetLegal(TypedDict, total=False):
"""Play format flags."""

standard: bool
expanded: bool


class TcgdexCardInSetBrief(TypedDict, total=False):
"""Card stub embedded in a full set payload."""

id: str
localId: str
name: str
image: str


class TcgdexSetDetail(TypedDict, total=False):
"""Full set from ``GET /v2/{locale}/sets/{setId}`` (superset of TcgdexSetBrief)."""

id: str
name: str
logo: str
symbol: str
cardCount: TcgdexCardCount
cards: list[TcgdexCardInSetBrief]
releaseDate: str
serie: TcgdexSerieRef
tcgOnline: str
abbreviation: TcgdexAbbreviation
legal: TcgdexSetLegal


class TcgdexSetNestedOnCard(TypedDict, total=False):
"""``set`` object on a single-card response (subset of set fields)."""

id: str
name: str
logo: str
symbol: str
cardCount: TcgdexCardCount


class TcgdexCardDetail(TypedDict, total=False):
"""Single card from ``GET /v2/{locale}/cards/{cardId}``."""

id: str
localId: str
name: str
image: str
rarity: str
category: str
set: TcgdexSetNestedOnCard
pricing: dict[str, Any]
2 changes: 2 additions & 0 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from routes import access_requests as access_requests_routes
from routes import articles as articles_routes
from routes import auth as auth_routes
from routes import catalog_route
from routes import ebay_market_route
from routes import ebay_route
from routes import pricing_route
Expand Down Expand Up @@ -104,6 +105,7 @@ def health() -> dict[str, str]:
app.include_router(ebay_route.router)
app.include_router(ebay_market_route.router)
app.include_router(pricing_route.router)
app.include_router(catalog_route.router)
app.include_router(stats_route.router)
app.include_router(scan_routes.router)
app.include_router(shipping_route.router)
Loading
Loading