imgbox-js 🗳️
Lightweight IMGBOX API. Unlimited free hosting for images 🗳️.
Installation
npm install imgbox-js
Import
import { imgbox } from 'imbox-js'
const imgbox = require('imgbox-js')
Usage
imgbox(images, options)
.then(res => console.log(res))
imgbox('https://picsum.photos/200/300')
.then(res => console.log(res));
imgbox('my_folder/img.jpg')
.then(res => console.log(res));
const images = [
'https://picsum.photos/200/300',
'my_folder/img.jpg',
'my_folder/photo.png'
]
imgbox(images)
.then(res => console.log(res));
- Singe URL/Path + Filename
const image1 = { source: 'https://picsum.photos/200/300', filename: 'Photo from URL' }
imgbox(image1)
.then(res => console.log(res));
const image2 = { source: 'my_folder/photo.png', filename: 'Photo from Local Path' }
imgbox(image2)
.then(res => console.log(res));
- Multiple URL/Path + Filename
const image1 = { source: 'https://picsum.photos/200/300', filename: 'Lorem Photos from URL' }
const image2 = { source: 'img.jpg', filename: 'Lorem Photos from Path' }
imgbox([ image1, image2 ])
.then(res => console.log(res));
const images = [
'https://picsum.photos/200/300',
'img.jpg'
]
const options = {
auth_cookie: 'nxIksl91sXxS8ls1',
album_title: 'Lorem Photos Album',
content_type: 'safe',
thumbnail_size: '350c',
comments_enabled: false,
logger: true
}
imgbox(images, options)
.then(res => console.log(res));
Note : 🚀
options | type | description |
---|
auth_cookie | string | As default images is uploaded as a guest. To get cookie and upload as logged in user jump here |
album_title | string | Title of gallery/album |
content_type | string | 'safe' = family safe content 'adult' = adult content |
thumbnail_size | string | c = thumbnail will be cropped r = thumbnail will be resized '100c' , '150c' , '200c' , '250c' , '300c' , '350c' , '500c' , '800c' '100r' , '150r' , '200r' , '250r' , '300r' , '350r' , '500r' , '800r' |
comments_enabled | boolean | enable/disable comment section for particular image/gallery true , false |
logger | boolean | enable/disable request log true , false |
- Multiple URL/Path + Filename + Create Album
const auth_cookie = '_imgbox_session=ZmtjTFR...'
const images = [
{ source: 'https://picsum.photos/200/300', filename: 'Lorem Photos from URL' },
{ source: 'https://picsum.photos/200', filename: 'Lorem Photos from URL' },
{ source: 'https://picsum.photos/300', filename: 'Lorem Photos from URL' },
{ source: 'img.jpg', filename: 'Lorem Photos from Path' }
]
const options = {
auth_cookie: auth_cookie,
album_title: 'Lorem Photos Album',
content_type: 'safe',
thumbnail_size: '350c',
comments_enabled: false,
logger: false
}
imgbox(images, options).then(res => console.log(res));
const options = {
album_title: 'My Album',
content_type: 'safe',
thumbnail_size: '350r',
comments_enabled: 1
}
imgbox('https://picsum.photos/200', options)
.then(res => console.log(res));
imgbox('img.jpg', options)
.then(res => console.log(res));
const auth_cookie = '_imgbox_session=ZmtjTFR...'
const options = {
auth_cookie: auth_cookie,
scope: 'all',
page: 1,
logger: true
}
imgbox
.getImages(options)
.then(res => console.log(res));
Note : 🚀
options | type | description |
---|
auth_cookie | string | this is mandatory to get access to your images. |
scope | string | 'all' = get all images from your account 'unbound' = get images that belong to a gallery |
page | number | pagination, return empty array [] if images are empty in particular page |
logger | boolean | enable/disable request log true , false |
const options = {
auth_cookie: '_imgbox_session=ZmtjTFR...',
page: 1,
logger: true,
order_by: 'updated'
}
imgbox
.getGalleries(options)
.then(res => console.log(res));
Note : 🚀
order_by
is string
.
Possible values : 'updated'
or 'created'
or 'title'
const images = [
'KEqFMTKX',
'https://imgbox.com/xxXsDvUv'
]
imgbox
.deleteImages(images, { auth_cookie: '_imgbox_session=ZmtjTFR...' })
.then(res => console.log(res));
const gallery_edit_url = 'https://imgbox.com/gallery/edit/zTFrSKPFF4/JR0hdNWKEAeChDFi'
imgbox
.deleteGallery(gallery_edit_url, { auth_cookie: '_imgbox_session=ZmtjTFR...' })
.then(res => console.log(res
- Enable/Disable Gallery Comment
const gallery_edit_url = 'https://imgbox.com/gallery/edit/zTFrSKPFF4/JR0hdNWKEAeChDFi'
imgbox
.updateComment(gallery_edit_url, { comments_enabled: true })
.then(res => console.log(res));
Get Login Cookie
Unfortunately, there's no way to get Http Only Cookie
by just using Javascript. IMGBOX does not provide such as api_token
either. So, to get access it's protected route we need to open up the browser and grab the Cookie after we are logged in.
const auth_cookie = '_imgbox_session=ZmtjTFR...'
Contributing
Pull requests are welcome.
License
MIT