API Reference and Developer Documentation
SoftLayer Object Storage
For quick API reference and testing, you can find our OpenAPI docs page at the following link
https://api.kraken.io/v1/docs
https://api.kraken.io/v1/docs
Kraken.io 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: | |
user | Your SoftLayer Username. |
key | Your SoftLayer API Key. |
container | Name of a destination container on your SoftLayer account. |
region | Short name of the region your container is located in. This can be one of the following:syd01 lon02 mon01 dal05 tok02tor01 hkg02 mex01 par01 fra02mil01 sjc01 sng01 mel01 ams01 |
| Optional Parameters: | |
path | Destination path in your container (e.g. "images/layout/header.jpg"). Defaults to root "/". |
cdn_url | A boolean value (true or false) instructing Kraken.io 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": "files/image.png"
},
"url": "https://example.com/image.png",
"wait": true,
"lossy": true
}<?php
require_once("Kraken.php");
$kraken = new Kraken("your_api_key", "your_api_secret");
$params = array(
"url" => "https://example.com/image.png",
"wait" => true,
"lossy" => true,
"sl_store" => array(
"user" => "SLOS299821-2:SL299821",
"key" => "2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c",
"container" => "assets",
"region" => "fra02",
"cdn_url" => true,
"path" => "files/image.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": "https://example.com/image.png",
"wait": true,
"lossy": true,
"sl_store": {
"user": "SLOS299821-2:SL299821",
"key": "2ccaaba70f2115de17f31744e1e09fef300c806f5b2b10ee2230129a62df0b7c",
"container": "assets",
"region": "fra02",
"cdn_url": true,
"path": "files/image.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' => 'files/image.png'
}
}
data = kraken.url('https://example.com/image.png', params)
if data.success
puts 'Success! Optimized image URL: ' + data.kraked_url
else
puts 'Fail. Error message: ' + data.message
endpackage main
import (
"log"
"github.com/kraken-io/kraken-go"
)