Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Richienb/iplocation
Get ip location information.
https://github.com/Richienb/iplocation
geolocation geolocation-api ip ip-address iplocation nodejs
Last synced: 24 days ago
JSON representation
Get ip location information.
- Host: GitHub
- URL: https://github.com/Richienb/iplocation
- Owner: Richienb
- License: mit
- Created: 2014-09-14T07:27:14.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-10-25T04:57:55.000Z (about 3 years ago)
- Last Synced: 2024-08-04T00:03:59.116Z (4 months ago)
- Topics: geolocation, geolocation-api, ip, ip-address, iplocation, nodejs
- Language: TypeScript
- Homepage:
- Size: 108 KB
- Stars: 77
- Watchers: 5
- Forks: 23
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iplocation [![Travis CI Build Status](https://img.shields.io/travis/com/Richienb/iplocation/master.svg?style=for-the-badge)](https://travis-ci.com/Richienb/iplocation)
Get ip location information.
[![NPM Badge](https://nodei.co/npm/iplocation.png)](https://npmjs.com/package/iplocation)
## Install
```sh
npm install iplocation
```## Usage
```js
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](https://ipapi.co/) API key to use.
```js
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](https://ipapi.co/) for IP lookups. Their free API is limited to 1000 requests per day.
## Related
- [iplocation-cli](https://github.com/Richienb/iplocation-cli) - CLI for this module.