An Asynchronous and Synchronous API Wrapper for the Imgbb API.
-
API Reference
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
andfile
are optional, but eitherurl
orfile
is needed to upload the image.
Returns:
- Image - The uploaded image.
Raises:
- TypeError - Raised when
expiration
is not of type int. - ImgbbError - Raised when:
Bothurl
andfile
is given.
Eitherurl
orfile
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.
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
andfile
are optional, but eitherurl
orfile
is needed to upload the image.
Returns:
- Image - The uploaded image.
Raises:
- TypeError - Raised when
expiration
is not of type int. - ImgbbError - Raised when:
Bothurl
andfile
is given.
Eitherurl
orfile
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.
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.
Base class for all Imgbb exceptions.
Exeption raised when the expiration given is less than 60 seconds.
Exeption raised when the expiration given is more than 15552000 seconds.