项目作者: Richienb

项目描述 :
Get ip location information.
高级语言: TypeScript
项目地址: git://github.com/Richienb/iplocation.git
创建时间: 2014-09-14T07:27:14Z
项目社区:https://github.com/Richienb/iplocation

开源协议:MIT License

下载


iplocation Travis CI Build Status

Get ip location information.

NPM Badge

Install

  1. npm install iplocation

Usage

  1. const ipLocation = require("iplocation");
  2. (async () => {
  3. await ipLocation("172.217.167.78");
  4. //=> { latitude: -33.8591, longitude: 151.2002, region: { name: "New South Wales" ... } ... }
  5. })();

API

ipLocation(ip, options?)

ip

Type: string

The ipv4 address to get the information for.

options

Type: object

apiKey

Type: string

An optional ipapi API key to use.

  1. const ipLocation = require("iplocation");
  2. (async () => {
  3. await ipLocation("172.217.167.78", { apiKey: 'YOUR_API_KEY' });
  4. //=> { latitude: -33.8591, longitude: 151.2002, region: { name: "New South Wales" ... } ... }
  5. })();

Providers

iplocation currently uses ipapi for IP lookups. Their free API is limited to 1000 requests per day.