API reference

Client

This is the base asyncdagpi client you use to make requests.

This example initalises a basic client.

from asyncdagpi import Client
client = Client("your token")

Tip

You can also disable logging

from asyncdagpi import Client
client = Client(token, logging=False)

You can also setup a more advance client by passing in your own aiohttp ClientSession and Event Loop. If you are using discord.py it is adviseable to use the bot.loop as the event loop.

Warning

Please use this only if you know what you are doing. Do not use the aiohttp session used by discord.py.

from asyncndagpi import Client
loop = #Your Asyncio Event Loop
session = #Your Aiohttp session
client = Client(token, loop=loop, session=session)

Below is all of the methods of the client.

Client

class asyncdagpi.Client(token: str, *, session: Optional[aiohttp.client.ClientSession] = None, loop: Optional[asyncio.events.AbstractEventLoop] = None)[source]
Parameters
  • token – Your Dagpi Api token

  • **kwargs

    Extra arguments you may pass this can include

    • loop: an asyncio event loop for the asyncdagpi to use

    • session: an aiohttp ClientSession for dagpi to use

This will initialise an AsyncDagpiClient that you can use for making dagpi requests.

property ratelimits: asyncdagpi.objects.Ratelimits

Get ratelimits for your client

async image_process(feature: asyncdagpi.image_features.ImageFeatures, url: str, **kwargs: Any) asyncdagpi.image.Image[source]
feature: ImageFeature

a dagpi ImageFeature class

url: str

the Url for the Image Passed

kwargs:

based on the Docs for your Feature chose the right extra kwargs like text or username

Returns

asyncdagpi.Image Asyncdagpi Image Object

async special_image_process(url: str) asyncdagpi.image.Image[source]
url: str

the Url for the Image Passed

Returns

asyncdagpi.Image Asyncdagpi Image Object

async wtp() asyncdagpi.objects.WTP[source]

get a WTP data object :returns: asyncdagpi.WTP

get a Logo data object :returns: asyncdagpi.Logo

async roast() str[source]

Returns a string with a Roast :returns: str

async yomama() str[source]

Returns a YoMama Joke String :returns: str

async joke() str[source]

Gets a Funny Joke :returns: str

async fact() str[source]

Gets a Fun fact :returns: str

async eight_ball() str[source]

Gets an 8ball response :returns: str

async pickup_line() asyncdagpi.objects.PickupLine[source]

Get a PickupLine

async headline() asyncdagpi.objects.Headline[source]

Get a PickupLine

async captcha() asyncdagpi.objects.Captcha[source]

Get a captcha

async typeracer() asyncdagpi.objects.Typeracer[source]

Get a sentence on an image

async waifu() Dict[str, Any][source]

Get a Random Anime Waifu. Does not return a model due to sheer complexity and impracticality.

async data_ping() float[source]

Returns a float with the Data API’s ping

async image_ping() float[source]

Returns a float with the Image API’s ping

async close() None[source]

Shuts down the asyncdagpi Client

Danger

Closing the Client means a new one must be initialised otherwise there will be errors.

ImageFeatures

class asyncdagpi.ImageFeatures(value: str, description: str)[source]

Base ImageFatures that asyncdagpi has

classmethod from_path(path: str) asyncdagpi.image_features.IF[source]

Construct an Image Feature from it’s path.

classmethod mirror() asyncdagpi.image_features.IF[source]

Flip image horizontally (left to right).

classmethod flip() asyncdagpi.image_features.IF[source]

Flip the image vertically (top to bottom).

classmethod pixel() asyncdagpi.image_features.IF[source]

Pixelate an Image

classmethod colors() asyncdagpi.image_features.IF[source]

Analyse and get an Image’s Color Top 5 Colors

classmethod wanted() asyncdagpi.image_features.IF[source]

Get a wanted poster of an Image.

classmethod triggered() asyncdagpi.image_features.IF[source]

Get a triggered Image gif

classmethod america() asyncdagpi.image_features.IF[source]

The waving american flag on an image.gif

classmethod communism() asyncdagpi.image_features.IF[source]

Glory of the soviet Union on an image.gif

classmethod bomb() asyncdagpi.image_features.IF[source]

Kaboom

classmethod wasted() asyncdagpi.image_features.IF[source]

GTA V Wasted screen.

classmethod five_guys_one_girl() asyncdagpi.image_features.IF[source]

No I have never heard of this meme. Takes in 2 Image URL. Needs:

  • url

  • url2

classmethod slap() asyncdagpi.image_features.IF[source]

Have someone slap someone. Needs:

  • url

  • url2

classmethod why_are_you_gay() asyncdagpi.image_features.IF[source]

