API Reference and Developer Documentation

SoftLayer Object Storage

Kraken API allows you to store optimized images directly in your SoftLayer Object Storage. With just a few additional parameters your optimized images will be pushed to SoftLayer in no time.

Mandatory Parameters:
userYour SoftLayer Username.
keyYour SoftLayer API Key.
containerName of a destination container on your SoftLayer account.
regionShort name of the region your container is located in. This can be one of the following:
syd01 lon02 mon01 dal05 tok02
tor01 hkg02 mex01 par01 fra02
mil01 sjc01 sng01 mel01 ams01
Optional Parameters:
pathDestination path in your container (e.g. "images/layout/header.jpg"). Defaults to root "/".
cdn_urlA boolean value (true or false) instructing Kraken API to return a public CDN URL of your optimized file. Defaults to false meaning the non-CDN URL will be returned.

The above parameters must be passed in a sl_store object:

{
    "sl_store": {
        "user": "your-softlayer-account",
        "key": "your-softlayer-key",
        "container": "destination-container",
        "region": "your-container-location"
    }
}

Below you can find an example of a complete JSON request that uses sl_store to push optimized image into your SoftLayer Object Storage container. We will use url option to feed the API with a URL of image to be optimized. The below request uses example (fake) credentials - you will need to replace them with your real ones.

{
    "auth": {
        "api_key": "your-api-key",
        "api_secret": "your-api-secret"
    },
    "sl_store": {
        "user": "SLOS299821-2:SL299821",
        "key": "2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c",
        "container": "assets",
        "region": "fra02",
        "cdn_url": true,
        "path": "images/layout/header.png"
    },
    "url": "http://awesome-website.com/images/header.png",
    "wait": true,
    "lossy": true
}
<?php

require_once("Kraken.php");

$kraken = new Kraken("your-api-key", "your-api-secret");

$params = array(
    "url" => "http://awesome-website.com/images/header.png",
    "wait" => true,
    "lossy" => true,
    "sl_store" => array(
        "user" => "SLOS299821-2:SL299821",
        "key" => "2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c",
        "container" => "assets",
        "region" => "fra02",
        "cdn_url" => true,
        "path" => "images/layout/header.png"
    )
);

$data = $kraken->url($params);

if ($data["success"]) {
    echo "Success. Optimized image URL: " . $data["kraked_url"];
} else {
    echo "Fail. Error message: " . $data["message"];
}
var Kraken = require("kraken");

var kraken = new Kraken({
    "api_key": "your-api-key",
    "api_secret": "your-api-secret"
});

var params = {
    "url": "http://awesome-website.com/images/header.png",
    "wait": true,
    "lossy": true,
    "sl_store": {
        "user": "SLOS299821-2:SL299821",
        "key": "2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c",
        "container": "assets",
        "region": "fra02",
        "cdn_url": true,
        "path": "images/layout/header.png"
    }
};

kraken.url(params, function(status) {
    if (status.success) {
        console.log("Success. Optimized image URL: %s", status.kraked_url);
    } else {
        console.log("Fail. Error message: %s", status.message);
    }
});
require 'rubygems'
require 'kraken-io'

kraken = Kraken::API.new(
    :api_key => 'your-api-key',
    :api_secret => 'your-api-secret'
)

params = {
    :wait => true,
    :lossy => true,
    :sl_store => {
        'user' => 'SLOS299821-2:SL299821',
        'key' => '2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c',
        'container' => 'assets',
        'region' => 'fra02',
        'cdn_url' => true,
        'path' => 'images/layout/header.png'
    }
}

data = kraken.url('http://awesome-website.com/images/header.png', params)

if data.success
    puts 'Success! Optimized image URL: ' + data.kraked_url
else
    puts 'Fail. Error message: ' + data.message
end
package main

import (
    "log"
    "github.com/kraken-io/kraken-go"
)

func main() {
    kr, err := kraken.New("your-api-key", "your-api-secret")

    if err != nil {
        log.Fatal(err)
    }

    params := map[string]interface {} {
        "wait": true,
        "lossy": true,
        "url": "http://awesome-website.com/images/header.png",
        "sl_store": map[string]interface {} {
            "user": "SLOS299821-2:SL299821",
            "key": "2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c",
            "container": "assets",
            "region": "fra02",
            "cdn_url": true,
            "path": "images/layout/header.png"
        }
    }

    data, err := kr.URL(params)

    if err != nil {
        log.Fatal(err)
    }

    if data["success"] != true {
        log.Println("Failed, error message ", data["message"])
    } else {
        log.Println("Success, Optimized image URL: ", data["kraked_url"])
    }
}
from krakenio import Client

api = Client('your-api-key', 'your-api-secret')

data = {
    'wait': True,
    'lossy': True,
    'sl_store': {
        'user': 'SLOS299821-2:SL299821',
        'key': '2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c',
        'container': 'assets',
        'region': 'fra02',
        'cdn_url': True,
        'path': 'images/layout/header.jpg'
    }
}

result = api.url('http://awesome-website.com/images/header.png', data);

if result.get('success'):
    print result.get('kraked_url')
else:
    print result.get('message')

If your SoftLayer container is CDN-enabled and you've passed "cdn_url": true parameter in your JSON request the optimization results will contain kraked_url which points directly to the optimized file location in your SoftLayer CDN, for example:

http://1c231.http.fra02.cdn.softlayer.net/images/layout/header.jpg

If your container is not CDN-enabled kraked_url will point to the optimized image URL in the Kraken API:

http://dl.kraken.io/api/ec/df/a5/c55d5668b1b5fe9e420554c4ee/header.jpg