Client

class yarsaw.Client(authorization)

Represents an async client object used to connect with the API.

Parameters

authorization (str) – Your Random Stuff API Key to be used to authorize the connection.

async get_ai_response(message, *, plan='free', **kwargs)

Fetches ai responses from the API.

Parameters
  • message (str) – The message to be sent to the API.

  • plan (Optional[str]) – The plan you bought the API with, if you did.

Returns

A list of responses from the API.

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 bytes. If save_to is specified, the edited image will be saved to the specified path, and will return the image.

Return type

Union[bytes, io.BufferedImage]

async get_covid_stats(country=None)

Fetch covid stats from the API.

Parameters

country (Optional[str]) – The country to fetch stats for.

Returns

A dictionary containing the stats.

Return type

dict

async get_covid_stats_by_country(country)

Fetch covid stats from the API by country.

Parameters

country (str) – The country to fetch stats for.

Returns

A dictionary containing the stats.

Return type

dict

async get_fact(*, plan, fact_type='all')

Fetches facts from the API.

Parameters
  • plan (str) – The plan you bought to use the API.

  • fact_type (Optional[str]) – The type of fact you want to fetch. Allowed Values: “all”, “dog”, “cat”, “space”, “covid”, “computer”, “food”, “emoji”

async get_image(img_type)

Fetches images from the API.

Parameters

img_type (str) – The type of image you want to fetch. Allowed Values: “aww”, “duck”, “dog”, “cat”, “memes”, “dankmemes”, “holup”, “art”, “harrypottermemes”, “facepalm”

Returns

A list containing the image(s).

Return type

list

async get_joke(joke_type='any', blacklist=[])

Fetches jokes from the API.

Parameters
  • joke_type (Optional[str]) – The type of joke you want to fetch. Allowed Values: “any”, “dark”, “pun”, “spooky”, “christmas”, “programming”, “misc”

  • blacklist (Optional[list]) – A list of types jokes you want to blacklist. Allowed Values: “all”, “nsfw”, “religious”, “political”, “racist”, “sexist”, “explicit”

Returns

A dictionary containing the joke.

Return type

dict

async get_safe_joke(joke_type='any')

Fetches safe jokes from the API. These jokes are family-friendly.

Parameters

joke_type (Optional[str]) – The type of joke you want to fetch. Allowed Values: “any”, “dark”, “pun”, “spooky”, “christmas”, “programming”, “misc”

Returns

A dictionary containing the joke.

Return type

dict

async get_waifu(waifu_type, *, plan)

Fetches waifus from the API.

Parameters
  • waifu_type (str) – The type of waifu you want to fetch. Allowed Values: “waifu”, “neko”, “shinobu”, “megumin”, “bully”, “cuddle”

  • plan (str) – The plan you bought to use the API.

async get_weather(city)

Fetches weather data from the API.

Parameters

city (str) – The city you want to fetch weather for.

Returns

A list containing the weather data.

Return type

list

async disconnect()

Disconnects the client from the API.

async restart()

Restarts the client’s connection with the API.

async connect()

Connects the client to the API, incase it’s not already connected.

Pages

  • Welcome to YARSAW! - The main page of the documentation

  • Client - Explains how to use the client - the main class [Very Important]

  • Utils - Extra support functions for Client’s functions