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 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():
    # Depending on your usage of the Wrapper It's recommended to store the Client and not to open a session each time.
    async with WaifuAioClient() as wf:
        # Get a completely random image
        image = await wf.random()
        # Get an image by tags
        image = await wf.random(selected_tags=['waifu','maid'],excluded_tags=['ero'],excluded_files=['file1.notneeded'])
        # Get sfw waifu images ordered by FAVOURITES
        images = await wf.random(selected_tags=['waifu'],is_nsfw=['False'],many=True,order_by='FAVOURITES')
        # Get a user favourites images
        favs = await wf.fav(token='The user token if no token is provided it use the one in the client constructor')
        


asyncio.run(main())
import asyncio

from waifuim import WaifuAioClient


async def main():
    wf = WaifuAioClient()
    # Get a completely random image
    image = await wf.random()
    # Get an image by tags
    image = await wf.random(selected_tags=['waifu','maid'],excluded_tags=['ero'])
    # Get sfw waifu images ordered by FAVOURITES
    images = await wf.random(selected_tags=['waifu'],is_nsfw=['False'],many=True,order_by='FAVOURITES')
    # Get a user favourites images
    favs = await wf.fav(token='The user token if no token is provided it use the one in the client constructor')
    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


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

Uploaded Source

File details

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

File metadata

  • Download URL: waifuim.py-3.2.5.tar.gz
  • Upload date:
  • Size: 8.0 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

Hashes for waifuim.py-3.2.5.tar.gz
Algorithm Hash digest
SHA256 e3681a6516314c0b3f3a153ec9dabe3063ea761bc4f64759b4ccaf9d56336215
MD5 5a5a22edf33c9163134065fe583c6bd6
BLAKE2b-256 e939b99ebf912772f62dc787ac4a17edc531d30d12ed0af0bf4ca6777a4666a4

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