URL Shortener API from x1url.com will cover all your link shortening needs within a few clicks.

Simple URL Shortener API for Your Business

API Usage in PHP

An API key is required for requests to be processed by the x1url.com URL shortener API. Once a user registers, an API key is automatically generated for this user. The API key must be sent with each request via the key parameter (see full example below). If the API key is not sent or is expired, there will be an error. Please make sure to keep your API key secret to prevent abuse.

Get your API key

Sending a request for shortening a URL

To send a request, the user must use the following format where the variables api and url are required. 

GET https://x1url.com/api/?key={YOUR_API_KEY}&url={THE_LONG_URL}

Server response

As before, the response from our URL shortener API will be encoded in JSON format (default). This is done to facilitate cross-language usage. The first element of the response will always tell if an error has occurred (error: 1) or not (error: 0). The second element will change with respect to the first element. If there is an error, the second element will be named 'msg'. which contains the source of error, otherwise it will be named “short” which contains the short URL. (See below for an example)

No errors


An error has occurred

{"error":1,"msg":"Please enter a valid url" }

Using plain text format

You can now request the response from the x1url.com URL shortener API to be in plain text by just adding &format=text at the end of your request. Note that if an error occurs, it will not output anything so you can assume if it is empty then there is an error.

Using the API in PHP

To use the API in your PHP application, you have to send a GET request through file_get_contents or cURL: Both are reliable methods. You can copy the function below. Everything is already set up for you.

/**** Sample PHP Function ***/
function shorten($url$custom ""$format "json")
$api_url "https://x1url.com/api/?key={YOUR_API_KEY};
$api_url .= "&url=" urlencode(filter_var($urlFILTER_SANITIZE_URL));
    if (!empty(
$custom)) {
$api_url .= "&custom=" strip_tags($custom);
$curl curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $api_url
$Response curl_exec($curl);
    if (
$format == "text") {
$Ar json_decode($ResponseTRUE);
        if (
$Ar["error"]) {
        } else {
    } else {


Simple Usage

echo shorten("https://google.com");

Usage with custom alias

echo shorten("https://google.com", "google");

Usage with custom alias and text format

echo shorten("https://google.com", "google", "text");