IP Geolocation API Typescript SDK
Introduction
IPGeolocation API is the solution to identify country code (ISO2 and ISO3 standard), country name, continent code, continent name, country capital, state/province, district, city, zip code, latitude and longitude of city, is country belongs to Europian Union, calling code, top level domain (TLD), languages, country flag, internet service provider (ISP), connection type, organization, geoname ID, currency code, currency name, time zone ID, time zone offset, current time in the time zone, is time zone in daylight saving time, and total daylight savings. This document provides important information to help you get up to speed with IPGeolocation API using IP Geolocation API Typescript SDK.
Developers can use this Typescript SDK for software and web projects related to, but not limited to:
- Display native language and currency
- Redirect based on the country
- Digital rights management
- Web log stats and analysis
- Auto-selection of country, state/province and city on forms
- Filter access from countries you do not do business with
- Geo-targeting for increased sales and click-through
Quick Start Guide
You need a valid 'IPGeolocation API key' to use this SDK. Sign up here and get your free API key if you don't have one.
Note: Complete documentation to use this SDK is also available at IP Geolocation API Typescript SDK Documentation.
System Requirements
Internet connection is required to run this component.
Installation
NPM
$ npm install ip-geolocation-api-sdk-typescript
Documentation
Use the following URL to visit documentation
https://ipgeolocation.io/documentation.html
Basic Usage
Setup API
import { IPGeolocationAPI } from './node_modules/ip-geolocation-api-sdk-typescript/IPGeolocationAPI';
let ipgeolocationApi = new IPGeolocationAPI("YOUR_API_KEY", false);
Geolocation Lookup
import { GeolocationParams } from './node_modules/ip-geolocation-api-sdk-typescript/GeolocationParams';
function handleResponse(json) {
console.log(json);
}
ipgeolocationApi.getGeolocation(handleResponse);
let geolocationParams = new GeolocationParams();
geolocationParams.setIPAddress('1.1.1.1');
geolocationParams.setLang('ru');
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
let geolocationParams = new GeolocationParams();
geolocationParams.setIPAddress('1.1.1.1');
geolocationParams.setFields('geo,time_zone,currency');
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
let geolocationParams = new GeolocationParams();
geolocationParams.setExcludes('continent_name,country_code3,time_zone');
geolocationParams.setLang('it');
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
Bulk Geolocations Lookup
let geolocationParams = new GeolocationParams();
geolocationParams.setLang('de');
geolocationParams.setIPAddresses(['1.1.1.1', '2.2.2.2', '3.3.3.3']);
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
let geolocationParams = new GeolocationParams();
geolocationParams.setIPAddresses(['1.1.1.1', '2.2.2.2', '3.3.3.3']);
geolocationParams.setFields('geo');
ipgeolocationApi.getGeolocation(geolocationParams, geoResponse);
Timezone API
import { TimezoneParams } from './node_modules/ip-geolocation-api-sdk-typescript/TimezoneParams';
let timezoneParams = new TimezoneParams();
timezoneParams.setTimezone('America/Los_Angeles');
ipgeolocationApi.getTimezone(handleResponse, timezoneParams);
let timezoneParams = new TimezoneParams();
timezoneParams.setLocation('37.1838139', '-123.8105225');
ipgeolocationApi.getTimezone(handleResponse, timezoneParams);
let timezoneParams = new TimezoneParams();
timezoneParams.setIPAddress('1.1.1.1');
ipgeolocationApi.getTimezone(handleResponse, timezoneParams);
ipgeolocationApi.getTimezone(handleResponse);
UserAgent API
ipgeolocationApi.getUserAgent(handleResponse, "AppleTV6,2/11.1");
var uaStrings:string[] = ["AppleTV6,2/11.1", "Roku4640X/DVP-7.70 (297.70E04154A)", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1"];
ipgeolocationApi.getBulkUserAgent(handleResponse, uaStrings);
** IPGeolocation provides geolocation information in the following languages:
- English (en)
- German (de)
- Russian (ru)
- Japanese (ja)
- French (fr)
- Chinese Simplified (cn)
- Spanish (es)
- Czech (cs)
- Italian (it)
By default, geolocation information is returned in English. Response in a language other than English is available to paid users only.
Commands To Run Typescript Application