@smartip/js
Version:
SmartIP.io Official Javascript Library (Typescript)
62 lines (45 loc) • 2.14 kB
Markdown
# [<img src="https://smartip.io/images/twitter_logo_noname.png" alt="SmartIP" width="24"/>](https://smartip.io/) SmartIP.io Official Javascript library
[](https://opensource.org/licenses/Apache-2.0) <img alt="npm type definitions" src="https://img.shields.io/npm/types/typescript"> [](https://badge.fury.io/js/%40smartip%2Fjs)
This is the official Javascript Library for [SmartIP.io](https://smartip.io), which allows a fast lookup of any IP address or ASN.
Our main features are:
- IP Geolocation data (country, city, postal codes, latitude, longitude)
- Timezone data
- Currency data
- Security data (TOR insights, Crawler insights, Proxy insigths)
- Crypto data (Bitcoin nodes)
- ASN data (number of IPs managed by an ASN, the organization name, the list of IP blocks managed by a given ASN)
- User Agent detection
## Getting started
In order to use SmartIP.io API, you will need to register a free account at https://smartip.io and get an API KEY.
All data fields are always enabled regardless of the subscription tier.
- The Free tier will allow up to 125,000 requests a month.
- The PRO tier will allow for an unlimited number of requests a month.
More pricing info are available at: https://smartip.io/#pricing-section
## Installation
### Npm
```javascript
$ npm install @smartip/js
```
### Yarn
```javascript
$ yarn add @smartip/js
```
## Usage example
IP Lookup:
```javascript
const {SmartIP} = require("@smartip/js")
let testApiKey = '249C35CF-81E7-4B49-8F9F-ACA72C9F5CD7';
const client = new SmartIP(testApiKey);
let hostname = true;
let userAgent = true;
let ipInfo = await client.requestIPData('8.8.8.8', hostname, userAgent);
console.log(ipInfo);
```
ASN Lookup:
```javascript
const {SmartIP} = require("@smartip/js")
let testApiKey = '249C35CF-81E7-4B49-8F9F-ACA72C9F5CD7';
const client = new SmartIP(testApiKey);
let asnInfo = await client.requestAsnData("AS15169");
console.log(asnInfo);
```