The ShortURL.FM API allows you to create free, shortened URLs from long links. No authentication is required, and the service is completely free.
URL: https://shorturl.fm/api/create.php
Method: POST
Send a JSON payload with the following parameter:
url (string): The long URL you want to shorten.{
"url":"https://example.com/page"
}
All responses are JSON.
{
"short_url": "https://shorturl.fm/ToVLL",
"long_url": "https://example.com/page"
}
{
"errorcode": 1,
"errormessage": "Invalid request method. Expected POST."
}
Rate limits apply to each individual IP address:
| Code | Description |
|---|---|
| 1 | Invalid request method. Expected POST. |
| 2 | Hourly request limit exceeded. Try again later. |
| 3 | Invalid content type. Expected application/json. |
| 4 | Request body too large. |
| 5 | Malformed JSON. |
| 6 | Unexpected fields. Only the "url" field is allowed. |
| 7 | Missing required parameter: url. |
| 8 | Invalid URL. |
| 9 | URL is too long. |
| 10 | This domain is blacklisted. |
| 11 | This URL is blacklisted. |
| 12 | Database error. Please try again later. |
Use this cURL function to call the API:
<?php
function createShortUrl(string $longUrl): array {
$endpoint = 'https://shorturl.fm/api/create.php';
$payload = json_encode(['url' => $longUrl]);
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
if (curl_errno($ch)) {
$err = curl_error($ch);
curl_close($ch);
return ['errorcode' => 0, 'errormessage' => $err];
}
curl_close($ch);
return json_decode($response, true);
}
// Example usage:
$result = createShortUrl('https://example.com/page');
if (isset($result['short_url'])) {
echo 'Shortened URL: ' . $result['short_url'];
} else {
echo 'Error: ' . $result['errormessage'];
}
?>
If you have any questions about our API, please email us at support@shorturl.fm