Sklik API

Sklik API Drak

Introduction

The Sklik API is a simple interface for developers who want to flexibly manage Sklik accounts. API is based on the XML-RPC protocol. You should have an understanding of this protocol and have common programming skills to use this API. XML-RPC is available in many programming languages. Using the Sklik API, you can create and manage campaigns, groups, keywords, ads and their statistics.

Versions

Logo API Drak Current stable Sklik API version is called Cipisek. New beta version is called Drak which is in testing process. Old Sklik API version is called Bajaja. New Sklik API version is released if parameters or response of some method is changed in a backward-incompatible way.

Following XML-RPC endpoints can be used:

See below for sandbox endpoints.

Paying for the API

Sklik API is free of charge. (Of course you are still charged for clicks on your ads.)

Developing API applications

For testing and developing API applications you can use the API sandbox. It doesn't contain any data – only the data you create in it. The username and login for the access to sandbox is the same as your account. All sandbox data will be deleted and account info synchronized each day after midnight. XML-RPC endpoints for sandbox environment are:

Differences between Sklik API versions Bajaja and Cipisek

Changes that are introduced in Cipisek:

Differences between Sklik API versions Cipisek and beta version of Drak

Changes that are introduced in bete Drak:

Changes that will be introduced in Drak: - All features meantioned in beta plus JSON - API

JSON API

Description

Json-api is simple http/json interface. This interface allows using JSON over HTTP as a communication protocol with our API(instead of XMLRPC or FASTRPC). Returns http response with results in json.

Using Json api is simple, only thing you must know is that method is in url and parameters for this method are in json (see examples).

Note: Json does not support some types used in XML-RPC/FAST-RPC protocol. These types are datetime and binary. Our Json-api accepts datetime in string ISO(YYYY-MM-DDThh:mm:ss, YYYY-MM-DD hh:hh:ss+TT:tt) format or in format YYYY-MM-DD (Y=year, M=month, D=day, h=hour, m=minute, s=second, T=time zone hour, t=time zone minute). Binary format must be convertible base64.

Simple examples use

example in python

    
import requests
from requests import post
import json
response = post("https://api.sklik.cz/jsonApi/drak/client.login",
                       json=("accoun@seznam.cz", "password"))
response_data = response.json()
print "Response client.login:", response_data
response = post("https://api.sklik.cz/jsonApi/drak/campaigns.createReport", json=[{'session': response_data['session']},
                                                            {'dateFrom': '2005-01-01', 'dateTo':  '2016-12-01 12:00:00+01:00'},
                                                            {'statGranularity': 'monthly'}])
response_data = response.json()
print "Response campaigns.createReport:", response_data

response = post("https://api.sklik.cz/jsonApi/drak/campaigns.stats", json=[{'session': response_data['session']}, response_data['reportId'], {'limit': 100, 'offset': 0, 'displayColumns': ['id', 'impressions', 'clicks']} ]) response_data = response.json() print "Response campaigns.stats:", response_data

example in php

    

function executePostRequest($postData, $url){ $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_POST => TRUE, CURLOPT_HTTPHEADER => array("Content-type: application/json"), CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POSTFIELDS => json_encode($postData) ));

// Create the context for the request $context = stream_context_create(array( 'https' => array( 'method' => 'POST', 'content' => json_encode($postData) ) ));

// Send the request $response = curl_exec($ch);

// Decode the response return json_decode($response, TRUE); }

$postData = array ( "accoun@seznam.cz", "password" );

$responseData = executePostRequest($postData, "https://api.sklik.cz/jsonApi/drak/client.login");

// Print the date from the responsponse = curl_exec($ch); print_r( $responseData );

$postData = array( array( 'session' => $responseData['session'], ), array( 'dateFrom' => '2005-01-01', 'dateTo' => '2016-12-01 12:00:00+01:00' ), array( 'statGranularity' => 'monthly' ) );

$responseData = executePostRequest($postData, "https://api.sklik.cz/jsonApi/drak/campaigns.createReport");

// Print the date from the responsponse = curl_exec($ch); print_r( $responseData );

$postData = array( array( 'session' => $responseData['session'], ), $responseData['reportId'], array( 'limit' => 100, 'offset' => 0, 'displayColumns' => array('id', 'impressions', 'clicks') ) );

$responseData = executePostRequest($postData, "https://api.sklik.cz/jsonApi/drak/campaigns.stats");

print_r( $responseData );

example in java

    

package cz.seznam.sklik.HttpJsonTest;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.stream.Collectors;

import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder;

/ * Jsonapi call / public class App {

public static String readInput(InputStream input) throws IOException {
    try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) {
        return buffer.lines().collect(Collectors.joining("\n"));
    }
}

public static void main( String[] args )
{
    HttpClient httpClient = HttpClientBuilder.create().build();
    try{
        HttpPost request = new HttpPost("https://api.sklik.cz/jsonApi/drak/client.login");
        StringEntity params = new StringEntity("[\"account@seznam.cz\", \"password\"]");
        request.addHeader("Content-Type", "application/json");
        request.setEntity(params);
        HttpResponse response = httpClient.execute(request);
        if (response != null) {
            InputStream in = response.getEntity().getContent();
            String getData = readInput(in);
            System.out.println(getData);
        }
    }catch(Exception e){
        e.printStackTrace();
    }

}

}

            
        

Copyright © 1996-2017

www.seznam.cz   Help   Contact