Skip to main content

Python client library for IP Netblocks API.

Project description

ip-netblocks-py license ip-netblocks-py release ip-netblocks-py build

Overview

The client library for IP Netblocks API in Python language.

The minimum Python version is 3.6.

Installation

pip install ip-netblocks

Examples

Full API documentation available here

Create a new client

from ipnetblocks import *

client = Client('Your API key')

Make basic requests

# Get netblocks for a given IPv4 or IPv6 address.
response = client.get('8.8.8.8')
print(response)

# Get netblocks by AS number
response = client.get_by_asn(15169)
# or
client.get(asn=15169)

# Find IP Netblocks which have the specified search terms in their
# Netblock (netname, description, remarks),
# or Organisation (org.org, org.name, org.email, org.address) fields.
response = client.get_by_org(['google', 'cloud'])
# or
client.get(org='google')

# Get raw API response in XML format
raw_result = client.get_raw('2.2.2.2',
    output_format=Client.XML_FORMAT)

Advanced usage

Extra request parameters

result = client.get(
    '1.1.1.1',
    mask=24,
    limit=10)

Response model overview

Response:
    - search: [str]
    - count: int
    - limit: int
    - inetnums: [Inetnum]
        - inetnum: str
        - inetnum_first: str
        - inetnum_last: str
        - parent: str
        - AS: AutonomousSystem
            - asn: int
            - name: str
            - type: str
            - route: str
            - domain: str
        - netname: str
        - nethandle: str
        - description: [str]
        - modified: datetime
        - country: str
        - city: str
        - address: [str]
        - org: Org
            - org: str
            - name: str
            - email: str
            - phone: str
            - country: str
            - city: str
            - postal_code: str
            - address: [str]
        - abuse_contact: [Contact]
            - id: str
            - person: str
            - role: str
            - email: str
            - phone: str
            - country: str
            - city: str
            - address: [str]
        - admin_contact: [Contact]
        - tech_contact: [Contact]
        - mnt_by: [Maintainer]
            - mntner: str
            - email: str
        - mnt_domains: [Maintainer]
        - mnt_lower: [Maintainer]
        - mnt_routes: [Maintainer]
        - remarks: [str]
        - source: str

Sample response

{ 'search': '8.8.8.8', 'count': '7', 'limit': '100',
  'inetnums': [
      {'inetnum': '8.8.8.0 - 8.8.8.255',
       'inetnum_first': 281470816487424,
       'inetnum_last': 281470816487679,
       'parent': '',
       'AS': {'asn': 15169,
              'name': 'Google LLC',
              'type': 'Content',
              'route': '8.8.8.0/24',
              'domain': 'https://about.google/intl/en/'}",
       'netname': 'LVLT-GOGL-8-8-8', 'nethandle': 'NET-8-8-8-0-1',
       'description': [],
       'modified': '2014-03-14 00:00:00',
       'country': 'US',
       'city': 'Mountain View',
       'address': ['1600 Amphitheatre Parkway'],
       'abuse_contact': [], 'admin_contact': [], 'tech_contact': [],
       'org': {'org': 'GOGL',
               'name': 'Google LLC',
               'email': 'arin-contact@google.com\\nnetwork-abuse@google.com',
               'phone': '+1-650-253-0000',
               'country': 'US',
               'city': 'Mountain View',
               'postal_code': '94043',
               'address': ['1600 Amphitheatre Parkway']},
       'mnt_by': [], 'mnt_domains': [], 'mnt_lower': [], 'mnt_routes': [],
       'remarks': [],
       'source': 'ARIN'}
      {'inetnum': '8.0.0.0 - 8.15.255.255',
       'inetnum_first': 281470815961088,
       'inetnum_last': 281470817009663,
       'parent': '8.0.0.0 - 8.127.255.255',
       'AS': {'asn': 3356,
              'name': 'Lumen AS 3356',
              'type': 'NSP',
              'route': '8.0.0.0/12',
              'domain': 'http://www.lumen.com'}",
       'netname': 'LVLT-ORG-8-8', 'nethandle': 'NET-8-0-0-0-1',
       'description': [],
       'modified': '2018-04-23 00:00:00',
       'country': 'US',
       'city': 'Monroe',
       'address': ['100 CenturyLink Drive'],
       'abuse_contact': [], 'admin_contact': [], 'tech_contact': [],
       'org': {'org': 'LPL-141',
               'name': 'Level 3 Parent, LLC',
               'email': 'abuse@level3.com nipaddressing@level3.com',
               'phone': '+1-877-453-8353',
               'country': 'US',
               'city': 'Monroe',
               'postal_code': '71203',
               'address': ['100 CenturyLink Drive']},
       'mnt_by': [], 'mnt_domains': [], 'mnt_lower': [], 'mnt_routes': [],
       'remarks': [],
       'source': 'ARIN'}
      ...
  ]
}

Changelog

1.0.0 (2021-11-02)

  • First release

Project details


Download files

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

Source Distribution

ip-netblocks-1.0.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

ip_netblocks-1.0.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file ip-netblocks-1.0.0.tar.gz.

File metadata

  • Download URL: ip-netblocks-1.0.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for ip-netblocks-1.0.0.tar.gz
Algorithm Hash digest
SHA256 99fbce9adff804456df058876cfd0731c78130afa97634fabb9587bca49ed5f1
MD5 6969a97c0c1681afd501e36ed78c7f6d
BLAKE2b-256 f2b9c776589baac9f94388c719e1c2c96be5362f5feae970f9adc6b1ff8652dd

See more details on using hashes here.

File details

Details for the file ip_netblocks-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ip_netblocks-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for ip_netblocks-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eabf1f2618ec83d7d9cd45705443e103e3d5d4c4674c2d16db6c9d49ad4142c8
MD5 ee3eadcfea9649e0aea9c469fe7f33fc
BLAKE2b-256 0693d4a2960874690c94626216fccd6cc3a1f6cd69e1a15077a25b3d16b8346a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page