Models¶
All API responses are parsed into typed Pydantic models. Fields are accessible as regular Python attributes.
Wallhaven models¶
- class xanax.sources.wallhaven.models.Wallpaper(**data)[source]¶
Bases:
BaseModelSingle wallpaper from Wallhaven.
- thumbs: Thumbnails¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.SearchResult(**data)[source]¶
Bases:
BaseModelSearch results with pagination metadata.
- meta: PaginationMeta¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.PaginationMeta(**data)[source]¶
Bases:
BaseModelPagination metadata for Wallhaven search results.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.Tag(**data)[source]¶
Bases:
BaseModelInformation about a tag.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.Uploader(**data)[source]¶
Bases:
BaseModelInformation about the wallpaper uploader.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.Avatar(**data)[source]¶
Bases:
BaseModelUser avatar at different sizes.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.Thumbnails(**data)[source]¶
Bases:
BaseModelThumbnail URLs at different sizes.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.QueryInfo(**data)[source]¶
Bases:
BaseModelInformation about a resolved search query.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.UserSettings(**data)[source]¶
Bases:
BaseModelUser account settings.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.Collection(**data)[source]¶
Bases:
BaseModelUser collection information.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.wallhaven.models.CollectionListing(**data)[source]¶
Bases:
BaseModelCollection listing response (mirrors SearchResult structure).
- meta: PaginationMeta¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.pagination.PaginationHelper(meta)[source]¶
Bases:
objectHelper class for navigating paginated Wallhaven search results.
Wraps
PaginationMetaand exposes clean properties and methods for driving pagination loops.Example
results = client.search(params) helper = PaginationHelper(results.meta)
- if helper.has_next:
next_params = params.with_page(helper.next_page_number()) next_results = client.search(next_params)
Unsplash models¶
- class xanax.sources.unsplash.models.UnsplashPhoto(**data)[source]¶
Bases:
BaseModelA photo from Unsplash.
Fields with
| Nonedefaults correspond to data only present in full photo responses (fromGET /photos/:idorGET /photos/random). Search results return abbreviated objects with these fields absent.Example
photo = unsplash.photo(“abc123”) data = unsplash.download(photo)
- urls: UnsplashPhotoUrls¶
- links: UnsplashPhotoLinks¶
- user: UnsplashUser¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.unsplash.models.UnsplashSearchResult(**data)[source]¶
Bases:
BaseModelPaginated search results from
GET /search/photos.Example
result = unsplash.search(UnsplashSearchParams(query="mountains")) print(result.total) # total matching photos print(result.total_pages) # number of pages available for photo in result.results: print(photo.id)
- results: list[UnsplashPhoto]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.unsplash.models.UnsplashPhotoUrls(**data)[source]¶
Bases:
BaseModelPhoto URLs at various resolutions provided by the Unsplash CDN.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.unsplash.models.UnsplashPhotoLinks(**data)[source]¶
Bases:
BaseModelHypermedia links associated with a photo.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Reddit models¶
- class xanax.sources.reddit.models.RedditPost(**data)[source]¶
Bases:
BaseModelA single media post from Reddit.
Represents one image, video, or GIF found in a subreddit listing. Gallery posts are not returned directly — the client expands them into one
RedditPostper image, populatinggallery_indexandgallery_id.Example
post = reddit.post("abc123") if post: data = reddit.download(post)
- classmethod from_reddit_data(data)[source]¶
Build a
RedditPostfrom a raw Reddit API post dict.Detects the media type and extracts the appropriate URL and dimension fields. Returns
Nonefor post types that carry no downloadable media (text posts, external links without supported image domains, polls, etc.).Media type detection order:
is_self=True— text post, skip (returnNone).is_video=Trueanddomain='v.redd.it'— VIDEO (or GIF whenis_gif=Trueon the reddit_video object).is_gallery=True— IMAGE;urlis left empty because the client calls_expand_gallery()to produce per-image posts.post_hint='image'ordomainin('i.redd.it', 'i.imgur.com')— IMAGE.Anything else — skip (return
None).
- Parameters:
data (
dict[str,Any]) – Raw post data dict fromdata.children[n].data.- Return type:
- Returns:
Parsed
RedditPost, orNoneif the post has no supported media.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.reddit.models.RedditGalleryItem(**data)[source]¶
Bases:
BaseModelA single image extracted from a Reddit gallery post.
Reddit galleries store image metadata in
media_metadatakeyed bymedia_id.RedditGalleryItemholds the parsed fields for one such entry.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.reddit.models.RedditListing(**data)[source]¶
Bases:
BaseModelA paginated page of posts from a subreddit listing endpoint.
Example
listing = reddit.listing(RedditParams(subreddit="EarthPorn")) for post in listing.posts: print(post.id, post.url) if listing.after: next_listing = reddit.listing(params.with_after(listing.after))
- posts: list[RedditPost]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].