0.0.4 • Published 5 years ago

kim-api v0.0.4

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
5 years ago

kim-api

npm.io npm.io

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.

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago