API : Create New Short URL
Check the Polls App.
End Point
METHOD : POST
https://mocker.in/api/urls
Minimum Required Parameters
{
"long_url":"http://any-long-url.com"
}
Above parameters are required fields. long_url field is where you can put your url that is to be shortened. slug or URL ID will be generated automatically.
All Parameters
{
"slug": "test2",
"long_url": "http://google.com",
"edit_token": "vno6QmIhBa",
"password": "123456",
"active_from": "23-03-2020",
"active_till": "28-03-2020",
"is_onetime": false
}
Above is the completely list of parameters. slug can be provided if you want a custom short url. The slug value will decide the Short URL. https://mocker.in/{slug}. edit_token is different from password. password is the password that your users will have to enter before they are redirected to the website specified in long_url. This feature maybe used to password protect your shortened links. Whereas edit_token is required to edit the Short URL in future. It is very important to store this somewhere. active_from and active_till is used to enable the poll only at a specific duration. is_onetime if set to true will automatically delete the link after it is used once.
Response
{
"status": "success",
"message": "Your URL is shortened.",
"data": {
"short_id": "test1",
"edit_token": "sI8HEUVGpa",
"short_url": "https://mocker.in/test1",
"edit_url": "https://mocker.in/test1/sI8HEUVGpa"
}
}
The reponse will always return two parameters, status and message. If status is success then the action is complete. and if it is error then that means some problem has occured. The problem details can be found in the message parameter. Additionally creating a new short url returns the short_id,edit_token,short_url and 'edit_url' inside the data parameter. Once you have the short_id and edit_token you may get the complete details of the Short URL and also edit it.
