API Reference¶
The following section outlines the API of weeb.sh.
Note
This module uses the Python logging module to log diagnostic and errors in an output independent way. If the logging module is not configured, these logs will not be output anywhere.
Weeb.sh Client¶
-
class
weebapi.client.
Client
(api_key: str, wolke_token: bool = True, v2_api: bool = False, base_url: str = 'https://api.weeb.sh/', bot=None, loop=<_UnixSelectorEventLoop running=False closed=False debug=False>)[source]¶ Client object for Weeb.sh V2
This is a client object for Weeb.sh API. Here are two versions. Basic without discord.py bot and a pluggable version that inserts this client object directly into your discord.py bot.
- Represents a client connection that connects to weeb.sh. It works in two modes:
As a standalone variable.
Plugged-in to discord.py Bot or AutoShardedBot, see
Client.pluggable
- Parameters
api_key (
str
) – Your weeb.sh api token.wolke_token (bool[Optional]) – Not required. Is the api token type Wolke or Bearer. Default: True
v2_api (bool[Optional]) – Not required. Use v2 API. Default: False
**base_url (str[Optional]) – Not required. Specify different DBL API url.
**base_url – Not required. Specify different base url.
**bot (Bot or AutoShardedBot) – Your bot client from discord.py
**loop (asyncio loop) – Your asyncio loop.
-
classmethod
pluggable
(bot, api_key: str, *args, **kwargs)[source]¶ Pluggable version of Client. Inserts Client directly into your Bot client. Called by using bot.dbl
- Parameters
bot (discord.ext.commands.Bot or discord.ext.commands.AutoShardedBot) – Your bot client from discord.py
api_key (
str
) – Your weeb.sh api token.
Note
Takes the same parameters as
Client
class. Usage changes tobot.weebsh
. (bot
is your bot client variable)
-
get_image
(image: str) → weebapi.data_objects.Image[source]¶ This function is a coroutine.
This function gets image by it’s ID.
- Parameters
image (
str
orweebapi.data_objects.Image
) – Image ID from string orweebapi.data_objects.Image
object.- Returns
-
get_preview
(type_name: str, hidden: bool = False, nsfw: int = 1) → weebapi.data_objects.Preview[source]¶ This function is a coroutine.
This function gets a preview of the specified image type.
- Parameters
- Returns
-
get_random
(tags: str = None, image_type: str = None, nsfw: int = 1, hidden: bool = False, file_type: str = None) → weebapi.data_objects.Image[source]¶ This function is a coroutine.
This function gets a random image of the specified tags or the image type.
Note
Make sure you either use comma separated or list of tags and/or one image type. You cannot leave both
tags
norimage_type
variable blank, one of them must be used.- Parameters
**tags (
str
orlist
) – One tag or comma separated tags or list of image tags.**image_type (
str
) – Specify image type.**hidden (
bool
) – Get hidden image tags. Defaults to False.**nsfw (
int
) – Display options for NSFW content. Look for the valid values in the box above.**file_type (
str
) – One ofjpg, jpeg, png, gif
file types.
- Returns
Returns the
weebapi.data_objects.Image
object.
This function is a coroutine.
This function gets the list of all available image tags.
- Parameters
- Returns
Returns the list of
weebapi.data_objects.Tag
objects.
-
get_types
(hidden: bool = False, nsfw: int = 1) → list[source]¶ This function is a coroutine.
This function gets the list of all available image types.
- Parameters
- Returns
Returns the list of
weebapi.data_objects.ImageType
objects.
Data objects¶
Here is the collection of all data objects that this API wrapper uses.
Image¶
-
class
weebapi.data_objects.
Image
(snowflake: str, image_type: str, base_type: str, nsfw: bool, file_type: str, mime_type: str, tags: list, url: str, hidden: bool, account: str, client, source: str = '')[source]¶ Represents an image from Weeb.sh.
bool
– Is image private.
list
– List of Tag objects.
This function is a coroutine.
Adds tags to this image.
- Parameters
tags (
list
) – List of strings.- Raises
Forbidden: – If required permissions are absent.