A simple NPM package for uploading images to ImgBB using different input types (Base64 string, URL, or file path).
npm install imgbb-uploader-api
const { uploadImage } = require('imgbb-uploader-api');
const apiKey = 'YOUR_CLIENT_API_KEY';
const base64Image = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
uploadImage(base64Image, apiKey)
.then(response => console.log('Image uploaded successfully:', response))
.catch(error => console.error('Failed to upload image:', error));
const { uploadImage } = require('imgbb-uploader-api');
const apiKey = 'YOUR_CLIENT_API_KEY';
const imageUrl = 'https://example.com/image.jpg';
uploadImage(imageUrl, apiKey)
.then(response => console.log('Image uploaded successfully:', response))
.catch(error => console.error('Failed to upload image:', error));
const { uploadImage } = require('imgbb-uploader-api');
const apiKey = 'YOUR_CLIENT_API_KEY';
const imagePath = './path/to/image.jpg';
uploadImage(imagePath, apiKey)
.then(response => console.log('Image uploaded successfully:', response))
.catch(error => console.error('Failed to upload image:', error));
-
imageInput
: (Required) The image input, which can be:- A base64-encoded string.
- A URL to an image.
- A file path to an image.
-
apiKey
: (Required) Your ImgBB API key. -
expiration
: (Optional) The time in seconds for the image to expire. there no expiration in default