The infamous Why are you gay. Takes in 2 Image URL. Needs:

  • url

  • url2

classmethod invert() asyncdagpi.image_features.IF[source]

Invert an Image.

classmethod sobel() asyncdagpi.image_features.IF[source]

Cool SOBEL filter for Images. Only png’s.

classmethod triangle() asyncdagpi.image_features.IF[source]

Cool triangle edge detection for Images. Only png’s.

classmethod hog() asyncdagpi.image_features.IF[source]

Histogram of Oriented Gradients.

classmethod blur() asyncdagpi.image_features.IF[source]

Blurs an entire Image.

classmethod rgb() asyncdagpi.image_features.IF[source]

Get RGB information from an image.

classmethod angel() asyncdagpi.image_features.IF[source]

Make an Image Angelic.

classmethod satan() asyncdagpi.image_features.IF[source]

Make an Image the devil.

classmethod hitler() asyncdagpi.image_features.IF[source]

Make an Image as bad as hitler.

classmethod obama() asyncdagpi.image_features.IF[source]

The obama meme of someone awarding themselves.

classmethod bad() asyncdagpi.image_features.IF[source]

This image is bad.

classmethod sith() asyncdagpi.image_features.IF[source]

Laughs in Sithlord

classmethod jail() asyncdagpi.image_features.IF[source]

Put an Image behind bars.

classmethod fedora() asyncdagpi.image_features.IF[source]

Tips. Fedora

classmethod delete() asyncdagpi.image_features.IF[source]

Delete some trash

classmethod shatter() asyncdagpi.image_features.IF[source]

Broken like glass

classmethod gay() asyncdagpi.image_features.IF[source]

represent! Pastes a pride flag on an image.

classmethod pride() asyncdagpi.image_features.IF[source]

Pride flag overlay Needs:

  • flag (one of these flags):
    • asexual

    • bisexual

    • gay

    • genderfluid

    • genderqueer

    • intersex

    • lesbian

    • nonbinary

    • progress

    • pan

    • trans

    • agender

    • ally

    • polysexual

classmethod trash() asyncdagpi.image_features.IF[source]

Makes an Image trash.

classmethod deepfry() asyncdagpi.image_features.IF[source]

Deepfries an Image.

classmethod ascii() asyncdagpi.image_features.IF[source]

Turns an Image into a ascii-fied image.

classmethod charcoal() asyncdagpi.image_features.IF[source]

Turns an Image into a charcoal sketch.

classmethod poster() asyncdagpi.image_features.IF[source]

Posterizes an image.

classmethod sepia() asyncdagpi.image_features.IF[source]

Makes an image sepia tone.

classmethod polaroid() asyncdagpi.image_features.IF[source]

Frames an Image like a printed polaroid.

classmethod glitch() asyncdagpi.image_features.IF[source]

Cool Glitched image

classmethod swirl() asyncdagpi.image_features.IF[source]

Swirls the center of Image.

classmethod paint() asyncdagpi.image_features.IF[source]

Turns an Image into an oil painting.

classmethod sketch() asyncdagpi.image_features.IF[source]

How an artist would create an image.

classmethod spin() asyncdagpi.image_features.IF[source]

the gif goes round and round.

classmethod dissolve() asyncdagpi.image_features.IF[source]

Thanos snapped and back.

classmethod neon() asyncdagpi.image_features.IF[source]

A cool multicolored glowing neon sign from an image.

classmethod petpet() asyncdagpi.image_features.IF[source]

Pet Pet Pet.

classmethod comic() asyncdagpi.image_features.IF[source]

classic black and white comic.

classmethod burn() asyncdagpi.image_features.IF[source]

Burn an image untill there’s molten remains.

classmethod freeze() asyncdagpi.image_features.IF[source]

Get blasted by Mr.Freeze from batman.

classmethod earth() asyncdagpi.image_features.IF[source]

Become one with Rock.

classmethod night() asyncdagpi.image_features.IF[source]

Turns day into night on an Image.

classmethod magik() asyncdagpi.image_features.IF[source]

Magik an Image

classmethod stringify() asyncdagpi.image_features.IF[source]

Stringify an Image

classmethod rainbow() asyncdagpi.image_features.IF[source]

Rainbow light effect on image

classmethod solar() asyncdagpi.image_features.IF[source]

Solarizes an Image.

classmethod bonk() asyncdagpi.image_features.IF[source]

Bonk Someone

classmethod captcha() asyncdagpi.image_features.IF[source]

Creates a realistic Captcha Needs:

  • text

  • image

classmethod thought_image() asyncdagpi.image_features.IF[source]

Wraps Image and Text into a thought Needs:

  • text

  • image

