Skip to content

Commit

Permalink
Publish Ip-Locator
Browse files Browse the repository at this point in the history
  • Loading branch information
sasmeee committed Jul 27, 2023
0 parents commit 90aa11d
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# **IP Locator** - NPM Pacakge for get IP data

IP-Locator is a versatile package that allows you to easily retrieve valuable information based on IP Addresses. With IP-Locator, you can effortlessly access user location details, country-specific data, and even obtain real-time weather updates, all in a single package. This project is based on Javascript.

_Coded by: [Sasmitha Ashinsana](https://github.com/sasmeee)_

## Installation

```
npm i @sasmeee/ip-locator
```

## Usage

```js
const getGeoData = require("@sasmeee/ip-locator");
```

## Note

> **Note:** You should use a valid IP address for doing that.

## Methods

### getGeoData(ip)

Code:

```js
const ip = "112.134.193.130"; // Enter your IP here

const data = await getGeoData(ip);
console.log(data);
```

Output:

```json
{
"ip": "112.134.193.130",
"city": "Panadura",
"region": "Kalutara District (13)",
"country": "Sri Lanka",
"postal_code": "12500",
"continent": "Asia (AS)",
"coordinates": {
"lat": "6.7154",
"long": "79.9019"
},
"time": "2023-07-27 13:23:47 (Asia/Colombo)",
"country_data": {
"common_name": "Sri Lanka",
"cca2": "LK",
"official": "Democratic Socialist Republic of Sri Lanka",
"subregion": "Southern Asia",
"languages": "Sinhala, Tamil",
"currencies": "{\"LKR\":{\"name\":\"Sri Lankan rupee\",\"symbol\":\"Rs රු\"}}",
"timezones": "UTC+05:30",
"area": 65610,
"population": 21919000,
"independent": true,
"capital": "Sri Jayawardenepura Kotte",
"flags": {
"svg": "https://flagcdn.com/lk.svg",
"png": "https://flagcdn.com/w320/lk.png"
}
},
"weather": {
"temperature": "+30°C",
"skyCondition": "cloudy",
"weatherCondition": "↗19km/h"
}
}
```

## License

This project is protected by the `MIT License.`

## Disclaimer

If you have any complain about this package, please contact via [email protected]
1 change: 1 addition & 0 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@sasmeee/ip-locator",
"version": "1.0.0",
"description": "IP-Locator is a versatile package that allows you to easily retrieve valuable information based on IP Addresses. With IP-Locator, you can effortlessly access user location details, country-specific data, and even obtain real-time weather updates, all in a single package.",
"main": "index.js",
"scripts": {
"test": "node test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sasmeee/ip-locator.git"
},
"keywords": [
"IP address",
"location",
"geodata",
"country",
"weather",
"coordinates",
"latitude",
"longitude"
],
"author": "Sasmitha Ashinsana",
"license": "MIT",
"bugs": {
"url": "https://github.com/sasmeee/ip-locator/issues"
},
"homepage": "https://github.com/sasmeee/ip-locator#readme",
"dependencies": {
"axios": "^1.4.0",
"cheerio": "^1.0.0-rc.12"
}
}
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const getGeoData = require("./index");

async function getLocation() {
const ip = "112.134.193.130";

try {
const data = await getGeoData(ip);
console.log(data);
} catch (error) {
console.error(error);
}
}

getLocation();

0 comments on commit 90aa11d

Please sign in to comment.