Skip to main content

PYBGPASN

pybgpasn is a Python package for looking up Autonomous System Number (ASN) information. The package includes a database of ASNs and their corresponding provider names.

Installation

You can install pybgpasn using pip:

pip install pybgpasn

Usage

Basic Usage

To use pybgpasn, first create an instance of the ASNCatalog class:

from pybgpasn import ASNCatalog

catalog = ASNCatalog()

The ASNCatalog class loads the ASN data from the package database file during initialization.

To look up an ASN's provider name, call the get_provider_name method:

asn = 15169  # Google LLC
provider_name = catalog.get_provider_name(asn)
print(provider_name)  # prints "Google LLC"

Private ASNs

If the provided ASN falls within the range of 64512 to 65535 (inclusive), the get_provider_name method will return "PRIVATE AS":

asn = 64512  # Start of private ASN range
provider_name = catalog.get_provider_name(asn)
print(provider_name)  # prints "PRIVATE AS"

asn = 65535  # End of private ASN range
provider_name = catalog.get_provider_name(asn)
print(provider_name)  # prints "PRIVATE AS"

Errors

If an invalid ASN is provided to the get_provider_name method, an error will be raised.

  • If the provided ASN is not an integer, a TypeError will be raised.
  • If the provided ASN is outside the valid range of 0 to 4294967295, a ValueError will be raised.

Here's an example of handling errors when looking up an ASN:

from pybgpasn import ASNCatalog

catalog = ASNCatalog()

try:
    asn = "invalid"  # Not an integer
    provider_name = catalog.get_provider_name(asn)
except TypeError as e:
    print(f"Error: {e}")
    # Output: Error: ASN must be an integer

try:
    asn = -1  # Negative ASN
    provider_name = catalog.get_provider_name(asn)
except ValueError as e:
    print(f"Error: {e}")
    # Output: Error: Invalid ASN number

License

pybgpasn is licensed under the MIT License. See the LICENSE file for more information.

Acknowledgments

pybgpasn includes data from the Border Gateway Protocol (BGP) Autonomous System (AS) Numbers registry maintained by the Internet Assigned Numbers Authority (IANA).

Metadata

Release files for pybgpasn 1.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybgpasn 1.0.13
File Size Uploaded Provenance
pybgpasn-1.0.13.tar.gz 589.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pybgpasn 1.0.13
File Interpreter ABI Platform
pybgpasn-1.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / pybgpasn-1.0.13.tar.gz

Download URL pybgpasn-1.0.13.tar.gz
Size 589.6 kB
Tags Source
SHA-256 checksum
How to use checksums
646a676da2117876dd91418fef5217c19842e479b590891657a1408981de8a77
BLAKE2b-256 checksum
How to use checksums
17edc9e00ed9a0579421a0623c7926865701d3b674fb2dc656f4e9d6a5585893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.9

Release files / pybgpasn-1.0.13-py3-none-any.whl

Download URL pybgpasn-1.0.13-py3-none-any.whl
Size 592.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af0f6a86bfe8110f1a24eb8098bc2a907657434117dfd6ae0977abe538c9b4d7
BLAKE2b-256 checksum
How to use checksums
8127cceb9fb6ebe18e23dbe7ea706dc1466ecb92b02ec7852b26ebbe52fff679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.9

Security for pybgpasn 1.0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page