Add EU endpoint support and new API response fields#46
Merged
jonathan-kosgei merged 8 commits intomainfrom Feb 23, 2026
Merged
Conversation
Add company object, carrier typing, threat intelligence fields (is_icloud_relay, is_datacenter, blocklists), and language code to the TypeScript interface. Add company to valid fields list while keeping organisation for backwards compatibility. Bump to 2.3.0. https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF
Add optional baseUrl constructor parameter so users can target the EU endpoint (eu-api.ipdata.co) or any custom URL. Export EU_BASE_URL constant. Update README with EU endpoint docs and response fields reference for company, carrier, and threat objects. https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF
Major upgrades: - axios: ^0.21.1 → ^1.13.5 (fixes known CVEs) - lru-cache: ^5.1.1 → ^11.2.6 (maxAge→ttl, LRUCache named export) - typescript: ^4.6.3 → ^5.9.3 (target es5→es2015) - tslib: ^1.10.0 → ^2.8.1 - prettier: ^1.18.2 → ^3.8.1 - @typescript-eslint/*: ^2.6.1 → ^8.56.0 - eslint: ^6.5.1 → ^8.57.0 - jest: ^24.9.0 → ^29.7.0, ts-jest: ^24.1.0 → ^29.4.6 Held back ESM-only packages (is-ip, url-join) and eslint 9+ (flat config migration out of scope). Updated CacheConfig interface (maxAge→ttl), eslint config (removed deprecated prettier/@typescript-eslint), tsconfig (es2015 target, explicit moduleResolution), and README. https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF
BREAKING CHANGE: Requires Node.js >= 18 (for native fetch). CacheConfig.maxAge renamed to CacheConfig.ttl (from lru-cache v11). Version bumped to 3.0.0. - Replace axios with native fetch (zero-dep HTTP) - Replace lodash/isString and lodash/isArray with typeof/Array.isArray - Replace is-ip with Node built-in net.isIP() - Replace url-join with URL constructor - Mock all HTTP calls in tests (no API key required for CI) - Remove dotenv-cli (tests no longer need env vars) - Runtime deps reduced from 6 to 2 (lru-cache, tslib) https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF
- Fix trailing whitespace in test descriptions - Use toBe() instead of toEqual() for primitive comparisons - Add parentheses to single-param arrow functions - Format long object literals across multiple lines - Use toBeDefined() instead of not.toBeUndefined() https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF
- Replace `any` types with proper types in ipdata.ts (unknown, LookupResponse[]) - Fix no-use-before-define by moving keyBy() above its usage in tests - Replace for...of with Array.reduce to satisfy no-restricted-syntax rule - Type mockFetchResponse parameter as unknown instead of any - Update README badge URL to match package.json repository (thomasconner) - Add missing organisation field to README response fields list https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF
Tests use mocked fetch and don't make real API calls. https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for the EU endpoint and updates the library to handle new fields in the IPData API response, including the
companyfield and enhancedthreatobject properties.Key Changes
EU_BASE_URLexport and optionalbaseUrlparameter to theIPDataconstructor, allowing users to route requests to the EU endpoint (https://eu-api.ipdata.co/) for GDPR compliancecompanyfield toVALID_FIELDSandLookupResponseinterface withname,domain,network, andtypepropertiescarrierobject to response withname,mcc, andmncpropertiesthreatobject withis_icloud_relay,is_datacenter, andblocklistspropertiescodefield to language objects in responseIPDataconstructor to accept optionalbaseUrlparameter, defaulting to the global endpointcompanyfield selection, and new API response fieldsImplementation Details
baseUrlis stored as an instance property and used in bothlookup()andbulkLookup()methods viaurljoin()import IPData, { EU_BASE_URL } from 'ipdata'https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF