A Python wrapper for waifu.im API.
Project description
waifuim.py
A Python wrapper for waifu.im API.
Table of Contents
Installation
Python 3.6 or higher is required.
Install from PyPI
$ pip install waifuim.py
Install from source
$ pip install git+https://github.com/Waifu-im/waifuim.py
Usage
For now, you can only use WaifuAioClient which is async. Maybe a sync client will be released in the future.
Examples with WaifuAioClient
import asyncio
from waifuim import WaifuAioClient
async def main():
async with WaifuAioClient() as wf:
# Get the json that the api return for the waifu tag
waifujson = await wf.sfw("waifu", raw=True)
# Get one random image URL for the waifu tag
waifu_url = await wf.sfw("waifu")
# Get 30 images URLs for the waifu tag (12 is the tag ID)
waifulist = await wf.sfw(12, many=True)
# Get one ero image excluding some files and the .gif extension
ero = await wf.nsfw("ero", exclude=["file1", "file2.png"], gif=False)
# Get your gallery (returns a dict)
gallery = await wf.fav(toggle=["file20"], insert=["file1"], token="A token")
# Get the endpoints
endpoints = await wf.endpoints(full=True) # it is optional
# Get some informations about one or multiple images
info = await wf.info(images=["file1.png", "file2"])
# Get the 30 most liked waifu images
top = await wf.sfw("waifu", many=True, top=True)
# Get completely random images, you can use same kwargs as SFW and NSFW
random = await wf.random()
asyncio.run(main())
import asyncio
from waifuim import WaifuAioClient
async def main():
wf = WaifuAioClient()
# Get the json that the api return for the waifu tag
waifujson = await wf.sfw("waifu", raw=True)
# Get one random image URL for the waifu tag
waifu_url = await wf.sfw("waifu")
# Get 30 images URLs for the waifu tag (12 is the tag ID)
waifulist = await wf.sfw(12, many=True)
# Get one ero image excluding some files and the .gif extension
ero = await wf.nsfw("ero", exclude=["file1", "file2.png", "file3.jpeg"], gif=False)
# Get your gallery (returns a dict)
gallery = await wf.fav(toggle=["file20"], delete=["file1"])
# Get the endpoints
endpoints = await wf.endpoints(full=True) # it is optional
# Get some informations about one or multiple images
info = await wf.info(images=["file1.png", "file2"])
# Get the 30 most liked maid images
top = await wf.sfw("maid", many=True, top=True)
# Get completely random images, you can use same kwargs as SFW and NSFW
random = await wf.random()
await wf.close()
asyncio.run(main())
Some interesting attributes
You can pass some useful kwargs to the class
from waifuim import WaifuAioClient
wf = WaifuAioClient(
session=an_aiohttpClientSession_created_asynchronously,
appname="TheNameOfYourApplication",
token="The default token to use in routes requiring authentication.",
)
# ...
License
MIT © Buco
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
waifuim.py-2.4.6.tar.gz
(7.5 kB
view details)
File details
Details for the file waifuim.py-2.4.6.tar.gz.
File metadata
- Download URL: waifuim.py-2.4.6.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38c13d06b85dab4d2ca9ac53b85d4195435c91d02404749e4d68f794d4e9aa20
|
|
| MD5 |
dc58934d7298b6b17f6509cba9a3c16d
|
|
| BLAKE2b-256 |
74f893b4d632c45a0fa63a2ed6ca973a2a87eec306b2e07fafa906c2f22f3912
|