Skip to main content

Retrieve, store and query information about Regional Internet Registries

Project description

Retrieve, store and query information about Regional Internet Registries

Build_Status codecov PyPI_Version Python_Version


pip install iprir


Query by ip:

>>> import iprir
>>> from ipaddress import IPv4Address, IPv6Address
>>> iprir.by_ip(IPv4Address(''))
RIRRecord(country='US', type='ipv4', start='', value='16777216', status='allocated')

Attributes of RIRRecord:

>>> record = iprir.by_ip(IPv4Address(''))
>>> record.ipv4
>>> record.ipv4_network
>>> record.length
>>> record.as_int

Use IpSet:

>>> us = iprir.by_country('ipv4', 'US')
>>> IPv4Address('') in us
>>> IPv4Address('') in us
>>> from iprir.ipset import IpSet
>>> db = iprir.get_db()
>>> us_and_ca_v6 = IpSet(db.by_country('ipv6', 'US') + db.by_country('ipv6', 'CA'))
>>> IPv6Address('2001:4860:4860::8888') in us_and_ca_v6

Update database:

# update text db and sqlite db
python3 -m iprir.updater

# show more choices
python3 -m iprir.updater -h

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for iprir, version 0.3.0.dev0
Filename, size File type Python version Upload date Hashes
Filename, size iprir-0.3.0.dev0.tar.gz (8.7 kB) File type Source Python version None Upload date Hashes View
Filename, size iprir-0.3.0.dev0-py3-none-any.whl (12.4 MB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page