• API calls in illustrations made using cURL
That doesn't mean that it is the only way to call our API.
You can make the requests by whatever tool you prefer, we used curl here because it is widly used and available for most systems and programing languages.
- You can use either Bearer authentication in an authorization header like Authorization: Bearer 123456789123456789
or Basic authentication either before endpoint url like https://123456789123456789@shrnk.us.to/api/shrink.php
or in an authorization header like Authorization: Basic <base 64 code for your token>
- if it is successfull request it will have http response code 200 and response will have two child elements:
1) result which value will be 'success' and 2) data which value is request dependant
- if it is failed request it will have http response code other than 200 and response will have two child elements also:
1) result which value will be 'failed' and 2) message which value will explain why this error happened
result if it is 'success' or 'failed'.
{
"result": (string)"failed",
"message": (string)"<WHY_THIS_ERROR_OCCURED>"
}
curl <YOUR_API_TOKEN>@shrnk.us.to/api/shrink.php?tag=<SOME_TAG>
| Auth. |
Required |
| tag |
Optional |
{
"result": (string)"success",
"data": (array)
[
{
"title":(string) "My sample shrinko title",
"shrinko":(string) "https://shrnk.us.to/abcde",
"linko":(string) "https://really.long/link/that/you/are/going/to/shrink/and/keep/track/of/clicks/and/visits/to.it",
"tag":(string) "sample_links",
"created_at":(datetime) "2024-01-01 00:00:00",
"clicks":(int) 0
},
{
"title": "another.long",
"shrinko": "https://shrnk.us.to/1234",
"linko": "https://another.long/link/that/you/are/going/to/shrink/and/keep/track/of/clicks/and/visits/to.it",
"tag": null,
"created_at": "2023-01-01 00:00:00",
"clicks": 20
},
......
]
}
curl \
-X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'link=<YOUR_LONG_LINK_TO_SHRINK>' \
-d 'title=<DESIRED_SHRINKO_TITLE>' \
-d 'tag=<TAGGING_SHRINKO>' \
https://<YOUR_API_TOKEN>@shrnk.us.to/api/shrink.php
| Auth. |
Optional |
| link |
Required |
| title |
Optional |
| tag |
Optional |
{
"result": (string)"success",
"data": (object)
{
"title":(string) "My link",
"shrinko":(string) "https://shrnk.us.to/abcde",
"linko":(string) "https://very.long/url/that/will/be/shrinked",
"tag":(string) "sample_links",
"creation":(datetime) "2024-01-01 00:00:00",
"action":(enum("created", "updated", "unchanged")) "created"
}
}
curl \
-X DELETE \
-H 'Authorization: Bearer <YOUR_API_TOKEN>' \
https://shrnk.us.to/api/shrink.php?shrinko=<SHRINKO_TO_BE_DELETED>
| Auth. |
Required |
| shrinko |
Required |
{
"result": (string)"success",
"data": (object)
{
"deleted":(string) "https://shrnk.us.to/abcde"
}
}