Giter Site home page Giter Site logo

iplocation's Introduction

iplocation Travis CI Build Status

Get ip location information.

NPM Badge

Install

npm install iplocation

Usage

const ipLocation = require("iplocation");

(async () => {
	await ipLocation("172.217.167.78");
	//=> { latitude: -33.8591, longitude: 151.2002, region: { name: "New South Wales" ... } ... }
})();

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.

const ipLocation = require("iplocation");

(async () => {
	await ipLocation("172.217.167.78", { apiKey: 'YOUR_API_KEY' });
	//=> { latitude: -33.8591, longitude: 151.2002, region: { name: "New South Wales" ... } ... }
})();

Providers

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

Related

iplocation's People

Contributors

a-tokyo avatar acal11 avatar aman1997 avatar angelorc avatar costamilam avatar greenkeeper[bot] avatar jlchereau avatar neaox avatar richienb avatar roryrjb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

iplocation's Issues

Error: All providers failed

0|API      | Mon Sep 23 2019 07:54:43 GMT+0000 (UTC) { Error: All providers failed.
0|API      |     at new ProviderError (/home/ubuntu/api/node_modules/iplocation/lib/index.js:39:28)
0|API      |     at retry (/home/ubuntu/api/node_modules/iplocation/lib/index.js:55:29)
0|API      |     at Request._callback (/home/ubuntu/api/node_modules/iplocation/lib/index.js:65:28)
0|API      |     at Request.self.callback (/home/ubuntu/api/node_modules/iplocation/node_modules/request/request.js:185:22)
0|API      |     at emitTwo (events.js:126:13)
0|API      |     at Request.emit (events.js:214:7)
0|API      |     at Request.<anonymous> (/home/ubuntu/api/node_modules/iplocation/node_modules/request/request.js:1161:10)
0|API      |     at emitOne (events.js:116:13)
0|API      |     at Request.emit (events.js:211:7)
0|API      |     at IncomingMessage.<anonymous> (/home/ubuntu/api/node_modules/iplocation/node_modules/request/request.js:1083:12)
0|API      |     at Object.onceWrapper (events.js:313:30)
0|API      |     at emitNone (events.js:111:20)
0|API      |     at IncomingMessage.emit (events.js:208:7)
0|API      |     at IncomingMessage.wrapped (/home/ubuntu/api/node_modules/newrelic/lib/transaction/tracer/index.js:188:22)
0|API      |     at IncomingMessage.wrappedResponseEmit (/home/ubuntu/api/node_modules/newrelic/lib/instrumentation/core/http-outbound.js:212:24)
0|API      |     at endReadableNT (_stream_readable.js:1064:12)
0|API      |     at Shim.applySegment (/home/ubuntu/api/node_modules/newrelic/lib/shim/shim.js:1424:20)
0|API      |     at wrapper (/home/ubuntu/api/node_modules/newrelic/lib/shim/shim.js:2065:17)
0|API      |     at _combinedTickCallback (internal/process/next_tick.js:138:11)
0|API      |     at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:218:9) message: 'All providers failed.' }

Getting this error on one server. Same works fine on other servers.

npmjs reports different version

The package.json reports version 3.0.0 but npmjs only serves version 2.0.1. This causes confusion as the docs are different too.

Looking for new maintainer

I don't use this module anymore, and to be honest I don't even use Node.js or GitHub much anymore, and I don't have the time to update it, review issues or pull requests, so I am looking for a new maintainer. I won't just pick anyone, as people are using the module, so I have to ensure it goes into good hands, it's not complicated and there isn't much coding involved it's more about checking providers and keeping on top of stuff. If no one suitable comes forward (in a reasonable amount of time) I will deprecate the module in npm and archive the repo in GitHub.

DOESN'T WORK WITH COLOMBIAN IPs

Hello I used this package in my express backend with node and I used mi local ip that it is from colombia bug the response json doesn't give any information about country name, code, latitud, longitude, etc.
Can you fix this ?

Re-add other services

It might be more useful to have many services that are all slightly off from each other than to rely on a single one.
Maybe re-add the services that used to be here?

More providers

Hi,

I've created the following list with more providers.

