Linkredirector API

The Linkredirector API provides programmatic access to create smart links. Our API is organized around REST and uses HTTP response codes to indicate API errors.
API Endpoint
https://api.linkredirector.com

Authentication

Authenticate when using the API by including your secret API key in the request. You can create and delete API keys inside the Link manager.

Your API keys carry many privileges, so be sure to keep them secret! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.

HTTP Basic Auth is used for authentication with the API. Provide your API key as the basic auth username. There's no need to provide a password.

All API requests must be made over HTTPS. Calls made over plain HTTP or without athentication will fail.
Basic Auth Authentication in Curl
curl https://api.linkredirector.com \
   -u API_KEY_GOES_HERE:

Errors

Linkredirector uses conventional HTTP response codes to indicate the success of an API request.

Codes in the 2xx range indicate success and the 4xx range indicate an error that failed given the information provided (e.g. a required parameter was omitted etc.). Codes in the 5xx range indicate an error with Linkredirector's servers.
HTTP Status Code Summary
200 - OK Everything worked as expected.
400 - Bad Request The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized No valid API key provided.
402 - Request Failed The parameters were valid but the request failed.
404 - Not Found The requested resource doesn't exist..
429 - Too Many Requests Too many requests hit the API too quickly.
500, 502, 503, 504 - Server Errors Something went wrong on Linkredirector's end.

Responses

The API will always respond with a JSON. The structure of the response can vary between different methods.
Successful Response Example
{
	"result" : {
		"link" : "http://lrd.to/skp2kSs"
	}
}

Error Response Example
{
	"error":{
		"code" : "authentication_failed",
		"description" : "Valid API key is missing."
	}
}

PHP Example

<?php

$linkredirector_secret_api_key = 'API_KEY_GOES_HERE';

$data = array('url'=>'http://www.amazon.com/Traction-Get-Grip-Your-Business/dp/1936661837');
$post_json = json_encode($data);

$ch = curl_init("https://api.linkredirector.com/v1/links");
curl_setopt($ch, CURLOPT_USERPWD, $linkredirector_secret_api_key . ':');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($post_json))
);

$result = curl_exec($ch);
curl_close($ch);

?>

Python Example

import requests
import json

linkredirector_secret_api_key = 'API_KEY_GOES_HERE'

data = {'url' : 'http://www.amazon.com/Traction-Get-Grip-Your-Business/dp/1936661837'}

r = requests.post(
        'https://api.linkredirector.com/v1/links',
        data=json.dumps(data),
        headers={"Content-Type": "application/json"},
        auth=(linkredirector_secret_api_key,''),
        )
Please contact us if you have questions, feedback, contributions or just want to say hi.