NXY API Version 1 1 0

From NxyWiki

Jump to: navigation, search

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/api_1_1_0/shorten.aspx?url=your urlWith options: “http://nxy.in/api_1_1_0/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/api_1_1_0/shorten.aspx?url=http://www.in-rev.com” or
         “http://nxy.in/api_1_1_0/shorten.aspx?url=http://www.in-rev.com&type=json” or
         “http://nxy.in/api_1_1_0/shorten.aspx?url=http://www.in-rev.com&user=lkhatiwada&frame=0&type=json”
    Xml format:
         “http://nxy.in/api_1_1_0/shorten.aspx?url=http://www.in-rev.com&type=xml” or
         “http://nxy.in/api_1_1_0/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>


Expanding

Expands a nxy shortened url or key to its elongated format. Input format: “http://nxy.in/api_1_1_0/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/api_1_1_0/expand.aspx?url=http://nxy.in/ko6zn” or
         “http://nxy.in/api_1_1_0/expand.aspx?url=ko6zn ”
    Xml format:
         “http://nxy.in/api_1_1_0/expand.aspx?url=http://nxy.in/ko6zn&type=xml” or
         “http://nxy.in/api_1_1_0/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>

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/api_1_1_0/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/api_1_1_0/referrals.aspx?key=ko6zn” or
         “http://nxy.in/api_1_1_0/referrals.aspx?key=ko6zn&type=json” 
    Xml format:
         “http://nxy.in/api_1_1_0/referrals.aspx?key=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 format

Returns if error occurred while calling a nxy api.

Error format json:

    {
         "Status":"<HTTP status code>",
         "Error":"<Error Description>"
    }

Error format xml:

    <hash>
         <Status><HTTP status code></Status>
         <Error><Error Description></Error>
    </hash>

Status list

Status Description
400 Bad Request 1. Invalid request format. Supports only JSON and XML.
404 Not Found
     1. Requested short url or key does not exist.
     2. Requested nxy url or key is invalid.
     3. Requested url or key is null or empty.
     4. Invalid twitter screen name supplied.
406 Not Acceptable Requested URI is invalid.
500 Internal Server Error Got an exception.
Personal tools