A simple API wrapper to interact with the Sheri Blossom API.
Project description
[THIS ISN'T FINISHED YET REE]
A simple API wrapper for Sheri Blossom (https://sheri.bot/)
The API provides several endpoints for free however some will require a unique token.
You can obtain your token by going to the dashboard (https://sheri.bot/settings/) and scrolling to the bottom.
Examples:
from SheriAPI import SheriAPI
api = SheriAPI(token="Your Token Here")
res = await api.get('hug')
# Get the image URL
url = res.url
# Or the report URL
report_url = res.report_url
# Save the image to disk
await res.save('/')
You can also use it in a context manager if you like:
from SheriAPI import SheriAPI
async with SheriAPI(token="Your Token Here") as api:
img = await api.get('fox')
img2 = await api.get('cat')
await img.save('/foxes')
await img2.save('/cats')
Additionally, there are enums of which list all applicable API endpoints. You may use them as well.
from SheriAPI import SheriAPI, FreeEndpoint
async with SheriAPI() as api:
img = await api.get(FreeEndpoint.Fox)
await img.save('/foxes')
You can specify an amount of images to return from the API. If it is any amount other than 1, it will be a list of SheriResponse objects.
from SheriAPI import SheriAPI, FreeEndpoint
async with SheriAPI() as api:
imgs = await api.get(
FreeEndpoint.Fox,
count=10
)
for img in imgs:
await img.save(f"images/{img.image_hash}")
The only time a token is needed is when attempting to use an endpoint that is not free. For example:
from SheriAPI import SheriAPI, SFWEndpoint
# Works
async with SheriAPI(token="Your Token Here") as api:
img = await api.get(SFWEndpoint.Paws)
print(img.url)
# Raises an InvalidToken exception
async with SheriAPI() as api:
img = await api.get(SFWEndpoint.Paws)
print(img.url)
Lastly, in order to use NSFW endpoints, you must pass in allow_nsfw=True
.
from SheriAPI import SheriAPI, NSFWEndpoint
# Works
async with SheriAPI(
token="Your Token Here",
allow_nsfw=True
) as api:
img = await api.get(NSFWEndpoint.Gay)
print(img.url)
# Raises NSFWEndpointWithoutAllowNSFW exception
async with SheriAPI(token="Your Token Here") as api:
img = await api.get(NSFWEndpoint.Dick_Wank)
print(img.url)
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
File details
Details for the file SheriAPI-0.9.1.tar.gz
.
File metadata
- Download URL: SheriAPI-0.9.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b91fac61dfe38c5310696e90f5398be9771b0ec850bc28c281c045dbb22633dd |
|
MD5 | ced00b3c2f58eb19a21e0f37c86eaeb4 |
|
BLAKE2b-256 | 7d0820577a79de00bb2d285f634afd97a156e0cafadcc6744dbd7cd931b89e8f |