Skip to content

Commit e8b62c5

Browse files
committed
Update README.md with Lite API usage
1 parent 82e3407 commit e8b62c5

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You'll need an IPinfo API access token, which you can get by signing up for a fr
1717

1818
The free plan is limited to 50,000 requests per month, and doesn't include some of the data fields such as IP type and company data. To enable all the data fields and additional request volumes see [https://ipinfo.io/pricing](https://ipinfo.io/pricing).
1919

20-
⚠️ Note: This library does not currently support our newest free API https://ipinfo.io/lite. If you’d like to use IPinfo Lite, you can call the [endpoint directly](https://ipinfo.io/developers/lite-api) using your preferred HTTP client. Developers are also welcome to contribute support for Lite by submitting a pull request.
20+
The library also supports the Lite API, see the [Lite API section](#lite-api) for more info.
2121

2222
### Installation
2323

@@ -57,7 +57,7 @@ const ipinfo = await ipinfoWrapper.lookupIp("1.1.1.1");
5757
5858
<details><summary>Standalone example</summary>
5959

60-
1. Create `ipinfo.js` with the following code, then replace `MY_TOKEN` with
60+
1. Create `ipinfo.js` with the following code, then replace `MY_TOKEN` with
6161
[your token](https://ipinfo.io/account/token).
6262

6363
```typescript
@@ -79,7 +79,7 @@ node ipinfo.js
7979
// ...
8080
```
8181
82-
3. Run `ipinfo.js` with an IP to lookup, like `2.2.2.2` `8.8.8.8` or
82+
3. Run `ipinfo.js` with an IP to lookup, like `2.2.2.2` `8.8.8.8` or
8383
[your IP](https://ipinfo.io/what-is-my-ip).
8484
8585
```shell
@@ -95,7 +95,7 @@ node ipinfo.js 2.2.2.2
9595
9696
Each `lookup` method will throw an error when the lookup does not complete
9797
successfully. A program that performs a lookup should catch errors unless it is
98-
desirable for the error to bubble up. For example, if your program is performing
98+
desirable for the error to bubble up. For example, if your program is performing
9999
a lookup to find the country code of an IP you can return "N/A" when catching an
100100
error.
101101
@@ -106,6 +106,23 @@ const countryCode = ipinfoWrapper
106106
.catch((error) => "N/A");
107107
```
108108
109+
### Lite API
110+
111+
The library gives the possibility to use the [Lite API](https://ipinfo.io/developers/lite-api) too, authentication with your token is still required.
112+
113+
The returned details are slightly different from the Core API.
114+
115+
```typescript
116+
import IPinfoLiteWrapper from "node-ipinfo";
117+
118+
const ipinfoWrapper = new IPinfoLiteWrapper("MY_TOKEN");
119+
const ipinfo = await ipinfoWrapper.lookupIp("8.8.8.8");
120+
console.log(ipinfo.countryCode)
121+
// US
122+
console.log(ipinfo.country)
123+
// United States
124+
```
125+
109126
### Caching
110127
111128
This library uses an LRU cache (deletes the least-recently-used items).
@@ -224,7 +241,7 @@ const { IPinfoWrapper } = require("node-ipinfo");
224241
225242
const ipinfoWrapper = new IPinfoWrapper("MY_TOKEN");
226243
227-
const ips = ["1.1.1.1", "8.8.8.8", "1.2.3.4"];
244+
const ips = ["1.1.1.1", "8.8.8.8", "1.2.3.4"];
228245
ipinfoWrapper.getMap(ips).then(response => {
229246
console.log(response);
230247
});
@@ -239,7 +256,7 @@ const { IPinfoWrapper } = require("node-ipinfo");
239256
240257
const ipinfoWrapper = new IPinfoWrapper("MY_TOKEN");
241258
242-
const ips = ["1.1.1.1", "8.8.8.8", "1.2.3.4/country"];
259+
const ips = ["1.1.1.1", "8.8.8.8", "1.2.3.4/country"];
243260
244261
ipinfoWrapper
245262
.getBatch(ips)

0 commit comments

Comments
 (0)