Skip to main content

A Python wrapper for waifu.im API.

Project description

horiapi.py

PyPI - Python Version PyPI License

A Python wrapper for waifuim 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/Bucolo/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 horiapi 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','file3.jpeg'],gif=False)

        # Get your gallery (returns a dict)
        gallery=await wf.fav(insert=['file1','file2.png','file3.jpeg'],delete=['file1','file2.png','file3.jpeg'],newtoken="The new token you want to use from now on instead of the one passed at the begining (or not).")

        #get the endpoints
        endpoints=await wf.endpoints(full=True) #it is optional you can simply not set it to True and get the endpoints without details.

asyncio.run(main())
import asyncio

from horiapi import WaifuAioClient


async def main():
    haioct=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(insert=['file1','file2.png','file3.jpeg'],delete=['file1','file2.png','file3.jpeg'],newtoken="The new token you want to use from now on instead of the one passed at the begining (or not).")

    # Get the endpoints
    endpoints=await wf.endpoints(full=True) #it is optional you can simply not set it to True and get the endpoints without details.
    await wf.close()

asyncio.run(main())

Some interesting attributes

You can pass some useful kwargs to the class

import aiohttp

from horiapi import WaifuAioClient

wf = WaifuAioClient(session=aiohttp.ClientSession(),appname="MyDiscordBot",token="The Token that fav will use if newtoken isn't provided.",maintenance_error="The error message that you want to raise if the api is returning a 502.")

# ...

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

Uploaded Source

File details

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

File metadata

  • Download URL: waifuim.py-1.0.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for waifuim.py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6ee4e02287efba929f821f5726efe267edf78035980138d2b8d70d9415a73ce8
MD5 7c03405727b70f14749571ca00ac9e26
BLAKE2b-256 b038b1a30f09ced85c1e34ed368ba4836752352fcff1ba561e80888e0e32693a

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