skaleb-ipstack-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

IP Stack API Client

Build Status Quality Gate Status Bugs Code Smells Coverage

ipstack offers a powerful, real-time IP to geolocation API capable of looking up accurate location data and assessing security threats originating from risky IP addresses. Results are delivered within milliseconds in JSON format. Using the ipstack API you will be able to locate website visitors at first glance and adjust your user experience and application accordingly.

Installation

You can install this package via npm

$ npm install skaleb-ipstack-client

Usage

Getting the geolocation based on a single IP address.

import { 
  Geolocation,
  IPStackClient, 
  InvalidAccessKeyError,
  IPStackClientConfiguration
} from 'ipstack-client'
 
const ipAddress = '41.121.45.123'
const configuration: IPStackClientConfiguration = {
  token: 'some-token',
  timeout: 1000
}
 
const client = new IPStackClient(configuration)
 
// Getting the ISO country code for an IP address
client.getLocation(ipAddress)
    .then((response: Geolocation) => {
      console.log(response.getRawLocationData())
    })
    .catch((invalidAccess: InvalidAccessKeyError) => {
      console.log(invalidAccess.message)
    })

Testing

This project is mostly covered by unit tests. Various cases have been accounted for both in the codebase and in the tests covering it. If a bug is picked up regarding the test suite or code, feel free to make a contribution to help correct the bug.

To run the tests, you can simply run the following test command/s.

npm run test
npm run coverage

Upcoming

Still working on the multiple addresses and selected fields.

Contribution

Feedback and contributions are more than welcome. Should you feel there is something you wish to contribute to this project, feel free to make a merge request. Ensure that whatever proposed change, has tests covering various cases for the change and if required, update all relevant documentation.

Dependents (0)

Package Sidebar

Install

npm i skaleb-ipstack-client

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

77.3 kB

Total Files

85

Last publish

Collaborators

  • toefungi