Nip URL Shortening SDK
This is a simple Node.js package to allow easy consumption of the Nip URL shortening service. This library is built with TypeScript.
The service allows you to pass it a url and then receive back a short-url (or longer one) that is fully tracked. These short-urls only work for GET
requests.
Installation
npm install nip-urls --save
Usage
To use this library, first import and instantiate the class with your reserved domain name and API key.
const { Nip } = require ( ' nip-urls ' ) ;
const nip = new Nip ( ' nip.is ' , ' INSERT_API_KEY_HERE ' ) ;
Generate tracked short url
const url = await nip . shorten ( ' https://root.co.za/careers ' ) ;
Generate tracked longer url
const url = await nip . track ( ' https://root.co.za/careers ' ) ;
Fetch a url
const url = await nip . getUrl ( ' b4949c2b-8a76-44df-8c34-04ccad2f9fb8 ' ) ;
Fetch a url's visits
const visits = await nip . getUrlVisits ( ' b4949c2b-8a76-44df-8c34-04ccad2f9fb8 ' ) ;
Interface definitions
type Url
export interface Url {
id : string ;
domainName : string ;
sourceUrl : string ;
destinationUrl : string ;
visitCount : number ;
createdAt : moment . Moment ;
} ;
{
id : ' b4949c2b-8a76-44df-8c34-04ccad2f9fb8 ' ,
domainName : ' nip.is ' ,
sourceUrl : ' https://nip.is/cXCUn ' ,
destinationUrl : ' https://root.co.za/careers ' ,
visitCount : 1 ,
createdAt : moment ( " 2019-05-27T20:48:48.519 " )
}
type Visit
export interface Visit {
id : string ;
url_id : string ;
headers : any ;
createdAt : moment . Moment ;
} ;
{
id : ' 11bee574-626e-447f-9864-329c56756872 ' ,
urlId : ' b4949c2b-8a76-44df-8c34-04ccad2f9fb8 ' ,
headers : {
host : ' nip.is ' ,
' user-agent ' :
' Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36 ' ,
' cf-ipcountry ' : ' ZA ' ,
' x-forwarded-for ' : ' 41.56.11.31, 197.234.242.47 ' ,
' cf-connecting-ip ' : ' 41.56.11.31 ' ,
...
} ,
createdAt : moment ( " 2019-05-27T20:50:59.141 " ) ,
}
Created by Root .