Skip to content

๐Ÿ—บ This module allows obtaining the client's geolocation using their IP address, leveraging data retrieved from a fast API.

License

Notifications You must be signed in to change notification settings

sefinek/geoip2-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—บ๏ธ GeoIP Lite 2: API Wrapper

The number of downloads Last commit Issues Commit activity Code size

๐Ÿ“ Information

This documentation covers a lightweight Node.js module designed for interacting with a geolocation data API. The module enables efficient retrieval of location details for specific IP addresses, utilizing native modules for optimal performance.

We utilize the MaxMind database via the geoip-lite2 module for our API.

๐Ÿ’ป Locally

There is an alternative to this module that allows for local geolocation retrieval based on a specific IP address. However, this will increase the memory usage because the alternative module stores the MaxMind database in RAM.

geoip-lite2 on npm

๐Ÿ“ฅ Installation

npm install geoip2-api

๐Ÿ˜Ž Example

const geoIp = require('geoip2-api');

(async () => {
    const data = await geoIp.get('185.21.84.216');
    console.log(data);
});

โœจ Output

GET https://api.sefinek.net/api/v2/geoip/185.21.84.216

{
  "success": true,
  "status": 200,
  "ip": "185.21.84.216",
  "data": {
    "range": [3105182720, 3105183743],
    "country": "PL",
    "region": "30",
    "eu": "1",
    "timezone": "Europe/Warsaw",
    "city": "Piล‚a",
    "ll": [53.1492, 16.7461],
    "metro": 0,
    "area": 20
  },
  "type": "unicast"
}

๐ŸŒ  API Tip

If you want to get the client's geolocation, instead of providing an IP, use /api/v2/geoip/myip.

๐Ÿ’™ Support

For any questions or issues related to the script, please visit the GitHub repository for the latest updates and support.

If you like this module, please star โญ the repository.

๐Ÿ”‘ MIT License

This GeoIP API client script is provided under the MIT License. See the LICENSE file for more details.

Copyright 2023-2024 ยฉ by Sefinek. All Rights Reserved.

About

๐Ÿ—บ This module allows obtaining the client's geolocation using their IP address, leveraging data retrieved from a fast API.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •