Search Parameters¶
Wallhaven¶
- class xanax.sources.wallhaven.params.SearchParams(**data)[source]¶
Bases:
BaseModelParameters for a Wallhaven wallpaper search.
All fields are validated before any network request is made. Invalid combinations raise
ValidationErrorimmediately.The default
categoriesincludes all three (general, anime, people), matching Wallhaven’s own default search behaviour.Example
params = SearchParams( query="+anime -sketch", categories=[Category.ANIME], purity=[Purity.SFW], sorting=Sort.TOPLIST, top_range=TopRange.ONE_MONTH, )
- model_post_init(_SearchParams__context)[source]¶
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- Return type:
- with_page(page)[source]¶
Return a new
SearchParamswith only the page number changed.- Parameters:
page (
int) – New page number.- Return type:
- Returns:
New instance with
pageupdated and all other fields preserved.
- with_seed(seed)[source]¶
Return a new
SearchParamswith only the seed changed.- Parameters:
seed (
str) – New seed value (6 alphanumeric characters).- Return type:
- Returns:
New instance with
seedupdated and all other fields preserved.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Unsplash¶
- class xanax.sources.unsplash.params.UnsplashSearchParams(**data)[source]¶
Bases:
BaseModelParameters for
GET /search/photos.The
queryfield is required. All other fields have sensible defaults matching the Unsplash API’s own defaults.Example
params = UnsplashSearchParams( query="mountains", orientation=UnsplashOrientation.LANDSCAPE, color=UnsplashColor.BLUE, order_by=UnsplashOrderBy.LATEST, per_page=30, ) result = unsplash.search(params)
- Parameters:
query (str) – Search terms. Required.
page (int) – Page number (1-indexed). Default is 1.
per_page (int) – Results per page. Min 1, max 30. Default is 10.
order_by (UnsplashOrderBy) – How to sort results. Default is
RELEVANT.collections (list[str]) – Collection IDs to narrow the search (comma-joined internally).
content_filter (UnsplashContentFilter) – Content safety level. Default is
LOW.color (UnsplashColor | None) – Filter by dominant color.
orientation (UnsplashOrientation | None) – Filter by photo orientation.
- order_by: UnsplashOrderBy¶
- content_filter: UnsplashContentFilter¶
- color: UnsplashColor | None¶
- orientation: UnsplashOrientation | None¶
- with_page(page)[source]¶
Return a new
UnsplashSearchParamswith the page number updated.- Parameters:
page (
int) – New page number.- Return type:
- Returns:
New instance with
pageupdated and all other fields preserved.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class xanax.sources.unsplash.params.UnsplashRandomParams(**data)[source]¶
Bases:
BaseModelParameters for
GET /photos/random.All fields are optional. With no parameters, a completely random photo is returned. Parameters narrow the pool of eligible photos.
Note
collectionsandtopicscannot be combined withqueryin the same request. The API will return an error if both are provided.Example
params = UnsplashRandomParams( query="forest", orientation=UnsplashOrientation.LANDSCAPE, ) photo = unsplash.random(params)
- Parameters:
collections (list[str]) – Collection IDs to restrict the random pool to.
topics (list[str]) – Topic IDs to restrict the random pool to.
username (str | None) – Restrict to photos from a specific user.
query (str | None) – Restrict to photos matching a search term.
orientation (UnsplashOrientation | None) – Filter by photo orientation.
content_filter (UnsplashContentFilter) – Content safety level. Default is
LOW.
- orientation: UnsplashOrientation | None¶
- content_filter: UnsplashContentFilter¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Reddit¶
- class xanax.sources.reddit.params.RedditParams(**data)[source]¶
Bases:
BaseModelParameters for a subreddit media listing request.
The
subredditfield is required. All other fields have sensible defaults. Use the+separator to fetch from multiple subreddits at once (e.g."EarthPorn+spaceporn").Cursor-based pagination is handled via the
afterfield. Usewith_after()to build the next-page params from a listing’saftercursor rather than mutating the instance.Note
time_filteronly affects results whensortisTOPorCONTROVERSIAL. It is silently ignored for all other sort orders.Example
params = RedditParams( subreddit="EarthPorn", sort=RedditSort.TOP, time_filter=RedditTimeFilter.WEEK, limit=50, ) for post in reddit.iter_media(params): reddit.download(post, path=f"{post.id}.jpg")
- Parameters:
subreddit (str) – Target subreddit(s). Use
+to combine multiple, e.g."wallpapers+EarthPorn". Required.sort (RedditSort) – Listing sort order. Default is
HOT.time_filter (RedditTimeFilter) – Time window for TOP/CONTROVERSIAL listings. Default is
ALL.limit (int) – Posts per page (1–100). Default is 25.
after (str | None) – Cursor for the next page (fullname like
't3_abc123').Nonefetches the first page.media_type (MediaType) – Media type filter applied client-side. Default is
ANY(no filtering).include_nsfw (bool) – Whether to include NSFW posts. Default is
False.
- sort: RedditSort¶
- time_filter: RedditTimeFilter¶
- with_after(after)[source]¶
Return a new
RedditParamswith the pagination cursor updated.All other fields are preserved unchanged.
- Parameters:
after (
str) – New cursor value (fullname fromRedditListing.after).- Return type:
- Returns:
New
RedditParamsinstance withafterset.
- model_config: ClassVar[ConfigDict] = {'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].