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

Uploaded Source

File details

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

File metadata

  • Download URL: waifuim.py-3.2.3.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.3.tar.gz
Algorithm Hash digest
SHA256 2ad73e28f090a1353283dda4270e0faf7cd1e612e61faa223af4bc8c46e6c590
MD5 633e14640007106a34eb8f818432085c
BLAKE2b-256 b6a4621ea4ae4a419779da61ee31aef23df0b6c978b4f675a50091149dd338b5

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