Skip to content

Add ip2geo IP geolocation provider#490

Open
bfzli wants to merge 1 commit into
DenisCarriere:masterfrom
bfzli:add-ip2geo-provider
Open

Add ip2geo IP geolocation provider#490
bfzli wants to merge 1 commit into
DenisCarriere:masterfrom
bfzli:add-ip2geo-provider

Conversation

@bfzli
Copy link
Copy Markdown

@bfzli bfzli commented Apr 20, 2026

Summary

  • Adds a new provider for the ip2geo IP geolocation API
  • Supports IPv4 and IPv6 address geocoding
  • Returns 30+ fields: city, country, continent, ASN, currency, flag, timezone, etc.
  • API key authentication via X-Api-Key header

Usage

import geocoder

g = geocoder.ip2geo('8.8.8.8', key='your-api-key')
print(g.city)       # Los Angeles
print(g.latlng)     # [34.0544, -118.244]
print(g.org)        # Los Angeles Department Of Water & Power
print(g.timezone)   # America/Los_Angeles

Files changed

  • New: geocoder/ip2geo.py — provider module (Ip2geoQuery + Ip2geoResult)
  • New: tests/test_ip2geo.py — basic test
  • Modified: geocoder/api.py — register provider in options dict + convenience function
  • Modified: geocoder/__init__.py — export ip2geo function

Test plan

  • Provider loads and registers correctly via geocoder.ip2geo()
  • All result properties map correctly from API response
  • Live API test with real key returns correct data

Add support for the ip2geo.dev IP geolocation API. Supports IPv4/IPv6
address lookups with city, country, continent, ASN, currency, flag,
and timezone data.

Usage:
    g = geocoder.ip2geo('8.8.8.8', key='your-api-key')

API docs: https://ip2geo.dev/docs
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.

1 participant