npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ip-geolocation-api-sdk-typescript

v1.0.7

Published

[Typescript SDK for IP Geolocation API](https://ipgeolocation.io/documentation/ip-geolocation-api-typescript-sdk-201809051239). You can use this SDK to Geolocate an IP address and get time zone information based on geolocation coordinates, or an IP addres

Downloads

211

Readme

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:

  1. Display native language and currency
  2. Redirect based on the country
  3. Digital rights management
  4. Web log stats and analysis
  5. Auto-selection of country, state/province and city on forms
  6. Filter access from countries you do not do business with
  7. 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';

// Create IPGeolocationAPI object. Constructor takes two parameters.
// 1) API key (Optional: To authenticate your requests through "Request Origin", you can skip it.)
// 2) Async (Optional: It is used to toggle "async" mode in the requests. By default, it is true.)
let ipgeolocationApi = new IPGeolocationAPI("YOUR_API_KEY", false); 

Geolocation Lookup

import { GeolocationParams } from './node_modules/ip-geolocation-api-sdk-typescript/GeolocationParams';

// Function to handle API response
function handleResponse(json) {
    console.log(json);
}

// Get complete geolocation for the calling machine's IP address
ipgeolocationApi.getGeolocation(handleResponse);

// Get complete geolocation in Russian** for IP address (1.1.1.1)
let geolocationParams = new GeolocationParams();
geolocationParams.setIPAddress('1.1.1.1');
geolocationParams.setLang('ru');

ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);

// Get custom geolocation (only "geo, time_zone and currency" fields/objects) for an IP address (1.1.1.1)
let geolocationParams = new GeolocationParams();
geolocationParams.setIPAddress('1.1.1.1'); 
geolocationParams.setFields('geo,time_zone,currency');

ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);

// Exclude fields/obejects from complete geolocation in Italian language
let geolocationParams = new GeolocationParams();
geolocationParams.setExcludes('continent_name,country_code3,time_zone');
geolocationParams.setLang('it');

ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);

Bulk Geolocations Lookup

// Query geolocation in German** for multiple IP addresses and all fields
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);

// Specify the required fields/objects for multiple IP addresses
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';

// Get time zone information by time zone ID
let timezoneParams = new TimezoneParams();
timezoneParams.setTimezone('America/Los_Angeles');

ipgeolocationApi.getTimezone(handleResponse, timezoneParams);

// Get time zone information by latitude and longitude of the location
let timezoneParams = new TimezoneParams();
timezoneParams.setLocation('37.1838139', '-123.8105225');

ipgeolocationApi.getTimezone(handleResponse, timezoneParams);

// Get time zone information for IP address (1.1.1.1) and geolocation information Japanese**
let timezoneParams = new TimezoneParams();
timezoneParams.setIPAddress('1.1.1.1');

ipgeolocationApi.getTimezone(handleResponse, timezoneParams);

// Query time zone information for calling machine's IP address
ipgeolocationApi.getTimezone(handleResponse);

UserAgent API

// Get user agent information for single user agent string
ipgeolocationApi.getUserAgent(handleResponse, "AppleTV6,2/11.1");

// Get user agents information in bulk by providing array of user agent strings
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

  1. tsc *.ts
  2. node Main.js