Shorten API v1 - Documentation

This REST api allows you to shorten urls fully automatically

Shorten a Link

This endpoint can be used to shorten a link

POST

Parameters

Parameter NameParameter TypeData TypeRequired
urlPost Body JSONstring (*)yes

JSON Response

AttributeData TypeExample Value
errorinteger0
idinteger1
codestring (8)abcdefgh
urlstring (*)https://example.com
clicksinteger0
created_attimestamp2018-12-21 18:33:49

Getting info

This endpoint can be used to get info (clicks, url, ...) for a shortlink code

GET

Parameters

Parameter NameParameter TypeData TypeRequired
codePath Parameterstring (8)yes

JSON Response

AttributeData TypeExample Value
errorinteger0
idinteger1
codestring (8)abcdefgh
urlstring (*)https://example.com
clicksinteger123
created_attimestamp2018-12-21 18:33:49

Error handling

The response always contains an error attribute containing a number that respresents the success state of the request.

Errors

IDMessage
0Success
1Not found
2Invalid request body
3Missing parameters
4Invalid parameters

jQuery Example

function shortenLink(link){
  $.ajax({
   type: "POST",
   url: "https://shtn.ml/api/v1/shorten",
   data: JSON.stringify({ url: link }),
   contentType: "application/json; charset=utf-8",
   dataType: "json"
  }).done(function(response) {
   console.log(response.code);
  });
}
Copyright 2018 @ shtn.ml | Sourcecode on Github | Imprint