Nxy API
From NxyWiki
Contents |
NXY REST APIs
Nxy exposes REST based APIs which can be used by the developer to shorten a long URL, expand nxy-shortened URL or get the click details. The response format is in XML or JSON (default).
Shortening
Returns an nxy shortened URI for a given long URI.
Input format:
Basic format: “http://nxy.in/apis/shorten.aspx?url=your url”
With options: “http://nxy.in/apis/shorten.aspx?url=your url&frame=frame options&user=creator's twitter id&type=response type”
HTTP Request Type: GET
Input details:
| Parameter (querystring) | Values | Default Value | Required |
|---|---|---|---|
| url | Valid long url | NA | Yes |
| frame | yes,1,no,0 | yes | No |
| type | xml, json | Json | No |
| user | valid twitter id | Null | No |
Example:
json format:
“http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com” or
“http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com&type=json” or
“http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com&user=lkhatiwada&frame=0&type=json”
Xml format:
“http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com&type=xml” or
“http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com&user=lkhatiwada&frame=0&type=xml”
Response format:
json:
{
"Status":"200 OK",
"ShortUrl":"http://nxy.in/ko6zn",
"LongUrl":"http://www.in-rev.com",
"Error":null
}
xml:
<?xml version="1.0" encoding="utf-8"?>
<UrlResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<Status>200 OK</Status>
<ShortUrl>http://nxy.in/ko6zn</ShortUrl>
<LongUrl>http://www.in-rev.com</LongUrl>
</UrlResponse>
Error code: Bad request type
| Input | http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com&frame=0&type=html |
|---|---|
| Output |
{
"Status":"400 Bad Request",
"ShortUrl":null,
"LongUrl":null,
"Error":"Format type supports only JSON and XML"
}
|
Expanding
Expands a nxy shortened url or key to its elongated format. Input format: “http://nxy.in/apis/expand.aspx?url=short url&type=response type”
HTTP Request Type: GET
Input details:
| Parameter (querystring) | Values | Default Value | Required |
|---|---|---|---|
| url | Valid short url | NA | Yes |
| type | xml, json | Json | No |
Example:
json format:
“http://nxy.in/apis/expand.aspx?url=http://nxy.in/ko6zn” or
“http://nxy.in/apis/expand.aspx?url=ko6zn ”
Xml format:
“http://nxy.in/apis/expand.aspx?url=http://nxy.in/ko6zn&type=xml” or
“http://nxy.in/apis/expand.aspx?url=ko6zn&type=xml”
Response format:
json:
{
"Status":"200 OK",
"ShortUrl":"http://nxy.in/ko6zn",
"LongUrl":"http://www.in-rev.com",
"Error":null
}
xml:
<?xml version="1.0" encoding="utf-8"?>
<UrlResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Status>200 OK</Status>
<ShortUrl>http://nxy.in/ko6zn</ShortUrl>
<LongUrl>http://www.in-rev.com</LongUrl>
</UrlResponse>
Error code: short url does not exist
| Input json | http://nxy.in/apis/expand.aspx?url=mfapr |
|---|---|
| Output |
{
"Status":"404 Not Found",
"ShortUrl":"http://nxy.in/mfapr",
"LongUrl":null,
"Error":"Requested short url or key does not exist."
}
|
| Input xml | http://nxy.in/apis/expand.aspx?url=mfapr&type=xml |
| Output |
{
<?xml version="1.0" encoding="utf-8"?>
<UrlResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Status>406 Not Acceptable</Status>
<ShortUrl>http://nxy.com/hfdx6</ShortUrl>
<Error>Invalid short url or key.</Error>
</UrlResponse>
|
Error code: Bad request type
| Input | http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com&frame=0&type=html |
|---|---|
| Output |
{
"Status":"400 Bad Request",
"ShortUrl":null,
"LongUrl":null,
"Error":"Format type supports only JSON and XML"
}
|
URL Details (Statistics)
Provides the statistics of the URL click details. The details include total visits, unique visits and Referrals. Nxy captures Referrals from the HTTP Header "Referer" (ref. RFC 2616, sec 14.36). This field shows the source from which this click was obtained. If this field is not present in the header, Nxy assumes that it was a direct request (and domain and path fields contain Direct in this case). Typical examples of sources could be google.com, facebook.com, twitter.com, etc.
Input format: “http://nxy.in/apis/referrals.aspx?key=short key&type=response type”
HTTP Request Type: GET
Input details:
| Parameter (querystring) | Values | Default Value | Required |
|---|---|---|---|
| url | Key | NA | Yes |
| type | xml, json | Json | No |
Example:
json format:
“http://nxy.in/apis/referrals.aspx?key=ko6zn” or
“http://nxy.in/apis/referrals.aspx?key=ko6zn&type=json” or
“http://nxy.in/apis/referrals.aspx?key=http://nxy.in/ko6zn&type=json”
Xml format:
“http://nxy.in/apis/referrals.aspx?key=ko6zn&type=xml” or
“http://nxy.in/apis/referrals.aspx?key=http://nxy.in/ko6zn&type=xml”
Response format:
json:
{
"Status":"200 OK",
"Visits":19,
"UniqueVisits":14,
"Referrals":[
{
"Domain":"Direct",
"Path":"Direct",
"Visits":"17"
},
{
"Domain":"twitter.com",
"Path":"http://twitter.com/",
"Visits":"2"
}],
"Error":"null"
}
xml:
<?xml version="1.0" encoding="utf-8"?>
<UrlReferrer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Status>200 OK</Status>
<Visits>19</Visits>
<UniqueVisits>14</UniqueVisits>
<Referrals>
<ReferralDetails>
<Domain>Direct</Domain>
<Path>Direct</Path>
<Visits>17</Visits>
</ReferralDetails>
<ReferralDetails>
<Domain>twitter.com</Domain>
<Path>http://twitter.com/</Path>
<Visits>2</Visits>
</ReferralDetails>
</Referrals>
<Error>null</Error>
</UrlReferrer>
Error code: short url does not exist
| Input json | http://nxy.in/apis/referrals.aspx?key=2occe |
|---|---|
| Output |
{
"Status":"404 Not Found",
"Visits":0,
"UniqueVisits":0,
"Referrals":[],"
"Error":"Requested short url or key does not exist."
}
|
| Input xml | http://nxy.in/apis/referrals.aspx?key=2occe&type=xml |
| Output |
{
<?xml version="1.0" encoding="utf-8"?>
<UrlResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Status>404 Not Found.</Status>
<Visits>0</Visits>
<UniqueVisits>0</UniqueVisits>
<Referrals />
<Error>Requested url does not exists.</Error>
</UrlResponse>
|
Error code: Bad request type
| Input | http://nxy.in/apis/shorten.aspx?url=http://www.in-rev.com&frame=0&type=html |
|---|---|
| Output |
{
"Status":"400 Bad Request",
"ShortUrl":null,
"LongUrl":null,
"Error":"Format type supports only JSON and XML"
}
|