classmethod tweet() asyncdagpi.image_features.IF[source]

Generates an accurate fake tweet Needs:

  • text

  • image

  • username

classmethod discord() asyncdagpi.image_features.IF[source]

Generated a realistic Discord Message Needs:

  • text

  • image

  • username

  • dark (boolean) default is true

classmethod youtube() asyncdagpi.image_features.IF[source]

Generated a realistic Yutube comment Needs:

  • text

  • image

  • username

  • dark (boolean) default is true

classmethod retro_meme() asyncdagpi.image_features.IF[source]

old 2012 advice animals style meme Needs:

  • top_text

  • bottom_text

  • image

classmethod motiv() asyncdagpi.image_features.IF[source]

old 2012 style Motiv memes Needs:

  • top_text

  • bottom_text

  • image

classmethod modern_meme() asyncdagpi.image_features.IF[source]

Mordern meme with text scaling Needs:

  • text

  • image

classmethod mosiac() asyncdagpi.image_features.IF[source]

Turn an image into a roman mosiac Needs:

  • image

  • pixels

classmethod cube() asyncdagpi.image_features.IF[source]

Turn an image into a cube Needs:

  • image

classmethod lego() asyncdagpi.image_features.IF[source]

image out of lego bricks Needs:

  • image

classmethod expand() asyncdagpi.image_features.IF[source]

blown out of proportions Needs:

  • image

classmethod from_string(feature: str) Optional[asyncdagpi.image_features.IF][source]

Get an image feature from a string

Parameters
  • cls (Type[IF]) – class stuff

  • feature (str) – string feature to try

Returns

Image Feature

Return type

IF

Response Models

Image Response

class asyncdagpi.Image(byt: bytes, image_format: str, process_time: str, original_url: str)[source]

An AsyncDagpi Image Returned This has special properties that can enhance the experience.

Attributes

image: io.BytesIO

BytesIO object with Image

format: str

String containing Image Format Either PNG or GIF

process_time: str

String for Time Taken by API to process Request

original_image: str

URL for the image passed to the API

size() int[source]

Returns the Size of the Image

read() bytes[source]

Get raw Image bytes :return: bytes

write(name: str, *, path: Optional[str] = None) None[source]

Writes the Image Object to file

Parameters

namestr the name of the file to save

kwargs: Optional To Pass in
  • path: path to write to can be relative/absolute. default is ./

Data Response Models

Data Objects returned by some Data API endpoints. The base class is.

class asyncdagpi.BaseDagpiObject(dictionary: Dict[str, Any])[source]

Base AsyncDagpi object

Attributes

dict: Dict

raw_data() Dict[str, Any][source]

Dictionary with Raw Data :returns Dict

All the below models are subclasses and will have all the same methods available to them.

WTP

class asyncdagpi.WTP(data: Dict[str, Any])[source]

A Dagpi PickupLine. A subclass of AsyncDagpi object

Attributes

dict: Dict

Dictionary with raw data (same returned by raw_data)

abilities: List[str]

A list containing the abilities the pokemon has

ascii: str

String containing ascii data of pokemons image

height: float

Float with height of pokemon

weight: float

Float with weight of pokemon

id: int

Integer with national dex id of pokemon

link: str

String containing pokemondb link for pokemon

name: str

String containing name of pokemon

answer: str

String containing url for answer image

question: str

String containing url for question image

PickupLine

class asyncdagpi.PickupLine(data: Dict[str, str])[source]

A Dagpi PickupLine

Attributes

dict: Dict

Dictionary with raw data (same returned by raw_data)

category: str

String containing Type of Pickup Line

line: str

String Containing Pickup Line

Errors

Asyncdagpi incorporates custom exceptions

Tip

AsyncDagpiException

This is the base excpetion

AsyncDagpiException

The base asyncdagpi exceptions

Use this to catch errors from the wrapper

SubExceptions

exception errors.BadUrl

The url provided is poorly framed

exception errors.Unauthorised

Raised for an API 401

exception errors.RateLimited

You are exceeding the API’s rate limits and built in Ratelimit handler Essentially a 429

exception errors.FileTooLarge

The image at source exceeds 10 MegaBytes

exception errors.InvalidFeature

The feature chosen is not valid Chose a valid feature from asyncdagpi.ImageFeature

exception errors.ParameterError

Parameters passed were not Sufficient

exception errors.ApiError

The equivalent of a 500, for the API when the status code returned indicates an API issue.

exception errors.ImageUnaccesible

The API was unable to get an image at your location

error_code: int

Containes the Code that the API returned

message: str

returns info about the reason image was unaccesible

__str__()

Returns a Concatenated HTTP code and Message