📁
randomstuff.py
  • randomstuff.py
  • Clients
    • Client
    • AsyncClient
  • Data Classes
    • AIResponse
    • Joke
    • JokeFlags
    • Waifu
    • Weather
    • WeatherLocation
    • CurrentWeather
    • WeatherForecast
  • Sub modules
    • utils
  • Errors tree
    • Forbidden
      • BadAPIKey
      • PlanNotAllowed
    • ArgumentError
      • InvalidPlanError
      • InvalidVersionError
      • InvalidServerError
      • InvalidType
      • InvalidCityError
    • HTTPError
  • Brief
    • Warnings
    • Lists
    • Unique ID
    • Joke 101
    • FAQ
    • Changelogs
Powered by GitBook
On this page

Was this helpful?

  1. Clients

AsyncClient

PreviousClientNextAIResponse

Last updated 3 years ago

Was this helpful?

Same as 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 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())    

Client
Client