Skip to content

Commit a823499

Browse files
Merge pull request #46 from ipdata/claude/update-ipdata-api-W4FVR
Add EU endpoint support and new API response fields
2 parents b820c02 + df873f1 commit a823499

9 files changed

Lines changed: 5788 additions & 7340 deletions

File tree

.eslintrc.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ module.exports = {
99
extends: [
1010
'airbnb-base',
1111
'plugin:@typescript-eslint/recommended',
12-
'prettier/@typescript-eslint',
13-
'plugin:prettier/recommended',
1412
'plugin:import/recommended',
15-
'plugin:import/typescript'
13+
'plugin:import/typescript',
14+
'plugin:prettier/recommended'
1615
],
1716
parser: '@typescript-eslint/parser',
1817
parserOptions: {

.github/workflows/default.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ jobs:
2828
- name: Install dependencies
2929
run: npm ci
3030
- name: Test
31-
env:
32-
IPDATA_API_KEY: ${{ secrets.IPDATA_API_KEY }}
3331
run: npm test

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
- name: Install dependencies
2929
run: npm ci
3030
- name: Test
31-
env:
32-
IPDATA_API_KEY: ${{ secrets.IPDATA_API_KEY }}
3331
run: npm test
3432

3533
release:

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# IPData JavaScript Library
22

3-
[![](https://github.com/ConnerTechnology/ipdata-js-library/workflows/CI/badge.svg)](https://github.com/ConnerTechnology/ipdata-js-library/actions)
3+
[![](https://github.com/ipdata/node/workflows/CI/badge.svg)](https://github.com/ipdata/node/actions)
44

55
JavaScript library that can be used in a web browser or Node.js application to gather information for an IP address using https://ipdata.co.
66

@@ -10,8 +10,10 @@ JavaScript library that can be used in a web browser or Node.js application to g
1010
- [Use](#use)
1111
- [Import Library](#import-library)
1212
- [Create an Instance](#create-an-instance)
13+
- [EU Endpoint](#eu-endpoint)
1314
- [Lookup](#lookup)
1415
- [Bulk Lookup](#bulk-lookup)
16+
- [Response Fields](#response-fields)
1517

1618
## Install
1719

@@ -48,20 +50,36 @@ The library will cache 4096 ip addresses responses for 24 hours using a LRU cach
4850
```js
4951
const cacheConfig = {
5052
max: 1000, // max size
51-
maxAge: 10 * 60 * 1000, // max age in ms (i.e. 10 minutes)
53+
ttl: 10 * 60 * 1000, // time-to-live in ms (i.e. 10 minutes)
5254
};
5355
const ipdata = new IPData('<apiKey>', cacheConfig);
5456
```
5557

56-
**Note:** To disable the cache pass `-1` as the `maxAge`.
58+
**Note:** To disable the cache pass `1` as the `ttl` (1ms effectively disables caching).
5759

5860
```js
5961
const cacheConfig = {
60-
maxAge: -1, // disable the cache
62+
ttl: 1, // disable the cache
6163
};
6264
const ipdata = new IPData('<apiKey>', cacheConfig);
6365
```
6466

67+
### EU Endpoint
68+
69+
By default requests are routed to the global endpoint (`https://api.ipdata.co`). To ensure end user data stays in the EU, pass the EU endpoint as the third parameter.
70+
71+
```js
72+
import IPData, { EU_BASE_URL } from 'ipdata';
73+
74+
const ipdata = new IPData('<apiKey>', undefined, EU_BASE_URL);
75+
```
76+
77+
You can also pass a custom base URL if needed.
78+
79+
```js
80+
const ipdata = new IPData('<apiKey>', undefined, 'https://eu-api.ipdata.co/');
81+
```
82+
6583
### Lookup
6684

6785
The library will lookup the ip address of the host computer if no ip address is provided.
@@ -131,3 +149,15 @@ ipdata.bulkLookup(ips, fields)
131149
// ...
132150
});
133151
```
152+
153+
## Response Fields
154+
155+
The following fields are available for use with `selectField` and `fields` parameters:
156+
157+
`ip`, `is_eu`, `city`, `region`, `region_code`, `country_name`, `country_code`, `continent_name`, `continent_code`, `latitude`, `longitude`, `asn`, `company`, `organisation`, `postal`, `calling_code`, `flag`, `emoji_flag`, `emoji_unicode`, `carrier`, `languages`, `currency`, `time_zone`, `threat`, `count`
158+
159+
The `company` field returns an object with `name`, `domain`, `network`, and `type` properties.
160+
161+
The `carrier` field returns an object with `name`, `mcc`, and `mnc` properties.
162+
163+
The `threat` field returns an object with `is_tor`, `is_icloud_relay`, `is_proxy`, `is_datacenter`, `is_anonymous`, `is_known_attacker`, `is_known_abuser`, `is_threat`, `is_bogon`, and `blocklists` properties.

0 commit comments

Comments
 (0)