WhatAnime.whatanime module
Client class for the wrapper author: Joker Hacker
- class WhatAnime.whatanime.Client(token: Optional[str], host: str = 'https://api.trace.moe')
Bases:
object
This class, interacts with the API
Note
The API server has a global request rate limit of 60/min per IP address. Regardless of which url endpoint you’re calling. This is always counted by IP address, even if you request with an API Key.
The rate limit info is included in the HTTP header. If you hit this HTTP rate limit, request would fail with HTTP 429 (Too Many Requests).
- Parameters
token (
str
, optional) – The API token to use to make requests.host (
str
, optional) – Hostname of the API to use incase you have your own server setup Defaults to api.trace.moe
- Raises
ValueError – If image is empty or Token invalid.
ImageSizeTooLargeError – when given image size is larger than 10MB.
QuotaExceedError – When you reached your Quota limit for your IP/Token or too many requests.
APIError – When Image is corrupted or Something went wrong on API’s end.
- get_me() WhatAnime.types.User
Let you check the search quota and limit for your account (with API key) or IP address (without API key).
- Returns
The Dictionary of User Data
- Return type
- search_file(image) WhatAnime.types.WAResponse
Search using file.
- Parameters
image (
str
) – Pass the location of image/video file, ex: search_file(“image.jpeg”)- Returns
Response object from the server which contains frameCount, error and
WhatAnime.types.Result
object- Return type
- search_url(url: str, anilist: bool) WhatAnime.types.WAResponse
Search using url.
- Parameters
url (
str
) – url of the image/video to use for request.anilist (
bool
, optional) – PassTrue
if you want to include anilist information
- Returns
Response object from the server which contains frameCount, error and
WhatAnime.types.Result
object- Return type
WhatAnime.types module
- class WhatAnime.types.Anilist(id: int, idMal: int, title: Dict[str, str], synonyms: List[str], isAdult: bool, **kwargs)
- class WhatAnime.types.Result(anilist: Union[int, WhatAnime.types.Anilist], filename: str, episode: Any, from_time: int, to_time: int, similarity: int, video: str, image: str, **kwargs)
Bases:
WhatAnime.types.WhatAnimeType
This object represents a Result for
WhatAnime.types.WAResponse
- Parameters
anilist (
int
|WhatAnime.types.Anilist
) – The matching anilist ID or Anilist Info, which contains information about id, idMal, title, synonyms and isAdultfilename (
str
) – The filename of file where the match is foundepisode (
Any
) – The extracted episode number from filename.from_time (
int
) – Starting time of the matching scene (seconds)to_time (
int
) – Ending time of the matching scene (seconds)similarity (
int
) – Similarity compared to search imagevideo (
str
) – URL to the preview video of the matching sceneimage (
str
) – URL to the preview image of the matching scene
- class WhatAnime.types.User(id: str, priority: int, concurrency: int, quota: int, quotaUsed: int, **kwargs)
Bases:
WhatAnime.types.WhatAnimeType
This object represents a User
- Parameters
id (
str
) – User IDpriority (
int
) – With limited processing power available, the server has priority queue to handle requestsconcurrency (
int
) – The number of simultaneous (parallel) requests you can make to the API serverquota (
int
) – Quota remaining for the IP or given tokenquotaUsed (
int
) – Quota used for the IP or given token
- class WhatAnime.types.WAResponse(frameCount: int, error: Optional[str], result: List[WhatAnime.types.Result], **kwargs)
Bases:
WhatAnime.types.WhatAnimeType
This object represents Response from API.
- Parameters
frameCount (
int
) –error (
str
) – Error Messageresult (
List
) – List ofWhatAnime.types.Result
Object, which containes all the information about the search request.
- class WhatAnime.types.WhatAnimeType
Bases:
object
Base class for all WhatAnime objects
WhatAnime.exception module
- exception WhatAnime.exception.APIError
Bases:
WhatAnime.exception.WhatAnimeError
Raises when an error occurs on the API.
- exception WhatAnime.exception.ImageSizeTooLargeError
Bases:
WhatAnime.exception.WhatAnimeError
Raises when an image uploaded was too large for the API.
- exception WhatAnime.exception.InvalidToken
Bases:
WhatAnime.exception.WhatAnimeError
Raises when API token is invalid
- exception WhatAnime.exception.QuotaExceedError
Bases:
WhatAnime.exception.WhatAnimeError
Raises when daily quota for requests has been reached.
- exception WhatAnime.exception.WhatAnimeError
Bases:
Exception
Base exception class for this module.