/api/link
Added in v1.0
POST
https://api.example.com/api/link
Requires authentication:
X-API-Key: YOUR_API_KEY
Create a link to be used as a shortened URL.
Headers
-
x-api-keystring requiredAPI key used to authenticate the requestExample:Your actual API key
Body parameters
-
namestring requiredThe short name for the link -
urlstring requiredThe URL the link should direct towards
Responses
- 200Success
- 400Body fields not passed, name and url are required.
Request
curl -X POST 'https://api.example.com/api/link' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'x-api-key: Your actual API key' \
-H 'Content-Type: application/json' \
-d '{
"name": "name",
"url": "url"
}'
const response = await fetch('https://api.example.com/api/link', {
method: 'POST',
headers: {
'X-API-Key': 'YOUR_API_KEY',
'x-api-key': 'Your actual API key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "name",
"url": "url"
}),
});
const data = await response.json();
console.log(data);
import requests
response = requests.post(
"https://api.example.com/api/link",
headers={
"X-API-Key": "YOUR_API_KEY",
"x-api-key": "Your actual API key",
"Content-Type": "application/json",
},
json={
"name": "name",
"url": "url"
},
)
print(response.json())
<?php
$ch = curl_init('https://api.example.com/api/link');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: YOUR_API_KEY',
'x-api-key: Your actual API key',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{
"name": "name",
"url": "url"
}',
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($response);
Response
Success
{
"id": 2,
"name": "g",
"url": "https://google.com",
"count": 0,
"creator": "API",
"creatorID": "0",
"createdAt": "1713090722076"
}
Body fields not passed, name and url are required.
{
"msg": "Body fields not passed, name and url are required."
}