Skip to main content

A Python wrapper for waifu.im API.

Project description

waifuim.py

PyPI - Python Version PyPI License

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 wich 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 url for the waifu tag (12 is the tag id)
        waifulist= await wf.nsfw(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"])

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 url for the waifu tag (12 is the tag id)
    waifulist= await wf.nsfw('waifu',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"])
    await wf.close()

asyncio.run(main())

Some interesting attributes

You can pass some useful kwargs to the class

import aiohttp

from waifuim import WaifuAioClient

wf = WaifuAioClient(session=aiohttp.ClientSession(),
    appname="MyDiscordBot",
    token="Default token",
    maintenance_error="Custom maintenance message")

# ...

License

MIT © Buco

Project details


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.1.0.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file waifuim.py-2.1.0.tar.gz.

File metadata

  • Download URL: waifuim.py-2.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for waifuim.py-2.1.0.tar.gz
Algorithm Hash digest
SHA256 78f806e78f6d23749098ad6e1c311e59f3c6ef37948fbbb71a9836dd6330a331
MD5 a8d0b9f99a50ff80f459bdb7b01126cd
BLAKE2b-256 1f2b9c7d436cae828308ba8a4d35a6a71b4c2644a4e68834a0dbc03cbc04e656

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page