Introduction
Create Short-URLs
/api/short
Parameter:
# longurl -> Long url
Perl example
use LWP::Simple;
getprint("http://5.gp/api/short?longurl=http://www.google.de");
# generate_password=1 -> Generation of a password (optional)
# expirein_option={time_option} -> Definiton of end of validity with given options (optional)
time_option =
0 => unlimited
1 => 1 day
2 => 1 week (default)
3 => 1 month
4 => 1 year
Answer
{
"facebook_url":"http://www.facebook.com/sharer.php?u=http://5.gp/dT",
"stat_url":"http://5.gp/dT+",
"twitter_url":"http://twitter.com/home?status=http://5.gp/dT",
"error":{
"msg":"OK",
"code":0
},
"url":"http://5.gp/dT",
"target_host":"www.google.de",
"host":"http://5.gp/"
"expire_date":"2018-09-25 18:45:12 CET"
}
Resolve Short-URLs
/api/long
Parameter:
# shorturl -> Short-URL target address (multiple delivery possible)
Perl example
use LWP::Simple;
getprint("http://5.gp/api/long?shorturl=http://5.gp/i&shorturl=http://5.gp/b2");
Answer
{
"http://5.gp/i": {
"error":{
"msg":"OK",
"code":0
},
"target_url":"http://www.amazon.de/gp/product/B0024NKZEW/ref=s9_pop_gw_ir02/275-2388775-7278822?pf_rd_m=A3JWKAKR8XB7XF&pf_rd_s=center-2&pf_rd_r=1BB63AC7DSA3VSCC09BJ&pf_rd_t=101&pf_rd_p=163674191&pf_rd_i=301128",
"shorturl":"http://5.gp/i"
"expire_date":"2017-07-17 18:45:12 CET"
},
"http://5.gp/b2":{
"error":{
"msg":"OK",
"code":0
},
"target_url":"http://www.amazon.de/gp/product/B0024NKZEW/ref=s9_pop_gw_ir02/275-2388775-7278822?pf_rd_m=A3JWKAKR8XB7XF&pf_rd_s=center-2&pf_rd_r=1BB63AC7DSA3VSCC09BJ&pf_rd_t=101&pf_rd_p=163674191&pf_rd_i=301128",
"shorturl":"http://5.gp/b2"
"expire_date":"unlimited"
}
}
Statistics for your Short-URL
/api/stat
Parameter:
# shorturl -> Short-URL target address (multiple delivery possible)
Perl example
use LWP::Simple;
getprint("http://5.gp/api/stat?shorturl=http://5.gp/i");
Answer
{
"http://5.gp/stat/i": {
"clicks":"246",
"error":{
"msg":"OK",
"code":0
},
"target_url":"http://www.amazon.de/gp/product/B0024NKZEW/ref=s9_pop_gw_ir02/275-2388775-7278822?pf_rd_m=A3JWKAKR8XB7XF&pf_rd_s=center-2&pf_rd_r=1BB63AC7DSA3VSCC09BJ&pf_rd_t=101&pf_rd_p=163674191&pf_rd_i=301128",
"shorturl_short_id":"i",
"shorturl":"http://5.gp/i",
"referer":[{
"Direkter Seitenaufruf":"23"
},{
"http://5.gp/stat/i":"157"
},{
"http://twitter.com/testuser":"66"
}],
"target_host":"www.amazon.de"
"expire_date":"2019-02-06 18:45:12 CET"
}
}
API error codes
There are several error codes to interpret the answer of the API correct.
Error codes
0 => "OK"
1 => "Not a url"
2 => "Shorturl not found"
3 => "too many requests"
4 => "domain not allowed"
5 => "expirein_option unknown"
Example of an error
http://5.gp/api/stat?shorturl=http://5.gp/d6
Answer
{
"error":{
"msg":"Shorturl not found",
"code":2
}
}