animedex.backends.nekos
High-level nekos.best v2 Python API.
Three thin wrappers over the v2 endpoints:
categories()— list every available category name (sugar overGET /endpoints).image()— fetch one or more random images / GIFs from a named category.search()— best-effort metadata search across all categories.
Every function accepts config and forwards transport-level
keyword arguments to the underlying passthrough call.
categories
- animedex.backends.nekos.categories(*, config: Config | None = None, **kw) List[str][source]
List every nekos.best v2 category name.
Calls
GET /endpointsand returns just the category names, alphabetically. The richer per-category format data is available viacategories_full()for callers that want the asset format and filename range.
categories_full
- animedex.backends.nekos.categories_full(*, config: Config | None = None, **kw) Dict[str, NekosCategoryFormat][source]
List every category along with its per-category format metadata.
Calls
GET /endpointsand validates each entry throughNekosCategoryFormatso downstream callers get typed access toformat/min/max.- Returns:
Mapping from category name to format metadata.
- Return type:
image
- animedex.backends.nekos.image(category: str, *, amount: int = 1, config: Config | None = None, **kw) List[NekosImage][source]
Fetch one or more random images / GIFs from a category.
Calls
GET /<category>?amount=<N>. The upstream’s response body is{"results": [<NekosImage>, ...]}; each row is validated throughNekosImage.- Parameters:
category (str) – Category name (e.g.
"husbando","neko","waifu"). Must be one of those returned bycategories().amount (int) – Number of images to return,
1..20. Defaults to1.
- Returns:
List of images. The list is always at least one entry long when the category is valid.
- Return type:
- Raises:
ApiError –
bad-argsforamountout of range,not-foundwhen the category is unknown.
search
- animedex.backends.nekos.search(query: str, *, type: int = 1, category: str | None = None, amount: int = 1, config: Config | None = None, **kw) List[NekosImage][source]
Search nekos.best v2 by metadata.
Calls
GET /search?query=<query>&type=<type>&amount=<amount>(plus optional&category=<name>). The upstream matchesqueryagainstanime_name/artist_name/source_urlfuzzily and always returns up toamountresults — a query that nothing closely matches falls through to a near-random ranking rather than an empty list.- Parameters:
query (str) – Search phrase.
type (int) – Asset type filter —
1for images (default),2for GIFs.category (str or None) – Restrict the search to one category.
amount (int) – Maximum number of results,
1..20. Defaults to1. The upstream returns exactlyamountresults in practice — there is no empty-result signal for non-matching queries.
- Returns:
List of matching images.
- Return type:
- Raises:
ApiError –
bad-argsforamountortypeout of range,upstream-shapefor malformed responses.
selftest
- animedex.backends.nekos.selftest() bool[source]
Smoke-test the public nekos.best Python API (signatures only).
Confirms each public callable accepts a
configkeyword so the Click factory’s keyword-injection pattern works, and that the callables list matches the documented surface.- Returns:
Trueon success.- Return type: