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.
Most of the methods returns an Image instance, the attributes are the same from the ones returned by the API.
Examples with WaifuAioClient
import asyncio
from waifuim import WaifuAioClient
async def main():
wf = WaifuAioClient()
# Get a completely random image
image = await wf.search()
# Get an image by tags
image = await wf.search(
included_tags=['waifu','maid'],
excluded_tags=['ero'],
)
image = await wf.search(
excluded_tags=['maid'],
is_nsfw='null',
height="<=252"
)
# Get sfw waifu images ordered by FAVORITES
images = await wf.search(
included_tags=['waifu'],
is_nsfw='null',
many=True,
order_by='FAVORITES',
)
# Get a user favorites
favorites = await wf.fav(
token='if not provided, use the one in the client constructor',
)
# Edit your favorites
await wf.fav_delete(3133)
await wf.fav_insert(
3133,
user_id=11243585148445,
token='user_id and token are optional',
)
fav_state = await wf.fav_toggle(4401)
# will be equal to 'INSERTED' or 'DELETED'
await wf.close()
# You can also use a context manager but for multiple request it is not recommended
async with WaifuAioClient() as wf:
# Do your stuff
asyncio.run(main())
The Image and Tag instance
In most of the case the methods will return an Image instance.
The attributes are the same as the json keys that the api returns.
image = await wf.search()
>>> <waifuim.types.Image object at 0x76217ccf10>
image.url
>>> 'https://cdn.waifu.im/1982.jpg'
str(image)
>>> 'https://cdn.waifu.im/1982.jpg'
image.signature
>>> aa48cd9dc6b64367
image.tags[0]
>>> <waifuim.types.Tag object at 0x73214ccf10>
image.tags[0].name
>>> 'waifu'
Some useful kwargs in the constructor
from waifuim import WaifuAioClient
wf = WaifuAioClient(
session=an_aiohttpClientSession_created_asynchronously,
app_name="TheNameOfYourApplication",
token="The default token to use in routes requiring authentication.",
)
# ...
License
MIT © Buco
Metadata
Release files for waifuim.py 4.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| waifuim.py-4.3.0.tar.gz | 8.9 kB | Without provenance | Details for waifuim.py-4.3.0.tar.gz |
Release files / waifuim.py-4.3.0.tar.gz
| Download URL | waifuim.py-4.3.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c0293f7f93d5166160f789d120a3c4f350f9e0aae756b686f33da8b5e4d9645
|
|
BLAKE2b-256 checksum How to use checksums |
1130b2935afe6fb1b5387664150bc0332e5c39ba5ffd22e570c00c719639819e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.5
|
Security for waifuim.py 4.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.