https://github.com/roryrjb/iplocation
Get ip location information.
https://github.com/roryrjb/iplocation
geolocation geolocation-api ip ip-address iplocation nodejs
Last synced: about 2 months ago
JSON representation
Get ip location information.
- Host: GitHub
- URL: https://github.com/roryrjb/iplocation
- Owner: Richienb
- License: mit
- Created: 2014-09-14T07:27:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-10-25T04:57:55.000Z (over 3 years ago)
- Last Synced: 2024-08-04T00:03:59.116Z (9 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 [](https://travis-ci.com/Richienb/iplocation)
Get ip location information.
[](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.