API Docs

 

Links

All relative URLs in this document have the following base https://ninjalinka.com/1.0

Create a new link

POST /links

Make a HTTP POST request to the /links endpoint with the long url you want to shorten.

This endpoint requires your API_KEY_ID and API_SECRET to access.

Request

Parameter Required Description Example
url YES STRING The long url to shorten https://example.com/long-url-to-shorten
domain NO STRING The domain name of the short url (defaults to ✰.com) ✰.com
slug NO STRING The custom link slug. These are the keywords that appear after the slash (defaults to a random 6 char string). Slugs must be unique for the domain and contain Alphanumeric and Hyphen characters only. Min 4 Chars and max 255 chars in length. custom-link-keywords
description NO STRING The description to associate with the created link The long url description

Example of a request.

curl https://ninjalinka.com/1.0/links/ \
    --header "X-Api-Id: <API_KEY_ID>" \
    --header "X-Api-Secret: <API_SECRET>" \
    --data "url=<URL>&domain=<DOMAIN>&slug=<SLUG>&description=<DESCRIPTION>"
const axios = require('axios');

const data = {
  url: '<URL>',
  domain: '<DOMAIN>',
  slug: '<SLUG>',
  description: '<DESCRIPTION>'
};

const options = {
  headers: {
    'X-Api-Id': '<API_KEY_ID>',
    'X-Api-Secret': '<API_SECRET>'
  }
};

axios.post('https://ninjalinka.com/1.0/links/', data, options)
  .then((response) => {
    console.log(response.data);
  }, (error) => {
    console.log(error);
  });
$url = "https://ninjalinka.com/1.0/links/";
$headers = ["X-Api-Id: <API_KEY_ID>", "X-Api-Secret: <API_SECRET>"];
$data = [
    "url" => "<URL>",
    "domain" => "<DOMAIN>",
    "slug" => "<SLUG>",
    "description" => "<DESCRIPTION>"
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_exec($ch);

curl_close($ch);

Response

Example of a successful response.

{
    "uuid": "c3ca6016-e720-49e4-a295-43a4a9892151",
    "short_url": "https://✰.com/HbMe4e",
    "long_url": "https://example.com/long-url-to-shorten",
    "description": "The long url description",
    "created": "2020-09-13T02:45:42+00:00",
}

List Links

GET /links

Make a HTTP GET request to the /links endpoint to list Links.

This endpoint requires your API_KEY_ID and API_SECRET to access.

Request

Parameter Required Description Example
page NO INTEGER The page number when using pagination 1
limit NO INTEGER The limit of returned resources when using pagination 50

Example of a request.

curl "https://ninjalinka.com/1.0/links?_id=<API_KEY_ID>&_secret=<API_SECRET>"
const axios = require('axios');

axios.get('https://ninjalinka.com/1.0/links?_id=<API_KEY_ID>&_secret=<API_SECRET>')
.then((response) => {
  console.log(response.data);
}, (error) => {
  console.log(error);
});
echo file_get_contents("https://ninjalinka.com/1.0/links?_id=<API_KEY_ID>&_secret=<API_SECRET>");

Response

Example of a successful response.

[
    {
        "uuid": "72284330-ad1f-46ce-bc2d-855e830b8c45",
        "short_url": "https://✰.com/HbMe4e",
        "long_url": "https://example.com/long-url-to-shorten",
        "description": "The long url description",
        "created": "2020-09-13T02:45:41+00:00",
    },
    {
        "uuid": "1adb12d2-a73f-45a7-81ab-44ea1da5f52a",
        "short_url": "https://✰.com/dHtxJl",
        "long_url": "https://example.com/long-url-to-shorten",
        "description": "The long url description",
        "created": "2020-09-13T02:45:42+00:00",
    }
]

Delete a Link

DELETE /links/<UUID>

Make a HTTP DELETE request to the /links/<UUID> endpoint with the UUID of the Link.

This endpoint requires your API_KEY_ID and API_SECRET to access.

Request

Parameter Required Description Example
uuid YES INTEGER The Link UUID 3c746233-7d93-4450-9f81-37d72d66dede

Example of a request.

curl https://ninjalinka.com/1.0/links/<UUID> \
    --header "X-Api-Id: <API_KEY_ID>" \
    --header "X-Api-Secret: <API_SECRET>" \
    -X "DELETE"
const axios = require('axios');

const options = {
  headers: {
    'X-Api-Id': '<API_KEY_ID>',
    'X-Api-Secret': '<API_SECRET>'
  }
};

axios.delete('https://ninjalinka.com/1.0/links/<UUID>', options)
.then((response) => {
  console.log(response.data);
}, (error) => {
  console.log(error);
});
$url = "https://ninjalinka.com/1.0/links/<UUID>";
$headers = ["X-Api-Id: <API_KEY_ID>", "X-Api-Secret: <API_SECRET>"];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_exec($ch);

curl_close($ch);

Response

Example of a successful response.

{
    "message": "Deleted successfully"
}

API Overview

Authentication

You'll need to authenticate using your API Key.

There are two ways to authenticate:

Request Headers:
curl -H "X-Api-Id: <API_KEY_ID>" -H "X-Api-Secret: <API_SECRET>" 'https://ninjalinka.com'

URL Parameters:
curl 'https://ninjalinka.com/foo?_id=<API_KEY_ID>&_secret=<API_SECRET>'

API Keys

API Keys can be created and managed in the API Keys section.

  1. Go to the API Keys section.
  2. Click on the button 'Generate API Key'.
  3. A new key will be genereated for use with the API.

Rate Limits

API Keys are rate limited to ensure fair delivery of services. You can view the current Rate Limit and Remaining Requests in the returned Response Headers from the API. Below is a description of the Response Headers.

Header Description
X-RateLimit-Limit The maximum number of requests per time window.
X-RateLimit-Remaining The number of requests remaining before reset.
X-RateLimit-Reset The time at which the current rate limit window resets in UTC Epoch seconds.

Error Codes

The following HTTP response codes are used.

Code Message Description
200 OK The request has succeeded.
400 Bad Request The request could not be understood by the server due to malformed syntax.
401 Unauthorised This indicates that you have not passed a valid API key, the key has expired, or the Authorization header is not formatted correctly.
404 Not Found The server has not found anything matching the Request-URI.
405 Method Not Allowed This indicates that the request method is known by the server but has been disabled and cannot be used.
429 Too Many Requests We have recieved too many requests from your API Key in a given amount of time. Wait a while and try again.
500 Internal Server Error An unspecified error occurred during the request.

Haven't found the answer? We can help.

Submit a request

Contact us and we’ll get back to you as soon as possible.