Client#
This is the main async client class you will use to make requests to the API. All methods are available here. You can find helper functions for some of these methods in the utils page.
You may create an instance of this class and use it to make requests.
- class yarsaw.Client(authorization, key)#
Represents a client object used to interact with the Random Stuff API.
- Parameters
- async get_ai_response(message, **kwargs)#
Gets AI responses from the API.
- Parameters
message (
str
) – The message you want to get the AI response for.id (Optional[Union[
str
,int
]]) – Assign an unique ID for customized response for each user.bot_name (Optional[
str
]) – Set a name for the AI replying to your message.bot_gender (Optional[
str
]) – Set a gender for the AI replying to your message.bot_master (Optional[
str
]) – The creator/master of the AI replying to your message.bot_age (Optional[
str
]) – The age of the AI replying to your message.bot_company (Optional[
str
]) – The company that owns the AI replying to your message.bot_location (Optional[
str
]) – The location of the AI replying to your message.bot_email (Optional[
str
]) – The email of the AI replying to your message.bot_build (Optional[
str
]) – The build of the AI replying to your message.bot_birth_year (Optional[
str
]) – The birth year of the AI replying to your message.bot_birth_date (Optional[
str
]) – The birth date of the AI replying to your message.bot_birth_place (Optional[
str
]) – The birth place of the AI replying to your message.bot_favorite_color (Optional[
str
]) – The favorite color of the AI replying to your message.bot_favorite_book (Optional[
str
]) – The favorite book of the AI replying to your message.bot_favorite_band (Optional[
str
]) – The favorite band of the AI replying to your message.bot_favorite_artist (Optional[
str
]) – The favorite artist of the AI replying to your message.bot_favorite_actress (Optional[
str
]) – The favorite actress of the AI replying to your message.bot_favorite_actor (Optional[
str
]) – The favorite actor of the AI replying to your message.
- Returns
An object containing the AI response and its details.
- Return type
- async get_animal_image(animal, amount=1)#
Gets animal images from the API.
- async get_anime_gif(query, channel)#
Get anime gifs from the API.
- async canvas(method, save_to=None, txt=None, text=None, img1=None, img2=None, img3=None)#
Edit Images with the API.
- Parameters
method (
str
) –The method to be used to edit the image.
Allowed Methods:
Method(s) in which only 1 image is required:
affect
,beautiful
,wanted
,delete
,trigger
,facepalm
,blur
,hitler
,kiss
,jail
,invert
,jokeOverHead
Method(s) in which 2 images are required:
bed
,fuse
,kiss
,slap
,spank
Method(s) in which 3 images are required:
distracted
Method(s) in which only Text is required:
changemymind
save_to (Optional[
str
]) – The path to save the edited image to. If not specified, the edited image will be returned as bytes.txt (Optional[
str
]) – The text required for your method.text (Optional[
str
]) – The text required for your method. Alias of txt.img1 (Optional[
str
]) – The path/link to the first image.img2 (Optional[
str
]) – The path/link to the second image.img3 (Optional[
str
]) – The path/link to the third image.
- Returns
If save_to is not specified, the edited image will be returned as a Response object containing the base64 encoded image. If save_to is specified, the edited image will be saved to the specified path, and will 200.
- Return type
Union[
CanvasResponse
,int
]
- async get_joke(tags=None, blacklist=None)#
Get random jokes from the API.
- async fetch_subreddit_post(subreddit, search_type='hot')#
Fetches a random post from a subreddit.
- Parameters
- Returns
An object containing the post and its details.
- Return type
- async fetch_post(subreddit, search_type='hot')#
Fetches a random post from a subreddit. This is an alias of
fetch_subreddit_post()
.- Parameters
- Returns
An object containing the post and its details.
- Return type
- async random_meme(search_type='hot')#
Gets a random meme from reddit.
- Parameters
search_type (Optional[
str
]) – This is how it sorts the posts. Allows: “hot”, “new”, “rising”, “top”- Returns
An object containing the post and its details.
- Return type
- async fetch_random_post(search_type='hot')#
Fetches a random post from reddit.
- Parameters
search_type (Optional[
str
]) – This is how it sorts the posts. Allows: “hot”, “new”, “rising”, “top”- Returns
An object containing the post and its details.
- Return type
- async fetch_post_by_id(post_id, search_type='hot')#
Fetch a reddit post by its ID.
- Parameters
- Returns
An object containing the post and its details.
- Return type
- async get_weather(city)#
Gets the weather for a city.
- async get_fact(fact_type='all')#
Fetches a random fact from the API. PREMIUM ENDPOINT.
- async disconnect()#
Closes the Client Session
- async reconnect()#
Restarts the Client Connection
Documentation Last Updated on Mar 27, 2022