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

imgbb-image-uploader

v1.0.6

Published

imgbb-image-uploader is a lightweight Node.js library for uploading images to the ImgBB API. It provides a simple and easy-to-use interface for uploading images and retrieving their URLs.

Downloads

64

Readme

imgbb-image-uploader

imgbb-image-uploader

imgbb-image-uploader is a lightweight Node.js library for uploading images to the ImgBB API. It provides a simple and easy-to-use interface for uploading images and retrieving their URLs.

Usage

  1. Create account on imgbb website.

https://imgbb.com/

  1. Go to the imgbb API page and create a new API key.

https://api.imgbb.com/

  1. Install imgbb-image-uploader using npm:
npm install imgbb-image-uploader
  1. Here's an example of how to use imgbb-image-uploader:
import {imgbbUpload} "imgbb-image-uploader";


imgbbUpload({
  key: "your-api-key",// your imgbb api key
  image: image, // image selected from the file input
})
  .then((data) => {
    console.log("Image uploaded to ImgBB:", data);
  })
  .catch((error) => {
    console.error("Failed to upload image to ImgBB:", error);
  });
  1. You can also specify additional options when uploading an image, such as the image name and expiration time:
import imgbbUpload "imgbb-image-uploader";

// Upload an image to ImgBB with additional options

imgbbUpload({
  key: "your-api-key",// your imgbb api key
  image: image, // image selected from the file input
  expiration: 600,// 10 mins
  name: 'name-of-the-image', // name of the image
})
  .then((data) => {
    console.log("Image uploaded to ImgBB:", data);
  })
  .catch((error) => {
    console.error("Failed to upload image to ImgBB:", error);
  });

Parameters

  • key: The ImgBB API key to use for authentication.
  • image: The image selected from the file input.
  • name (optional): The name of the image file. If not provided, the name will be automatically detected when uploading a file with multipart/form-data.
  • expiration (optional): The expiration time for the uploaded image, in seconds. The uploaded image will be automatically deleted after this time.

Returns

This responses display all the image uploaded information in JSON format.

JSON the response will have headers status codes to allow you to easily notice if the request was OK or not. It will also output the status properties

{
  "data": {
    "id": "2ndCYJK",
    "title": "c1f64245afb2",
    "url_viewer": "https://ibb.co/2ndCYJK",
    "url": "https://i.ibb.co/w04Prt6/c1f64245afb2.gif",
    "display_url": "https://i.ibb.co/98W13PY/c1f64245afb2.gif",
    "width": "1",
    "height": "1",
    "size": "42",
    "time": "1552042565",
    "expiration": "0",
    "image": {
      "filename": "c1f64245afb2.gif",
      "name": "c1f64245afb2",
      "mime": "image/gif",
      "extension": "gif",
      "url": "https://i.ibb.co/w04Prt6/c1f64245afb2.gif"
    },
    "thumb": {
      "filename": "c1f64245afb2.gif",
      "name": "c1f64245afb2",
      "mime": "image/gif",
      "extension": "gif",
      "url": "https://i.ibb.co/2ndCYJK/c1f64245afb2.gif"
    },
    "medium": {
      "filename": "c1f64245afb2.gif",
      "name": "c1f64245afb2",
      "mime": "image/gif",
      "extension": "gif",
      "url": "https://i.ibb.co/98W13PY/c1f64245afb2.gif"
    },
    "delete_url": "https://ibb.co/2ndCYJK/670a7e48ddcb85ac340c717a41047e5c"
  },
  "success": true,
  "status": 200
}

License

This library is licensed under the MIT License. See the LICENSE file for details.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sahilverma-dev/imgbb-image-uploader.