API Reference and Developer Documentation

Getting Started

To plug into the power of Kraken.io API you need to Sign Up for Kraken.io API services and obtain your unique API Key and API Secret. You will find those in your Account under the API Credentials section. Once you have set-up your Account, you can start using Kraken.io API in your applications.

We love helping customers get up and running with our system!
Should you have any questions about Kraken.io API simply contact us at support@kraken.io

How To Use

Kraken.io supports JPEG, PNG, GIF (including animated GIFs) and SVG images. You can optimize your images in two ways - by providing a URL of the image you want to optimize or by uploading an image file directly to Kraken.io API.

The first option (image URL) is great for images that are already in production or any other place on the Internet. The second one (direct upload) is ideal for your deployment process, build script or the on-the-fly processing of your user's uploads where you don't have the images available online yet.

Read more on:


Kraken.io API accepts HTTPS POST requests only. Note that we offer API access through SSL secured connections, which means you have to use the HTTPS protocol in your requests.

Every POST request body must include a well-formed JSON object with mandatory auth section conaining your api_key and api_secret, for example:

    "auth": {
        "api_key": "your_api_key",
        "api_secret": "your_api_secret"


$kraken = new Kraken("your_api_key", "your_api_secret");
var Kraken = require("kraken");

var kraken = new Kraken({
    "api_key": "your_api_key",
    "api_secret": "your_api_secret"
require 'rubygems'
require 'kraken-io'

kraken = Kraken::API.new(
    :api_key => 'your_api_key',
    :api_secret => 'your_api_secret'
package main

import (

func main() {
    kr, err := kraken.New("your_api_key", "your_api_secret")

    if err != nil {
using Kraken;
using Kraken.Http;

var connection = Connection.Create("your_api_key", "your_api_secret");
from krakenio import Client

api = Client('your_api_key', 'your_api_secret')


Depending on a choosen response option (Wait or Callback URL) in the response body you will find either the optimization ID or optimization results containing a success property, file name, original file size, kraked file size, amount of savings, original image dimensions (px) and optimized image URL:

HTTP/1.1 200 OK

    "success": true,
    "file_name": "header.jpg",
    "original_size": 324520,
    "kraked_size": 165358,
    "saved_bytes": 159162,
    "original_width": 640,
    "original_height": 480,
    "kraked_url": "http://dl.kraken.io/ec/df/a5/c55d5668b1b5fe9e420554c4ee/header.jpg"

If anything goes wrong with the optimization process you will find the "success": false property and error message in the response body:

HTTP/1.1 422 Unprocessable Entity

    "success": false,
    "message": "Couldn't fetch this image from a given URL"

Read more on:

Downloading Optimized Images

Remember - never link to optimized images offered to download. You have to download them first, and then replace them in your websites or applications. Optimized images are available on our servers for one hour only.