Javascript

This is a user contributed library. Special thanks to Thomas Conner for creating this! Test this in your browser - https://npm.runkit.com/ipdata.

Installation

npm install ipdata

Importing the library under a namespace

import * as ipdata from 'ipdata';
// ipdata.lookup()

Importing just the lookup function

import { lookup } from 'ipdata';
// lookup()

Requiring the library

var ipdata = require('ipdata');
// ipdata.lookup()

Basic Usage

Looking up the calling IP Address

lookup()
.then(function(info) {
// info.ip === 'hostcomputerip'
// ...
})

Looking up a specific IP Address

lookup('8.8.8.8')
.then(function(info) {
// info.ip === 8.8.8.8
// ...
})

Using an API Key

lookup('8.8.8.8', 'apiKey')
.then(function(info) {
// info.ip === 8.8.8.8
// ...
})