trade_name, uri, key, result_pattern, is_free
---------------------------------------------
'Antideo', 'https://api.antideo.com/ip/location/*', '', 'location.country_code', false
'Antideo(Limited)', 'https://api.antideo.com/ip/location/*', '', 'location.country_code', true
'dbip', 'https://api.db-ip.com/v2/#/*/{propertyName}', '#', 'countryCode', false
'dbip(Limited)', 'https://api.db-ip.com/v2/free/*/{propertyName}', '', 'countryCode', true
'Geo IP Lookup', 'http://api.geoiplookup.net/?query=*', '', 'countrycode', true
'ip2c.org', 'https://ip2c.org/*', '', '1;CD;COD;COUNTRY', true
'ip2location', 'https://api.ip2location.com/?ip=*&key=#&package=<WS1|WS2|WS3|...|WS24>&format=json', '#', 'country_code', false
'ip2location(Limited)', 'https://api.ip2location.com/?ip=*&key=#&package=<WS1|WS2|WS3|...|WS24>&format=json', 'demo', 'country_code', true
'ipapi', 'https://ipapi.co/*/json/', '', 'country', false
'ipapi(Limited)', 'https://ipapi.co/*/json/', '', 'country', true
'ipinfo.io', 'https://*?token=#', '#', 'country', false
'ipinfo.io(Limited)', 'https://*?token=#', '#', 'country', true
'IPIP', 'http://enapi.ipip.net/*?token=#', '#', 'country_code', false
'IPIP(Limited)', 'http://enapi.ipip.net/*?token=#', '#', 'country_code', true
'IPLocate', 'https://www.iplocate.io/api/lookup/*?apikey=#', '#', 'country_code', false
'IPLocate(Limited)', 'https://www.iplocate.io/api/lookup/*', '', 'country_code', true
'ipstack', 'https://api.ipstack.com/* ? access_key = #', '#', 'country_code', false
'ipstack(Limited)', 'https://api.ipstack.com/* ? access_key = #', '#', 'country_code', true
'MAXMIND', 'https://geoip.maxmind.com/geoip/v2.1/country/*', '', 'country.iso_code', false

Notes:

  • result pattern is how you can directly get the alpha2 country code from the result
  • * stands for IP address
  • # stands for key, if required
  • {propertyName} is optional
  • (Limited) means that there is a maximum number of api calls that a user can make in a certain temporal period
  • for 'ip2location' a package has to be chosen (default is WS1)
  • 'MAXMIND' requires authentication header
  • Geo IP Lookup and ip2c.org claim that provide free services

Tia

PS: I hope more to be added.

Please add city

City is available as https://ipapi.co/84.68.57.75/json/ returns:
Note that country_capital is of little interest.

{
    "ip": "84.68.57.75",
    "city": "Ilford",
    "region": "England",
    "region_code": "ENG",
    "country": "GB",
    "country_code": "GB",
    "country_code_iso3": "GBR",
    "country_capital": "London",
    "country_tld": ".uk",
    "country_name": "United Kingdom",
    "continent_code": "EU",
    "in_eu": false,
    "postal": "IG3",
    "latitude": 51.5646,
    "longitude": 0.0898,
    "timezone": "Europe/London",
    "utc_offset": "+0100",
    "country_calling_code": "+44",
    "currency": "GBP",
    "currency_name": "Pound",
    "languages": "en-GB,cy-GB,gd",
    "country_area": 244820.0,
    "country_population": 62348447.0,
    "asn": "AS5378",
    "org": "Vodafone Limited"
}

Error to use the IpLocation

Describe the bug
I can't run the library because it gives me a JSON error.

Example
async function myFunction(req, res, next) {
try {
console.log( await ipLocation('172.217.167.78') )
} catch (error) {
console.log(error)
}
}

Expected behavior
I expected a response from the bookstore.

Output log
SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at C:~~~~~\node_modules\ip-location\index.js:12:23
at done (C:~~~~~\node_modules\ip-location\http-get.js:13:5)
at IncomingMessage. (C:~~~~~\node_modules\ip-location\http-get.js:24:7)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser EDGE
  • Version 86.0.622.69

Additional context
Add any other context about the problem here.

🐛Fails Create React App's build

Description

  • When using the package with create react app, it throws the following error on build attempts.
    Creating an optimized production build...
    Failed to compile.
    
    Failed to minify the code from this file:
    
            ./node_modules/ip-regex/index.js:6
    
    Read more here: http://bit.ly/2tRViJ9
  • The reason is ip-regex library failing to be minified.

Fix: #13

Different JSON structures from providers

Each of the providers produces slightly different JSON structures. So what I think this lib needs is an optional transform function per provider to convert the JSON into a set of common fields.
Some of the providers DO produce similar results so they could become the defacto standard.

Basic test failed

Can someone check if this module is being maintained.
Basic test failed with latest version and works fine with 6.x

const ipLocation = require("iplocation");

(async () => {
    await ipLocation("172.217.167.78");
})();

With 7.x (latest), i see the following error
HTTPError: Too Many Requests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.