The Feedlr.io API allows you to perform a number of the operations you can normally. All requests should be made to the
related endpoint on https://api.feedlr.io
.
To authenticate with the API you'll the the username for your account and an API key. You can get the key in your account on the API Keys page. Use the following method to authenticaate with the API:
POST https://api.feedlr.io/auth/login
If successful, the response will contain a token to use in future requests and a timeout for the token:
{
"success": true,
"token": "3o5rwzmscw4-gbo7j5ogifr3m7thplbdn5bzb4b7",
"timeout": "2017-03-29T02:17:59+00:00"
}
If the authentication fails, you'll be given an value of false
in the success
return value and a message
will accompany it with more information:
{
"success": false,
"message": "Invalid API key"
}
You should then use the API token for to things in your requests: setting the value as the X-Token
value in a
header and using it to generate a HMAC hash of the request contents to be placed in the X-Token-Hash
header. Here's
an example of performing this with the PHP HTTP Client Guzzle:
<php
$token = '3o5rwzmscw4-gbo7j5ogifr3m7thplbdn5bzb4b7';
$body = json_encode(['test' => 'foo']);
$hash = hash_hmac('SHA256', $body, $token);
$client = new GuzzleHttp\Client();
$res = $client->request('GET', 'https://api.feedlr.io/user', [
'headers' => [
'Content-Type' => 'application/json',
'X-Token' => $token,
'X-Token-Hash' => $hash
],
'body' => $body
]);
echo $res->getBody();
?>
The Link endpoints can be used to read and create new shortened links on your account.
URL:
GET https://api.feedlr.io
Request:
{
"source": "http://your-url.com"
}
Response:
{
"success": true,
"message": {
"source": "http://foobar.com",
"code": "mk",
"short_link": "http://feedlr-short.localhost/mk"
}
}
Errors:
None
URL:
POST https://api.feedlr.io
Request:
{
"source": "http://your-url.com"
}
Response:
{
"success": true,
"message": {
"links": [
{
"id": 1,
"user_id": 11,
"source": "https:\/\/google.com",
"code": "raYPi3q",
"created_at": "2016-11-17 03:11:55",
"updated_at": "2016-11-17 03:11:55"
},
{
"id": 201,
"user_id": 11,
"source": "http:\/\/www.phpdeveloper.org\/news\/24620",
"code": "dp",
"created_at": "2016-11-23 13:45:52",
"updated_at": "2016-11-23 13:45:52"
},
[... more results ...]
]
}
}
Errors:
None