PiURL.com API

Requests

Example Requests

  1. http://piurl.com/api.php?url=http://www.example.com/some-long-article-name.html
  2. http://piurl.com/api.php?url=invalid-url.c

Responses

Example Responses

  1. http://piurl.com/xcode
  2. invalid-url.c

Sample codes

PHP

1. Basic
function myPiurl($myurl){
	$piurl = "http://piurl.com/api.php?url=$myurl";
	$response = file_get_contents($piurl);
	return $response;
}

echo myPiurl('http://www.google.com');

It will write http://piurl.com/1

2. Advanced
function parseMyUrl($myurl,$urllength){
	if(strlen($myurl)>$urllength){
		$myurl=myPiurl($myurl);
	}
	return $myurl;
}

function myPiurl($myurl){
	$piurl = "http://piurl.com/api.php?url=$myurl";
	$response = file_get_contents($piurl);
	return $response;
}

$max_length=24;
$theUrl="http://www.google.com";

echo  parseMyUrl($theUrl,$max_length);

It will write http://www.google.com.

The function checks whether the URL has over 24 chars.
If it has over 24 chars it gets a PiURL.
If it has less it gets the same URL because there is no benefit in a short URL.

Be Polite, Please!

Use good judgment when designing your application. Don't make repeated requests for the same data frequently.

We monitor API usage, and we may block applications that do silly things. Use good judgment to keep your application running smoothly!

Remember Terms

Using it for spamming or illegal purposes is forbidden.

This service is provided without warranty of any kind.