Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including kim-api with all npm packages installed. Try it out:

var kimApi = require("kim-api")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

kim-api v0.0.4

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

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.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free