AsyncClient

Same as Client but this is completely async class. This class is suitable for async programs like discord bots etc.

All the parameters, attributes and methods are same as Client except all methods are coroutine and need to be awaited. For example:

await AsyncClient.get_ai_response('Hi')

Simple example

Just to assure, This is a simple example for you using this class.

import randomstuff
import asyncio

client = randomstuff.AsyncClient(api_key="api-key")

async def coro():
    ai = await client.get_ai_response("hi")
    image = await client.get_image("any")
    joke = await client.get_joke("any")
    weather = await client.get_weather("new york")
    await client.close()
    print("AI: ", ai.message)
    print("Joke: ", joke.joke)
    print("Image: ", image)
    print("Temprature in NY: ", weather.current.temperature)

loop = asyncio.get_event_loop()
loop.run_until_complete(coro())    

Last updated