Skip to content

Comments

Add EU endpoint support and new API response fields#46

Merged
jonathan-kosgei merged 8 commits intomainfrom
claude/update-ipdata-api-W4FVR
Feb 23, 2026
Merged

Add EU endpoint support and new API response fields#46
jonathan-kosgei merged 8 commits intomainfrom
claude/update-ipdata-api-W4FVR

Conversation

@jonathan-kosgei
Copy link
Collaborator

Summary

This PR adds support for the EU endpoint and updates the library to handle new fields in the IPData API response, including the company field and enhanced threat object properties.

Key Changes

  • EU Endpoint Support: Added EU_BASE_URL export and optional baseUrl parameter to the IPData constructor, allowing users to route requests to the EU endpoint (https://eu-api.ipdata.co/) for GDPR compliance
  • New API Fields:
    • Added company field to VALID_FIELDS and LookupResponse interface with name, domain, network, and type properties
    • Added carrier object to response with name, mcc, and mnc properties
    • Extended threat object with is_icloud_relay, is_datacenter, and blocklists properties
    • Added optional code field to language objects in response
  • Constructor Enhancement: Modified IPData constructor to accept optional baseUrl parameter, defaulting to the global endpoint
  • Documentation: Updated README with EU endpoint usage examples and comprehensive response fields reference
  • Tests: Added test coverage for default and custom base URLs, company field selection, and new API response fields
  • Version Bump: Updated package version to 2.3.0

Implementation Details

  • The baseUrl is stored as an instance property and used in both lookup() and bulkLookup() methods via urljoin()
  • All new response fields are marked as optional in the TypeScript interface to maintain backward compatibility
  • The EU endpoint can be imported as a named export for convenience: import IPData, { EU_BASE_URL } from 'ipdata'

https://claude.ai/code/session_01UabaLo3R3sXovyxaZo2yCF

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
@jonathan-kosgei jonathan-kosgei merged commit a823499 into main Feb 23, 2026
2 checks passed
@jonathan-kosgei jonathan-kosgei deleted the claude/update-ipdata-api-W4FVR branch February 23, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants