animedex.backends.waifu.models
Rich Waifu.im dataclasses (one per resource type).
Waifu.im wraps every listing in a {items, pageNumber, totalPages,
totalCount, pageSize, hasPreviousPage, hasNextPage} envelope. The
high-level API extracts items and validates each row through a
typed model; per the project’s lossless contract every model
inherits from BackendRichModel (extra='allow',
populate_by_name=True, frozen=True) so any field upstream
adds round-trips through model_dump.
The WaifuImage.to_common() projection maps image records onto
the cross-source ArtPost shape.
WaifuTag and WaifuArtist have no cross-source common type
and surface as their rich shape only.
WaifuTag
- class animedex.backends.waifu.models.WaifuTag(*, id: int, name: str | None = None, slug: str | None = None, description: str | None = None, imageCount: int | None = None, reviewStatus: str | None = None, creatorId: int | None = None, source_tag: SourceTag | None = None, **extra_data: Any)[source]
Bases:
BackendRichModelA single tag record (also nested inside
WaifuImage).- Variables:
id (int) – Numeric tag ID.
name (str or None) – Display name (capitalised, e.g.
"Waifu").slug (str or None) – URL-safe slug (lowercased, e.g.
"waifu").description (str or None) – Short description.
imageCount (int or None) – Number of images carrying this tag.
reviewStatus (str or None) – Upstream’s review state (
"Accepted").
WaifuArtist
- class animedex.backends.waifu.models.WaifuArtist(*, id: int, name: str | None = None, patreon: str | None = None, pixiv: str | None = None, twitter: str | None = None, deviantArt: str | None = None, reviewStatus: str | None = None, creatorId: int | None = None, imageCount: int | None = None, source_tag: SourceTag | None = None, **extra_data: Any)[source]
Bases:
BackendRichModelA single artist record (also nested inside
WaifuImage).- Variables:
id (int) – Numeric artist ID.
name (str or None) – Artist display name.
patreon (str or None) – Artist’s Patreon URL.
pixiv (str or None) – Artist’s Pixiv URL.
twitter (str or None) – Artist’s Twitter / X URL.
deviantArt (str or None) – Artist’s DeviantArt URL.
imageCount (int or None) – Number of images by this artist in the catalogue.
WaifuImageDimensions
- class animedex.backends.waifu.models.WaifuImageDimensions(*, width: int | None = None, height: int | None = None, **extra_data: Any)[source]
Bases:
BackendRichModelWidth / height block on
WaifuImage. Note that Waifu.im flattenswidth/heightdirectly onto the image record rather than nesting them, so this class is here for parity with other backends’ typed access — Waifu.im itself has no nested dimensions object.
WaifuImage
- class animedex.backends.waifu.models.WaifuImage(*, id: int, url: str, source: str | None = None, isNsfw: bool | None = None, isAnimated: bool | None = None, width: int | None = None, height: int | None = None, perceptualHash: str | None = None, extension: str | None = None, dominantColor: str | None = None, uploaderId: int | None = None, uploadedAt: str | None = None, byteSize: int | None = None, favorites: int | None = None, likedAt: str | None = None, addedToAlbumAt: str | None = None, reviewStatus: str | None = None, tags: List[WaifuTag] = [], artists: List[WaifuArtist] = [], albums: List[dict] | None = None, source_tag: SourceTag | None = None, **extra_data: Any)[source]
Bases:
BackendRichModelA single image record from Waifu.im.
Returned by
/imagesand/images/{id}. Carries explicitisNsfw/isAnimatedflags + nestedtagsandartistslists.- Variables:
id (int) – Numeric image ID.
url (str) – Direct asset URL.
source (str or None) – Upstream source URL (artist’s pixiv, twitter, etc).
isNsfw (bool or None) – NSFW flag — the canonical signal for the
isNsfw=query parameter on/images.isAnimated (bool or None) – Whether the asset is an animated GIF / WebP.
width (int or None) – Image width in pixels.
height (int or None) – Image height in pixels.
dominantColor (str or None) – Hex colour summarising the image (used for placeholder backgrounds).
artists (list of WaifuArtist) – Nested list of typed artist records.
- artists: List[WaifuArtist]
WaifuUser
- class animedex.backends.waifu.models.WaifuUser(*, id: int, name: str | None = None, discordId: str | None = None, avatarUrl: str | None = None, role: str | None = None, isBlacklisted: bool | None = None, blacklistReason: str | None = None, requestCount: int | None = None, apiKeyRequestCount: int | None = None, jwtRequestCount: int | None = None, uploadedAt: str | None = None, source_tag: SourceTag | None = None, **extra_data: Any)[source]
Bases:
BackendRichModelThe authenticated user record from
/users/me.- Variables:
WaifuStats
- class animedex.backends.waifu.models.WaifuStats(*, totalRequests: int | None = None, totalImages: int | None = None, totalTags: int | None = None, totalArtists: int | None = None, source_tag: SourceTag | None = None, **extra_data: Any)[source]
Bases:
BackendRichModelPublic-statistics envelope from
/stats/public: counters summarising the upstream’s content + traffic.- Variables:
selftest
- animedex.backends.waifu.models.selftest() bool[source]
Smoke-test the Waifu.im rich models.
Validates a synthetic
WaifuImageround-trips throughmodel_dump_json/model_validate_jsonand projects to a well-formedArtPost, including theisNsfw→ rating mapping.- Returns:
Trueon success; raises on schema drift.- Return type: