Guide to REST API data sources

Overview

In Klipfolio, data from web services such as Twitter or LinkedIn is accessed either by a dedicated service connector in Klipfolio's Connector Gallery or using the REST/URL connector which can connect to most APIs that use the REST (REpresentational State Transfer) protocol and one of the following authentication methods (if authentication is required):

As well, Klipfolio supports many web service APIs that use OAuth authentication.

NOTE: REST APIs with additional authentication requirements, such as an initial login request, may not be accessible using Klipfolio's REST/URL connector.

Introductory videos on APIs

Klipfolio API's 101

Klipfolio 401 Webinar -  Worksheet accompanying the 401 webinar

 

How to read an API query

Each web service API has its own unique definition and requirements, and it is necessary to refer to the web service API documentation for specific details:

  • user credentials (for example, username and password)
  • authentication method (OAuth, basic HTTP, 2-step Auth or API Key)
  • web service URL (address of the web service being queried, for example, http://api.linkedin.com)
  • endpoint names (the resources available to be queried, for example, in http://api.linkedin.com/v1/people, people is the endpoint)
  • parameters
    • dimensions, such as time or geographic location
    • metrics, the data being requested
    • time span, usually specified by start and end dates
  • parameter formats, in particular date formats (for example, yyyy-MM-dd, Unix time)
  • parameter combinations (which metrics can be used with which dimensions)
  • access method (GET, POST)
  • output format (CSV, JSON, XML)

API query syntax

Although there is no defined REST standard, many REST-based API queries use a syntax similar to:

<webServiceURL>/<version>/<endpointName>.<outputFormat>?<parameter1Name>=<parameter1Value>&<parameter2Name>=<parameter2Value>&<startDate>=01-01-2015&<endDate>={date.today}

A REST-based query may not include all elements shown. If the query includes parameters, the first parameter is prefixed with a question mark (?) and subsequent parameters are prefixed with and ampersand (&).

Signed Authentication Parameters

Some third-party APIs, such as Amazon Web Services and Moz, require a signed authentication parameter to be included in their API query to secure the identity of the user making the API query. A signed authentication parameter is comprised of one or more data elements, such as an API key or a user ID, that have been encrypted to produce a unique key. Klipfolio's Signed Authentication Builder (Hash Helper) provides a set of methods to create this signed authentication parameter. The data elements required to build the signed authentication parameter are specified by the third-party API. This signed authentication parameter is included in the API query following the same syntax as a regular parameter.

Examples

Yahoo Weather API query

http://weather.yahooapis.com/forecastrss?w=3369&u=c

where

<webserviceURL> = http://weather.yahooapis.com
<endpoint> = forecastrss
<parameter1Name> = w
<parameter1Value> = 3369
<parameter2Name> = u
<parameter2Value> = c

Twitter API query

https://api.twitter.com/1.1/followers/list.json

where

<webserviceURL> = https://api.twitter.com
<version> = 1.1
<endpoint> = followers/list
<outputFormat> = json

Supported methods

Klipfolio supports the GET and POST methods for requesting data from an API. The API will specify which method to use: most APIs use GET, however some APIs, such as Infusionsoft, use POST for certain queries.

Creating a REST/URL data source

To create a REST/URL data source:

    1. Go to the Library and select the Data Sources tab.
    2. Click Create a New Data Source and select REST/URL from the Core Connectors list.
    3. On the screen presented, fill in the required information:
      • Query URL: type the API query according to the web service's API specification
      • Data Format: select the output format returned by the API (Excel, CSV, JSON or XML)
      • Methodselect the method required by the API (GET or POST).
    1. Set Query Parameters as required by the API (many APIs do not require any). Type a Name and Value for each parameter required and set one of the following Types:
      • Query - This is equivalent to the parameters in an API query. You can either include them in the URL or in this section.
      • Header - If required by the API (for example, Smartsheets), add parameters to the query Header.
      • Cookie - If required by the API, Cookie parameters are used for session-related data.
    1. Configure the authentication.

a) If the API uses API Key authentication

        • set Query Parameters according to the API's specification for the API Key parameter
        • leave Authentication Type set to None

b) Otherwise, select the Authentication Type and fill in the required fields.

    1. Click Get Resource, then Continue once the data is verified.
    2. Save and name the data source.