Skip to main content

waifu-py

PyPI - Python Version PyPI - Downloads PyPI License

A simple Python wrapper for the waifu.pics API.

Table of Contents

Installation

Python 3.6 or higher is required.

Install from PyPI

$ pip install waifu-py

Install from source

$ pip install git+https://github.com/IchBinLeoon/waifu-py

Usage

You can use either WaifuClient or WaifuAioClient, depending on whether you want a synchronous wrapper class, or an asynchronous wrapper class. Below are some examples of how to use WaifuClient and WaifuAioClient.

Usage Examples with WaifuClient

from waifu import WaifuClient

client = WaifuClient()

# Get one SFW image
sfw_waifu: str = client.sfw(category='waifu')

# Get 30 unique SFW images
sfw_megumin_list: list = client.sfw(category='megumin', many=True)

# Get 30 unique SFW images and exclude images in list
sfw_megumin_list_exclude: list = client.sfw(category='megumin', many=True, exclude=['https://i.waifu.pics/IqD8csE.png', 'https://i.waifu.pics/NV-dfTH.png'])

# Get one NSFW image
nsfw_neko: str = client.nsfw(category='neko')

# Get 30 unique NSFW images
nsfw_trap_list: list = client.nsfw(category='trap', many=True)

Async Usage Examples with WaifuAioClient

import asyncio

from waifu import WaifuAioClient


async def main():
    async with WaifuAioClient() as client:

        # Get one SFW image
        sfw_neko: str = await client.sfw(category='neko')

        # Get 30 unique SFW images
        sfw_shinobu_list: list = await client.sfw(category='shinobu', many=True)

        # Get one NSFW image
        nsfw_waifu: str = await client.nsfw(category='waifu')

        # Get 30 unique NSFW images
        nsfw_neko_list: list = await client.nsfw(category='neko', many=True)

asyncio.run(main())
import asyncio

from waifu import WaifuAioClient


async def main():
    client = WaifuAioClient()

    # Get one SFW image
    sfw_waifu: str = await client.sfw(category='waifu')

    # Get 30 unique NSFW images
    nsfw_waifu_list: list = await client.nsfw(category='waifu', many=True)

    await client.close()

asyncio.run(main())

Usage Examples with own Session

If you want to use your own requests or aiohttp session, you can do that too.

WaifuClient

import requests

from waifu import WaifuClient

session = requests.Session()
client = WaifuClient(session=session)

# ...

WaifuAioClient

import asyncio

import aiohttp

from waifu import WaifuAioClient


async def main():
    session = aiohttp.ClientSession()
    async with WaifuAioClient(session=session) as client:
        # ...

asyncio.run(main())
import asyncio

import aiohttp

from waifu import WaifuAioClient


async def main():
    session = aiohttp.ClientSession()
    client = WaifuAioClient(session=session)

    # ...

    await client.close()

asyncio.run(main())

Image Categories

You can also view all valid image categories.

from waifu import ImageCategories

print(ImageCategories)

Output:

{
   "sfw":[
      "waifu",
      "neko",
      "shinobu",
      "megumin",
      "bully",
      "cuddle",
      "cry",
      "hug",
      "awoo",
      "kiss",
      "lick",
      "pat",
      "smug",
      "bonk",
      "yeet",
      "blush",
      "smile",
      "wave",
      "highfive",
      "handhold",
      "nom",
      "bite",
      "glomp",
      "slap".
      "kill",
      "kick",
      "happy",
      "wink",
      "poke",
      "dance",
      "cringe"
   ],
   "nsfw":[
      "waifu",
      "neko",
      "trap",
      "blowjob"
   ]
}

Contribute

Contributions are welcome! Feel free to open issues or submit pull requests!

License

MIT © IchBinLeoon

Metadata

Release files for waifu-py 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for waifu-py 1.0.3
File Size Uploaded Provenance
waifu-py-1.0.3.tar.gz 6.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for waifu-py 1.0.3
File Interpreter ABI Platform
waifu_py-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 16.8 kB

Release files / waifu-py-1.0.3.tar.gz

Download URL waifu-py-1.0.3.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e75ced660ca40744e4dd23989e50c82e17060329175d540a2b51640862c5b6d8
BLAKE2b-256 checksum
How to use checksums
9c57fe104e9f11ca8ffae879d575a42fa889bdb786d397780a66cb3a6328a647
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release files / waifu_py-1.0.3-py3-none-any.whl

Download URL waifu_py-1.0.3-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0da9d2cddf628f944b1c9a97720392d804579b21d58b9bb4b0ef2b80c430ef61
BLAKE2b-256 checksum
How to use checksums
ef0f57e6801444fe2ab6f89b406bb28ad113f3a658206f7793078ef459794973
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Security for waifu-py 1.0.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page