Skip to content

Latest commit

 

History

History
106 lines (81 loc) · 5.33 KB

documentation.md

File metadata and controls

106 lines (81 loc) · 5.33 KB

imgbbpy

An Asynchronous and Synchronous API Wrapper for the Imgbb API.

Table of Contents

API Reference

Client

Async Client

class imgbbpy.aio.Client(key)
Represents an asynchronous client connection that connects to the Imgbb API for uploading.

Parameters:

  • key (str) - The API Key required to make a connection with the API.

await upload(*, url, file, name, expiration)
Parameters:

  • url (Optional[str]) - The URL of the image to upload. The image to upload should not be more than 32 MB.
  • file (Optional[str]) - The path of the image to upload. The image to upload should not be more than 32 MB.
  • name (Optional[str]) - The name of the image to set when uploading.
  • expiration (Optional[int]) - The expiration to set when you want the image to be auto deleted after certain time (in seconds 60 - 15552000). The uploaded image gets deleted automatically after 2592000 seconds (30 days) by default.

Note:

  • Both url and file are optional, but either url or file is needed to upload the image.

Returns:

  • Image - The uploaded image.

Raises:

  • TypeError - Raised when expiration is not of type int.
  • ImgbbError - Raised when:
    Both url and file is given.
    Either url or file is not given.
    An uncaught error occurs.
  • MinExpirationLimit - Raised when given expiration is lower than 60 seconds.
  • MaxExpirationLimit - Raised when given expiration is more than 15552000 seconds.

Sync Client

class imgbbpy.imgbb.Client(key)
Represents a synchronous client connection that connects to the Imgbb API for uploading. Parameters:

  • key (str) - The API Key required to make a connection with the API.

upload(*, url, file, name, expiration)
Parameters:

  • url (Optional[str]) - The URL of the image to upload. The image to upload should not be more than 32 MB.
  • file (Optional[str]) - The path of the image to upload. The image to upload should not be more than 32 MB.
  • name (Optional[str]) - The name of the image to set when uploading.
  • expiration (Optional[int]) - The expiration to set when you want the image to be auto deleted after certain time (in seconds 60 - 15552000). The uploaded image gets deleted automatically after 2592000 seconds (30 days) by default.

Note:

  • Both url and file are optional, but either url or file is needed to upload the image.

Returns:

  • Image - The uploaded image.

Raises:

  • TypeError - Raised when expiration is not of type int.
  • ImgbbError - Raised when:
    Both url and file is given.
    Either url or file is not given.
    An uncaught error occurs.
  • MinExpirationLimit - Raised when given expiration is lower than 60 seconds.
  • MaxExpirationLimit - Raised when given expiration is more than 15552000 seconds.

Models

Image

class imgbbpy.imgbbgallery.Image
Represents the uploaded image.
This is returned from Client.upload.

  • id (str) - The ID of the image.
  • filename - (str) - The filename of the image.
  • url (str) - The URL of the image.
  • size (int) - The size of the image in bytes.
  • expiration (int) - The time left (in seconds) for the image to expire.
  • mime (str) - The mime type of the image.
  • extension (str) - The extension of the image.
  • delete_url (str) - The delete URL to delete the image.

Exceptions

class imgbb.imgbberrors.ImgbbError

Base class for all Imgbb exceptions.

class imgbb.imgbberrors.MinExpirationLimit

Exeption raised when the expiration given is less than 60 seconds.

class imgbb.imgbberrors.MaxExpirationLimit

Exeption raised when the expiration given is more than 15552000 seconds.