https://github.com/ichbinleoon/waifu-py
🖼️ A simple Python wrapper for the waifu.pics API
https://github.com/ichbinleoon/waifu-py
anime api-wrapper python3 waifu waifu-pics
Last synced: about 2 months ago
JSON representation
🖼️ A simple Python wrapper for the waifu.pics API
- Host: GitHub
- URL: https://github.com/ichbinleoon/waifu-py
- Owner: IchBinLeoon
- License: mit
- Created: 2021-05-02T01:04:56.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-26T17:31:55.000Z (almost 4 years ago)
- Last Synced: 2025-03-28T09:42:55.580Z (2 months ago)
- Topics: anime, api-wrapper, python3, waifu, waifu-pics
- Language: Python
- Homepage: https://pypi.org/project/waifu-py/
- Size: 16.6 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# waifu-py
[](https://pypi.org/project/waifu-py/)
[](https://pypi.org/project/waifu-py/)
[](https://pypi.org/project/waifu-py/)
[](https://github.com/IchBinLeoon/waifu-py/blob/main/LICENSE)A simple Python wrapper for the waifu.pics API.
## Table of Contents
- [Installation](#Installation)
- [Usage](#Usage)
- [Contribute](#Contribute)
- [License](#License)## Installation
**Python 3.6 or higher is required.**Install from PyPI
```shell
$ pip install waifu-py
```Install from source
```shell
$ pip install git+https://github.com/IchBinLeoon/waifu-py
```## Usage
You can use either WaifuClient or WaifuAioClient, depending on whether you want a synchronous wrapper class, or an asynchronous wrapper class. Below are some examples of how to use WaifuClient and WaifuAioClient.### Usage Examples with WaifuClient
```python
from waifu import WaifuClientclient = WaifuClient()
# Get one SFW image
sfw_waifu: str = client.sfw(category='waifu')# Get 30 unique SFW images
sfw_megumin_list: list = client.sfw(category='megumin', many=True)# Get 30 unique SFW images and exclude images in list
sfw_megumin_list_exclude: list = client.sfw(category='megumin', many=True, exclude=['https://i.waifu.pics/IqD8csE.png', 'https://i.waifu.pics/NV-dfTH.png'])# Get one NSFW image
nsfw_neko: str = client.nsfw(category='neko')# Get 30 unique NSFW images
nsfw_trap_list: list = client.nsfw(category='trap', many=True)
```### Async Usage Examples with WaifuAioClient
```python
import asynciofrom waifu import WaifuAioClient
async def main():
async with WaifuAioClient() as client:# Get one SFW image
sfw_neko: str = await client.sfw(category='neko')# Get 30 unique SFW images
sfw_shinobu_list: list = await client.sfw(category='shinobu', many=True)# Get one NSFW image
nsfw_waifu: str = await client.nsfw(category='waifu')# Get 30 unique NSFW images
nsfw_neko_list: list = await client.nsfw(category='neko', many=True)asyncio.run(main())
```
```python
import asynciofrom waifu import WaifuAioClient
async def main():
client = WaifuAioClient()# Get one SFW image
sfw_waifu: str = await client.sfw(category='waifu')# Get 30 unique NSFW images
nsfw_waifu_list: list = await client.nsfw(category='waifu', many=True)await client.close()
asyncio.run(main())
```### Usage Examples with own Session
If you want to use your own requests or aiohttp session, you can do that too.#### WaifuClient
```python
import requestsfrom waifu import WaifuClient
session = requests.Session()
client = WaifuClient(session=session)# ...
```#### WaifuAioClient
```python
import asyncioimport aiohttp
from waifu import WaifuAioClient
async def main():
session = aiohttp.ClientSession()
async with WaifuAioClient(session=session) as client:
# ...asyncio.run(main())
```
```python
import asyncioimport aiohttp
from waifu import WaifuAioClient
async def main():
session = aiohttp.ClientSession()
client = WaifuAioClient(session=session)# ...
await client.close()
asyncio.run(main())
```### Image Categories
You can also view all valid image categories.
```python
from waifu import ImageCategoriesprint(ImageCategories)
```
Output:
```shell
{
"sfw":[
"waifu",
"neko",
"shinobu",
"megumin",
"bully",
"cuddle",
"cry",
"hug",
"awoo",
"kiss",
"lick",
"pat",
"smug",
"bonk",
"yeet",
"blush",
"smile",
"wave",
"highfive",
"handhold",
"nom",
"bite",
"glomp",
"slap".
"kill",
"kick",
"happy",
"wink",
"poke",
"dance",
"cringe"
],
"nsfw":[
"waifu",
"neko",
"trap",
"blowjob"
]
}
```## Contribute
Contributions are welcome! Feel free to open issues or submit pull requests!## License
MIT © [IchBinLeoon](https://github.com/IchBinLeoon/waifu-py/blob/main/LICENSE)