REST API


The Easel.ly REST API provides access in creating, updating and downloading infographic.


Creating an API Key

Access to the API is available to everyone with a Pro Easel.ly account. To get the API key, log in using your valid Easel.ly account and visit the My Account page to generate a new API key or manage existing keys. It is important that you treat this key as if it were a secret password. With an API key, anyone can access endpoints from your account.

Note that generating API key is only allowed to Pro Account Users.

Authentication

The API is secured with ApiKeyAuth. You must use your API Key to sign requests when accessing the API.

For more examples, please view our sample code.


Making Requests

To make a request you simply need to point to https://www.easel.ly/. Also, each request must have the apiKey parameter which is equal to your account’s API key. Invalid or absence of the apiKey parameter will lead to HTTP response with code 401 “Unauthorized”. Using a non Pro account will lead to HTTP response with code 405 “Your account must be pro to use API”.

For reference, here is a list of our public API endpoints, API Explorer, and sample code.


Supported File Formats and HTTP Responses

Examples:

  • 200 Successful operation - returns data as JSON in the response body.
  • 400 Invalid status value - may return extra error description in response body.
  • 401 Unauthorized - may return extra error description in response body.
  • 405 405 Your account must be pro to use API - may return extra error description in response body.

Sample Codes

PHP:

public function getInfographicByCanvasID(){
    $client = new \GuzzleHttp\Client();
    $url = "https://www.easel.ly/pages/generateJSON";
    $api_key = "API_KEY_HERE";
    $canvas_id = "https://s3.amazonaws.com/easel.ly/all_easels/310246/1544516577";

    try {
        $headers = [
            'Accept' => 'application/json',
            'apiKey' => $api_key
        ];
        $paramFilters = ['id' => $canvas_id];
        $response = $client->request('GET', $url, [
            'headers' => $headers,
            'query' => $paramFilters
        ]);

        echo $response->getStatusCode(); 
        echo $response->getReasonPhrase(); 
        echo $response->getProtocolVersion(); 
        echo $response->getBody(); 
    } catch (GuzzleHttp\Exception\BadResponseException $e) {
        $response = $e->getResponse();
        $responseBodyAsString = $response->getBody()->getContents();
        print_r($responseBodyAsString);
    }
}

Java:

import java.io.*;
import java.net.*;
import org.apache.http.*;
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.*;
import org.apache.http.impl.client.*;

public class GetInfographic {
    public static void main(String[] args) throws ClientProtocolException, IOException {

        try {
            HttpClient client  = HttpClients.createDefault();
            String url = "https://www.easel.ly/pages/generateJSON"; 
            String api_key = "API_KEY_HERE"; 
            String canvas_id = "https://s3.amazonaws.com/easel.ly/all_easels/310246/1544516577"; 

            URIBuilder builder = new URIBuilder(url);
            builder.addParameter("apiKey", api_key);
            builder.addParameter("id", canvas_id);

            String fullUrl = builder.build().toString();
            HttpGet request = new HttpGet(fullUrl);
            request.addHeader("Accept", "*/*");
            request.addHeader("Content-Type", "application/json");
            request.addHeader("apiKey", api_key);

            HttpResponse response  = client.execute(request);

            BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
            String line  = "";
            while ((line = rd.readLine()) != null) {
                System.out.println(line);
            }
        
        } catch (URISyntaxException | IOException e) {
            // Handle errors 
        } 
    }
}

Python:

from django.shortcuts import render
import import requests

endpoint = 'https://www.easel.ly/pages/generateJSON'
api_key = 'API_KEY_HERE'
canvas_id = 'https://s3.amazonaws.com/easel.ly/all_easels/310246/1544516577'

params = {'id' : canvas_id}
headers = {'apiKey' : api_key, 'accept':'application/json'}

response = requests.get(endpoint, headers = headers, params = params)

print (response.content)
                    

Easel.ly © Copyright 2018