Socket
Book a DemoInstallSign in
Socket

ip-geolocation-api-sdk-typescript

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-geolocation-api-sdk-typescript

## Installation ```cli npm i ip-geolocation-api-sdk-typescript ```

1.0.4
Source
npmnpm
Version published
Weekly downloads
366
55.08%
Maintainers
1
Weekly downloads
 
Created
Source

IPGeolocation API Typescript SDK

Installation

npm i ip-geolocation-api-sdk-typescript

Usage

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

Setup API

var api = new IPGeolocationAPI("YOUR_API_KEY");
or
var api = new IPGeolocationAPI();

Geolocation Lookup

// Query geolocation for IP address (1.1.1.1) and fields (geo, time_zone and currency)
var geolocationParams = new GeolocationParams();
geolocationParams.setIp("1.1.1.1"); 
geolocationParams.setFields("geo,time_zone,currency");

api.getGeolocation(geolocationParams, geoResponse);
function geoResponse(json) {
    console.log(json);
}

// Query geolocation for IP address (1.1.1.1) and all fields
GeolocationParams geoParams = new GeolocationParams();
geoParams.SetIp("1.1.1.1");

api.getGeolocation(geolocationParams, geoResponse);
function geoResponse(json) {
    console.log(json);
}


// Query geolocation for the calling machine's IP address for all fields
api.getGeolocation(null, geoResponse);
function geoResponse(json) {
    console.log(json);
}

Bulk Geolocations Lookup

// Query geolocations for multiple IP addresses and all fields
var geolocationParams = new GeolocationParams();
geolocationParams.setIps(['1.1.1.1','2.2.22.2','34.1.1.3']);

api.getGeolocation(geolocationParams, geoResponse);
function geoResponse(json) {
    console.log(json);
}

Time Zone API

// Query time zone information by time zone ID
var tzParams = new TimezoneParams();

tzParams.setIp("1.1.1.1");
obj.getTimezone(null, geoResponse);
function geoResponse(json) {
    console.log(json);
}

Commands To Run

  • tsc *.ts
  • node *.js

Keywords

ip

FAQs

Package last updated on 22 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.