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
  • authorization (str) – Your API Key for the Random Stuff API used to authenticate your requests.

  • key (str) – Your RapidAPI-Key for the Random Stuff API used to authenticate your requests.

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

AIResponse

async get_animal_image(animal, amount=1)#

Gets animal images from the API.

Parameters
  • animal (str) – The animal you want to get images for. Supported Animals: Dog, Cat, Wolf, Fox

  • amount (Optional[int]) – The amount of images you want to get.

Returns

An object containing the image.

Return type

Image

async get_anime_gif(query, channel)#

Get anime gifs from the API.

Parameters
  • query (str) – The query you want to get gifs for.

  • channel (str) – The channel you want to get gifs from, could be 1, 2 or 3.

Returns

A list of AnimeGIF objects.

Return type

list

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.

Parameters
  • tags (Optional[list]) – A list of tags to filter the jokes by.

  • blacklist (Optional[list]) – Blacklisted tags to filter the jokes by. Blacklist “dirty” if you want safe jokes.

Returns

A Joke object containing the joke and the tags.

Return type

Joke

async fetch_subreddit_post(subreddit, search_type='hot')#

Fetches a random post from a subreddit.

Parameters
  • subreddit (str) – The subreddit to fetch a post from.

  • 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

RedditPost

async fetch_post(subreddit, search_type='hot')#

Fetches a random post from a subreddit. This is an alias of fetch_subreddit_post().

Parameters
  • subreddit (str) – The subreddit to fetch a post from.

  • 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

RedditPost

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

RedditPost

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

RedditPost

async fetch_post_by_id(post_id, search_type='hot')#

Fetch a reddit post by its ID.

Parameters
  • post_id (str) – The ID of the post to fetch.

  • 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

RedditPost

async get_weather(city)#

Gets the weather for a city.

Parameters

city (str) – The city to get the weather for.

Returns

A list containing the weather details.

Return type

list

async get_fact(fact_type='all')#

Fetches a random fact from the API. PREMIUM ENDPOINT.

Parameters

fact_type (Optional[str]) – The type of fact you want to fetch.

Returns

An object containing the fact.

Return type

Fact

async disconnect()#

Closes the Client Session

async reconnect()#

Restarts the Client Connection

Documentation Last Updated on Mar 27, 2022