lieuweberg / kim-api

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

Home Page:https://npmjs.org/package/kim-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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

https://npmjs.org/package/kim-api

License:Apache License 2.0


Languages

Language:JavaScript 100.0%