For otwn.us
and otwn.net
There are 3 main API functions: creating a short URL, getting info about a shortened URL, redirecting the shortened URL to it's destination.
All functions return a JSON object containing an error
(boolean) indicating if there is an error, a message
(string) with a message if there is an error, and a data
object which contains the result of the function called.
Endpoint: ourtown.us/?c=URL_TO_SHORTEN
Parameter: URL_TO_SHORTEN: The URL to be shortened, URL encoding is optional.
This will create a new shortened URL, if it does not exist already, or else return information about the existing record for this URL.
Returns:
The data
property of the result object contains the following properties:
is_new
(boolean): is this record new, or did it already exist.creator_ip
(string): the IP address of the user who intially created the URL. create_time
(string): the time the URL was created.short_url
(string): the shortened URL.stats_url
(string): a URL which provides stats and a paginated list of page hits for the shortened URL.full_url
(string): the full URL that the shortened one redirects to.Endpoint: (provided in the stats_url
property when a new URL is created)
This will provide stats and a paginated list of page hits for a shortened URL.
Returns:
The data
property of the result object contains the following properties:
creator_ip
(string): the IP address of the user who intially created the URL. create_time
(string): the time the URL was created.short_url
(string): the shortened URL.full_url
(string): the full URL that the shortened one redirects to.stats_next_page_url
(string): if there is a next page of results, this is the URL for that page. If there is not a proceeding page, this property will not be defined.stats_last_page_url
(string): if there is a previous page of results, this is the URL for that page. If there is not a previous page, this property will not be defined.hit_count
(integer): the number of hits this page has had.page_hits
(array): a list of objects representing page hits. Each object contains the following properties:request_time
(string): the time of the request.user_ip
(string): the IP address of the user.Endpoint: (provided in the stats_url
property when a new URL is created)
This will create a log of the user's IP and the current time and redirect to the full URL. Nothing is returned.