Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adamlui/geolocate

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adamlui/geolocate

Fetch IP geolocation data from the CLI.

  • 2.0.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

geolocate

Fetch IP geolocation data from the CLI.


⚡ Installation

As a global utility:

$ npm install -g @adamlui/geolocate

As a dev dependency, from your project root:

$ npm install -D @adamlui/geolocate

As a runtime dependency, from your project root:

$ npm install @adamlui/geolocate

💻 Command line usage

The basic global command is:

$ geolocate [ip1] [ip2] [...]

Sample output:

📝 Note: If no IPv4 address is passed, your own one will be used.

Command line options

Boolean options:
 -q, --quiet                 Suppress all logging except errors.

Info commands:
 -h, --help                  Display help screen.
 -v, --version               Show version number.

🔌 Importing the API

You can also import geolocate into your app to use its main API method.

Node.js

ECMAScript*:
import geo from '@adamlui/geolocate';
CommonJS:
const geo = require('@adamlui/geolocate');
*Node.js version 14 or higher required

Web

<> HTML script tag:
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.10/dist/geolocate.min.js"></script>
ES6:
(async () => {
    await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.10/dist/geolocate.min.js');
    // Your code here...
})();

Greasemonkey

...
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.10/dist/geolocate.min.js
// ==/UserScript==

// Your code here...

📝 Note: To always import the latest version (not recommended in production!) remove the @2.0.10 version tag from the jsDelivr URL: https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js


📋 API usage

locate([ips, options])

💡 Asynchronous method to fetch geolocation data for each ip passed in an array, returned as an array of data objects.

Example:

const geo = require('@adamlui/geolocate');

// Using await syntax
(async () => {
    const location = await geo.locate('8.8.8.8');
    console.log(location);
})();

// Using .then() syntax
geo.locate('8.8.8.8').then(location => {
    console.log(location);
});

/* outputs:
[{
  ip: '8.8.8.8',
  country: 'United States',
  countryCode: 'US',
  region: 'VA',
  regionName: 'Virginia',
  city: 'Ashburn',
  zip: '20149',
  lat: 39.03,
  lon: -77.5,
  timezone: 'America/New_York',
  isp: 'Google LLC'
}]
*/

📝 Note: If no IPv4 address is passed, your own one will be used.

Available options (passed as object properties):

NameTypeDescriptionDefault Value
verboseBooleanShow logging in console/terminal.true

🏛️ MIT License

Copyright © 2024 Adam Lui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


generate-ip  

Randomly generate, format, and validate IPv4 + IPv6 + MAC addresses.
Install / Readme / API usage / CLI usage / Discuss

🔒 generate-pw  

Randomly generate, strengthen, and validate cryptographically-secure passwords.
Install / Readme / API usage / CLI usage / Discuss


More JavaScript utilities / Discuss / Back to top ↑

Keywords

FAQs

Package last updated on 25 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc