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

Uploaded Source

Supported by

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