Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ipapi-is/ip_to_hosting
This package allows you to check whether an IP address belongs to a hosting provider or not. In case the IP address can be successfully linked to a hosting provider (datacenter), this module will return the meta information for the hosting provider.
https://github.com/ipapi-is/ip_to_hosting
api aws azure cloud-provider datacenter-detection gcp hosting-detection
Last synced: 18 days ago
JSON representation
This package allows you to check whether an IP address belongs to a hosting provider or not. In case the IP address can be successfully linked to a hosting provider (datacenter), this module will return the meta information for the hosting provider.
- Host: GitHub
- URL: https://github.com/ipapi-is/ip_to_hosting
- Owner: ipapi-is
- Created: 2022-12-09T14:58:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-22T12:07:02.000Z (about 1 year ago)
- Last Synced: 2024-10-14T16:40:12.474Z (about 1 month ago)
- Topics: api, aws, azure, cloud-provider, datacenter-detection, gcp, hosting-detection
- Language: JavaScript
- Homepage: https://ipapi.is/
- Size: 12.7 KB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IP to Hosting
[![Npm package version](https://badgen.net/npm/v/ip-to-hosting)](https://www.npmjs.com/package/ip-to-hosting)
[![Npm package yearly downloads](https://badgen.net/npm/dy/ip-to-hosting)](https://npmjs.com/package/ip-to-hosting)This package allows you to check whether an IP address belongs to a hosting/cloud provider. In case the IP belongs to a hosting provider (datacenter), this module will return the meta information for the hosting provider.
Currently, there are more than 180,000 IP ranges from more than 4,400 hosting providers in the database. Learn more, by [reading the documentation](https://ipapi.is/hosting-detection.html).
## Installation
You can both use this package from Node.js and in the browser with vanilla JavaScript.
```bash
npm install ip-to-hosting
```If you want to clone the repository directly from GitHub instead:
```bash
git clone [email protected]:ipapi-is/ip_to_hosting.git
```## Usage from Node.js
If you want to lookup the following IP addresses:
```JavaScript
const { ipToHosting } = require('ip-to-hosting');const ipAddresses = [
'144.168.164.55',
'167.99.241.66',
'97.107.129.77',
'85.10.199.76',
];for (let ip of ipAddresses) {
ipToHosting(ip).then(function (isHosting) {
console.log(`${ip} isHosting:`);
console.log(isHosting);
});
}
```which yields:
```JavaScript
85.10.199.76 isHosting:
{
datacenter: 'Hetzner Online GmbH',
domain: 'www.hetzner.com',
network: '85.10.192.0 - 85.10.207.255'
}
167.99.241.66 isHosting:
{
datacenter: 'DigitalOcean',
code: '60341',
city: 'Frankfurt',
state: 'DE-HE',
country: 'DE',
network: '167.99.240.0/20'
}
144.168.164.55 isHosting:
{
datacenter: 'ServerMania Inc.',
domain: 'https://www.servermania.com/',
network: '144.168.128.0-144.168.255.255'
}
97.107.129.77 isHosting:
{
datacenter: 'Linode',
domain: 'https://www.linode.com/',
network: '97.107.128.0-97.107.143.255'
}
```If the IP address belongs to a datacenter/hosting provider, the API response will return an object with the following required attributes:
- `datacenter` - `string` - to which datacenter the IP address belongs. For a full list of datacenters, check the [ipapi.is/json/info endpoint](https://ipapi.is/json/info). In this case, the datacenter's name is `B2 Net Solutions Inc.`
- `domain` - `string` - The domain name of the company
- `network` - `string` - the network this IP address belongs to (In the above case: `144.168.128.0 - 144.168.255.255`)With some datacenter providers, more meta data is available. Consult the [API documentation page](https://ipapi.is/developers.html) in order to learn more.
Most IP's don't belong to a hosting provider. In those cases, the response will be `null`.
## Usage from the Browser
Copy the browser JavaScript bundle to your preferred location. After installing the module with
```bash
npm install ip-to-hosting
```you can find the minified JavaScript here: `node_modules/ip-to-hosting/dist/ipToHosting.min.js`
```html
IP to Hosting Example Browser
ipToHosting('43.33.44.11').then((res) => {
document.getElementById('hosting').innerText = JSON.stringify(res, null, 2);
});
```
## Use the Database Directly
This package uses the [ipapi.is API](https://ipapi.is/developers.html) in order to avoid shipping a huge database in the npm module. If you have a large volume of IP addresses to lookup, you can download the full & free [Hosting Provider Database](https://ipapi.is/hosting-detection.html).
GitHub mirror of the database: [Hosting Provider Database Mirror](https://github.com/ipapi-is/ipapi/tree/main/databases)