Notice: The API is temporarily disabled. We are working on a new version.

URL Shortener API

The ShortURL.FM API allows you to create free, shortened URLs from long links. No authentication is required, and the service is completely free.


Endpoint

URL: https://shorturl.fm/api/create.php

Method: POST

Request Format

Send a JSON payload with the following parameter:

  • url (string): The long URL you want to shorten.

Example Request

{
  "url":"https://example.com/page"
}

Response Format

All responses are JSON.

Success Response

{
  "short_url": "https://shorturl.fm/ToVLL",
  "long_url": "https://example.com/page"
}

Error Response

{
  "errorcode": 1,
  "errormessage": "Invalid request method. Expected POST."
}

Rate Limits

Rate limits apply to each individual IP address:

  • 300 requests per hour per IP

Error Codes

CodeDescription
1Invalid request method. Expected POST.
2Hourly request limit exceeded. Try again later.
3Invalid content type. Expected application/json.
4Request body too large.
5Malformed JSON.
6Unexpected fields. Only the "url" field is allowed.
7Missing required parameter: url.
8Invalid URL.
9URL is too long.
10This domain is blacklisted.
11This URL is blacklisted.
12Database error. Please try again later.

PHP Example

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