@toil/ip-geolocation
v1.0.0
Published
A library for free (and not only free) use of the ip geolocation APIs
Maintainers
Readme
IP Geolocation
A library for free (and not only free) use of the IP Geolocation APIs, which supports working with JavaScript, TypeScript, and also has built-in separated types for Typebox.
Installation
Installation via Bun:
bun add @toil/ip-geolocation
Installation via NPM:
npm install @toil/ip-geolocation
Getting started
To get started with the API, you need to create an IPGeolocation client. This can be done using the code below.
const client = new IPGeolocationClient({
service: IPGeolocationService.freeipapi,
});
const result = await client.lookup("103.21.244.0");
You can see more code examples here
Available services
In some services, transferring reserved ranges of IP addresses may cause an error - this is normal.
If you are missing some data in the lookup method, and the service should have it, it's recommended to consider using the provider directly using the rawLookup method
| Status | Service | Limits | Features | | ------ | ----------------------------------- | ---------- | ------------------------------- | | ✅ | FreeIPAPI | 60 req/min | detail | | ✅ | IPAPICom | 45 req/min | detail |
More detailed information about the supported access services here
Build
To build, you must have:
Don't forget to install the dependencies:
bun install
Regular Build
Building the entire package:
bun build:bun
Building a types for TypeBox
You can use this build option if you only want to build types for TypeBox:
bun build:typebox
Tests
The library has minimal test coverage to check it's performance.
Run the tests:
bun test