npm

Need private packages and team management tools?Check out npm Orgs. »

kim-api

0.0.4 • Public • Published

kim-api

An API-wrapper for Kie's Image Machine (kim). Completely anonymous image hosting.

  • Unlimited image uploads
  • No api key required
  • No config files required
  • Built on request

kim supports the following file extensions: png, jpg, jpeg, gif


Uploading an image to kim.

// require kim-api
const kim = require('kim-api');
const path = require('path');
 
// upload
kim.upload(path.join(__dirname, 'image.png'))
    .then(img => {
        console.log(img.url);
    })
    .catch(err => {
        // ...
    })

Installation

npm

$ npm install kim-api

yarn

$ yarn add kim-api

Methods

.upload(file)

Upload an image to kim. Returns a promise.

Example response:

{
    "status":"success",
    "data":{
        "image_id":"DQNMMxSm8SbYSJVt15cecbke8LqsidfE",
        "filetype":"png"
    },
    "url": "https://kim.kieranhowland.co.uk/uploads/DQNMMxSm8SbYSJVt15cecbke8LqsidfE/"
}

.datauri(imageID)

Get the datauri of an image uploaded to kim. Returns a promise.

Example response:

{
    "status":"success",
    "data": {
        "uri":"data:image/png;base64,iVBORw0..."
    }
}

.uploads()

Get the total amount of images uploaded to kim. Returns a promise.

Example response:

{
    "status":"success",
    "data":{
        "uploads": 4627
    }
}

Errors

If there's an error on kim server-sided, an Error will be thrown.

Error: kim-api error: recieved status code 400 - invalidFileExtension
    // stack trace ...

If not all arguments required for a method are provided, a TypeError will be thrown.

TypeError: No image provided.
    // stack trace ...

.catch() these errors to prevent UnhandledPromiseRejectionWarnings.

install

npm i kim-api

Downloadsweekly downloads

2

version

0.0.4

license

Apache 2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability