npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imgbox-js

v1.0.35

Published

Lightweight Imgbox API. Unlimited free hosting for images 🗳️.

Downloads

67

Readme

imgbox-js 🗳️

Code Quality Score Code Quality Score GitHub license npm version

Lightweight IMGBOX API. Unlimited free hosting for images 🗳️.

Installation

npm install imgbox-js

Import

import { imgbox } from 'imbox-js'
// or
const imgbox = require('imgbox-js')

Usage

  • Pattern
imgbox(images, options)
    .then(res => console.log(res))

// images is mandatory
// options is optional
  • Singe URL/Path
imgbox('https://picsum.photos/200/300')
    .then(res => console.log(res));

imgbox('my_folder/img.jpg')
    .then(res => console.log(res));
  • Multiple URL/Path
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));

  • Images + Options
const images = [
    'https://picsum.photos/200/300',
    'img.jpg'
]

const options = {
    auth_cookie: 'nxIksl91sXxS8ls1', // default null 
    album_title: 'Lorem Photos Album', // default null 
    content_type: 'safe', // default 'safe' 
    thumbnail_size: '350c', // default '100c'
    comments_enabled: false, // default false 
    logger: true // default 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));
  • URL/Path + Create Album
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));

  • Get Images
const auth_cookie = '_imgbox_session=ZmtjTFR...'

const options = {
    auth_cookie: auth_cookie, // mandatory
    scope: 'all', // optional, default 'all'
    page: 1, // optional, default 1
    logger: true // optional, default 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 |

  • Get Galleries
const options = {
    auth_cookie: '_imgbox_session=ZmtjTFR...', // mandatory
    page: 1, // optional, default 1
    logger: true,  // optional, default true
    order_by: 'updated'  // optional, default 'updated'
}

// get galleries along with it's images from your account
imgbox
    .getGalleries(options)
    .then(res => console.log(res));

Note : 🚀 order_by is string. Possible values : 'updated' or 'created' or 'title'


  • Delete Images
// you can pass ID or Image's URL
// as Array 
const images = [
    'KEqFMTKX',
    'https://imgbox.com/xxXsDvUv'
]

// delete images from your account
imgbox
    .deleteImages(images, { auth_cookie: '_imgbox_session=ZmtjTFR...' })
    .then(res => console.log(res));
  • Delete Gallery
// url got from upload images + create album
const gallery_edit_url = 'https://imgbox.com/gallery/edit/zTFrSKPFF4/JR0hdNWKEAeChDFi'

// delete as logged in user
imgbox
    .deleteGallery(gallery_edit_url, { auth_cookie: '_imgbox_session=ZmtjTFR...' })
    .then(res => console.log(res

  • Enable/Disable Gallery Comment
// url got from upload images + create album
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. get_login_cookie.jpg

// then you can use it whenever you dealing with this API, eg.
const auth_cookie = '_imgbox_session=ZmtjTFR...'

Contributing

Pull requests are welcome.

License

MIT