ASNDB
A simple Python CLI + library for instant lookup of ASN data by IP address, AS number, or organization. Uses BBOT.IO API (asndb.api.bbot.io).
ASNs are automatically cached for instant lookups and minimal network traffic.
Installation
uv tool install asndb
# or quick run with uvx
uvx asndb
# or using pip
pip install asndb
Usage (CLI)
Note: anonymous queries are limited to 10/minute. If you need more, you can purchase an API key at the BBOT.IO Developer Portal. Export the key as an environment variable:
export BBOT_IO_API_KEY=<your_api_key>
IP Lookup
asndb ip 1.1.1.1
Output:
{
"ip": "1.1.1.1",
"asn": 13335,
"asn_name": "CLOUDFLARENET",
"org": "Cloudflare, Inc.",
"org_id": "CLOUD14-ARIN",
"country": "US",
"rir": "ARIN",
"subnets": null
}
To include subnets in the response, use the --include-subnets / -s flag:
asndb ip -s 1.1.1.1
Output:
{
"ip": "1.1.1.1",
"asn": 13335,
"asn_name": "CLOUDFLARENET",
"org": "Cloudflare, Inc.",
"org_id": "CLOUD14-ARIN",
"country": "US",
"rir": "ARIN",
"subnets": [
"1.0.0.0/24",
"1.1.1.0/24",
"..."
]
}
AS Number Lookup
asndb asn 13335
Organization Lookup
asndb org CLOUD14-ARIN
Output:
{
"org_id": "CLOUD14-ARIN",
"org_name": "Cloudflare, Inc.",
"country": "US",
"asns": [
{"asn": 13335, "name": "CLOUDFLARENET"},
{"asn": 14789, "name": "CLOUDFLARENET"},
{"asn": 394536, "name": "CLOUDFLARENET-SFO"},
{"asn": 395747, "name": "CLOUDFLARENET-SFO05"},
{"asn": 400095, "name": "CLOUDFLARENET"}
]
}
Search
asndb search cloudflare
CLI Help
$ asndb --help
Usage: asndb [OPTIONS] COMMAND [ARGS]...
╭─ Options ──────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or │
│ customize the installation. │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────╮
│ ip Lookup ASN by IP address │
│ asn Lookup ASN by AS number │
│ org Get all the ASNs for an organization, by its registered organization ID, e.g. │
│ GOGL-ARIN │
│ search Search for ASNs by name or description │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
Usage (Python)
from asndb import ASNDB
# Create a new ASNDB client
asndb = ASNDB()
# Look up an IP address
asn = asndb.lookup_ip_sync("1.1.1.1")
# {
# "ip": "1.1.1.1",
# "asn": 13335,
# "asn_name": "CLOUDFLARENET",
# "org": "Cloudflare, Inc.",
# "org_id": "CLOUD14-ARIN",
# "country": "US",
# "rir": "ARIN",
# "subnets": null
# }
# Include subnets
asn = asndb.lookup_ip_sync("1.1.1.1", include_subnets=True)
# same as above, but with subnets populated
# Look up an AS number
asn = asndb.lookup_asn_sync(13335)
# Look up an organization
org = asndb.lookup_org_sync("CLOUD14-ARIN")
# {
# "org_id": "CLOUD14-ARIN",
# "org_name": "Cloudflare, Inc.",
# "country": "US",
# "asns": [
# {"asn": 13335, "name": "CLOUDFLARENET"},
# {"asn": 14789, "name": "CLOUDFLARENET"},
# ...
# ]
# }
# Search
results = asndb.search_sync("cloudflare")
Environment Variables
You can customize the behavior of the ASNDB client by exporting the following environment variables:
BBOT_IO_API_KEY: Your BBOT.IO API key.ASNDB_BASE_URL: The base URL of the ASNDB API (default: https://asndb.api.bbot.io/v1).ASNDB_TIMEOUT: The timeout for the ASNDB API requests (default: 60 seconds).ASNDB_CACHE_SIZE: The size of the cache for the ASNDB API requests (default: 10000).
License
Copyright (C) 2025 Black Lantern Security
Licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later). See LICENSE.
Metadata
Release files for asndb 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asndb-1.1.1.tar.gz | 18.8 kB | With provenance | Details for asndb-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asndb-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for asndb-1.1.1-py3-none-any.whl |
Total release size: 37.1 kB
Release files / asndb-1.1.1.tar.gz
| Download URL | asndb-1.1.1.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9272dd29d649ce5c5f5fcc6c84382488120d8f7571656801c8d970e7afc2a03a
|
|
BLAKE2b-256 checksum How to use checksums |
373df4952fb025d45cd3fff5afcf1914ac72da0f8e8b981cda4fe42067b9cf80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logRelease files / asndb-1.1.1-py3-none-any.whl
| Download URL | asndb-1.1.1-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
371c1c0b9e9b7226afcb80bfaac270fdbd23058290df877840f4d45cc73cbb3a
|
|
BLAKE2b-256 checksum How to use checksums |
69e5f0a3f6ff661b7a81d6b31a39ce07d544e797d20ec28e40bea8a3ff3d6293
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logSecurity for asndb 1.1.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for asndb-1.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logA 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.