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

Uploaded Source

File details

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

File metadata

  • Download URL: waifuim.py-3.1.0.tar.gz
  • Upload date:
  • Size: 7.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 973729734062e43ba515eff145914320fcfa4636c64e4196a1c670c367027b1d
MD5 b2a849335717b2678a5e6949480eae63
BLAKE2b-256 38f8af67df30514adee29963202af33f18cee78c5cd6b1776646a3cbe4ec146e

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