Skip to main content

A simple API wrapper to interact with the Sheri Blossom API.

Project description

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

SheriAPI-1.0.4.tar.gz (4.2 MB view details)

Uploaded Source

Built Distribution

SheriAPI-1.0.4-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file SheriAPI-1.0.4.tar.gz.

File metadata

  • Download URL: SheriAPI-1.0.4.tar.gz
  • Upload date:
  • Size: 4.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for SheriAPI-1.0.4.tar.gz
Algorithm Hash digest
SHA256 dd89e8e45f5912848903231ecc9dc2212b9545f123a95fee1299bd447600b7dd
MD5 9d795d5d4a72b06fcfba716c0016b149
BLAKE2b-256 a9c8d453a456c4381a24944fc6eeb62bd9ddccae9323d27ee3139656b4584f92

See more details on using hashes here.

File details

Details for the file SheriAPI-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: SheriAPI-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for SheriAPI-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fa6dd9ebd2bc22b4efc3e21990951b4143ad19310e99907cc2b6e550460e10f6
MD5 87b63a4dd222bbbb8c827e9823a9f0a1
BLAKE2b-256 cbef2915ce3e6ec46f871c6d9e5ac875106151ce173734fd34d7588651b9d551

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page