semvec/pypi-packages huggingface dataset:
random-api 0.1
A python API wrapper for https://random-api.nitcord.repl.co/api
License: MIT
Requires Python: >=3.8
Keywords: Animals,API,Hamburger,Pats,Headpats,API Wrapper

# random-api
Python Wrapper for https://random-api.nitcord.repl.co/api<br>
Discord Server: https://discord.gg/ESPMP7BEeJ<br>
Made for burber. (Hamburger#0001)<br>

## Simple Usage
```py
import random_api
from asyncio import get_event_loop

async def run():
    animal = await random_api.get_animal("dog")
    print(animal.name, animal.image, animal.fact)

    random = await random_api.random_animal()
    print(random.name, random.image, random.fact)

    await random_api.close()

get_event_loop().run_until_complete(run())
```

## Using an existing aiohttp client session
```py
import random_api
import aiohttp

my_session = aiohttp.ClientSession(...)
random_api.set_session(my_session)
```

## Downloading an image response from the API
```py
import random_api
from asyncio import get_event_loop

async def run():
    animal = await random_api.random_animal()

    img = await animal.download_image()
    with open(f"{animal.name}.png", "wb" as f:
        f.write(img)
        f.close()

    await random_api.close()

get_event_loop().run_until_complete(run())
```