Skip to main content

๐Ÿ” Read-only CLI tool to pull IPAM data from NetBox

Project description

๐Ÿ” nbpull

CI Python 3.13+ License: GPL v3 Typed NetBox 4.4+

Read-only CLI tool to pull IPAM data from NetBox.

๐Ÿ”’ Safety guarantee: nbpull only reads data from NetBox. No POST / PUT / PATCH / DELETE requests are ever made. The HTTP client is hardcoded to GET-only โ€” this invariant is enforced by code structure and verified by tests.

๐ŸŒ NetBox compatibility: Tested against NetBox Cloud v4.4.10. Compatible with NetBox v3.x+ (legacy site field) and v4.2+ (generic scope relation). The Prefix model transparently handles both via the resolved_site property.


โœจ Features

  • ๐Ÿ“ก Prefixes โ€” list and filter IPAM prefixes
  • ๐Ÿ–ฅ๏ธ IP Addresses โ€” query IP address allocations
  • ๐Ÿท๏ธ VLANs โ€” browse VLAN assignments
  • ๐Ÿ”€ VRFs โ€” inspect VRF instances
  • ๐Ÿ“Š Aggregates โ€” list top-level IP space by RIR
  • ๐Ÿข Sites โ€” browse DCIM sites
  • ๐Ÿ–ง Devices โ€” query DCIM devices
  • ๐Ÿ›๏ธ Tenants โ€” list tenancy tenants
  • ๐ŸŒ RFC 1918 โ€” inventory Global VRF RFC 1918 prefixes with mapping status
  • ๐Ÿ“ฆ Batch queries โ€” check many prefixes at once from a TOML file
  • ๐ŸŽจ Rich table output (default), JSON saved to a file (--format json), or CSV (--format csv)
  • ๐Ÿ”Ž Filter by status, VRF, tenant, site, tag, or free-text search
  • โšก Async HTTP with automatic pagination
  • ๐Ÿ”’ Strict typing (mypy strict mode + Pydantic v2)

๐Ÿ“ฆ Installation

With uv (recommended)

uv tool install nbpull

With pipx

pipx install nbpull

With pip

pip install nbpull

From source

git clone https://github.com/Champion2005/nbpull.git
cd nbpull
make install   # uses uv sync

๐Ÿš€ Quick Start

# 1. Run the interactive setup wizard
nbpull setup

# Or configure manually:
export NETBOX_URL=https://netbox.example.com
export NETBOX_TOKEN=your_read_only_token
# Or: cp .env.example .env && edit .env

# 2. Pull data
nbpull prefixes
nbpull prefixes --status active --vrf Production
nbpull ip-addresses --prefix 10.0.0.0/24
nbpull vlans --site DC1
nbpull vrfs --tenant Ops
nbpull aggregates --rir ARIN
nbpull sites --status active
nbpull devices --role "Core Router"
nbpull tenants
nbpull rfc1918
nbpull batch-prefixes --file my_prefixes.toml --status-only

๐Ÿ“‹ Commands

Command Description
nbpull setup Interactive setup wizard
nbpull prefixes List IPAM prefixes
nbpull ip-addresses List IP addresses
nbpull vlans List VLANs
nbpull vrfs List VRFs
nbpull aggregates List IPAM aggregates (top-level space by RIR)
nbpull sites List DCIM sites
nbpull devices List DCIM devices
nbpull tenants List tenancy tenants
nbpull rfc1918 Inventory Global VRF RFC 1918 prefixes with mapping status
nbpull location-report Location-to-IP report โ€” mapped prefixes with PRD and general columns
nbpull batch-prefixes Query multiple prefixes from a TOML file

Common Flags

Flag Description
--status Filter by status (active, reserved, deprecated, container)
--vrf Filter by VRF name
--tenant Filter by tenant name
--site Filter by site name
--tag Filter by tag slug
--search / -s Free-text search
--limit / -l Max results (default: 50)
--format / -f Output format: table (default), json (writes to file), or csv
--output / -o JSON output file path (prompts with default if omitted)
--verbose / -v Enable debug logging

See the full command reference for all options.

โš™๏ธ Configuration

Set these in .env or as environment variables:

Variable Required Default Description
NETBOX_URL โœ… โ€” NetBox instance URL
NETBOX_TOKEN โœ… โ€” API token (read-only recommended)
NETBOX_PAGE_SIZE โŒ 100 Results per API page
NETBOX_TIMEOUT โŒ 30 Request timeout (seconds)
NETBOX_VERIFY_SSL โŒ true Verify SSL certificates

See docs/configuration.md for details on token setup and SSL options.

๐Ÿ“ฆ Batch Queries

Create a TOML file to query multiple prefixes in one run:

prefixes = [
    "10.0.0.0/8",
    "172.16.0.0/12",
    "192.168.0.0/16",
]

[filters]
# status = "active"
# vrf = "Production"
nbpull batch-prefixes --file prefixes.toml --status-only

๐Ÿ“ Architecture

src/netbox_data_puller/
โ”œโ”€โ”€ cli.py          # Typer commands + filtering + JSON file output
โ”œโ”€โ”€ client.py       # Async GET-only NetBox API client
โ”œโ”€โ”€ config.py       # Pydantic Settings (.env)
โ”œโ”€โ”€ formatters.py   # Rich table renderers
โ””โ”€โ”€ models/         # Pydantic models per resource
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ common.py   # Shared field types / base classes
    โ”œโ”€โ”€ aggregate.py
    โ”œโ”€โ”€ device.py
    โ”œโ”€โ”€ ip_address.py
    โ”œโ”€โ”€ prefix.py
    โ”œโ”€โ”€ site.py
    โ”œโ”€โ”€ tenant.py
    โ”œโ”€โ”€ vlan.py
    โ””โ”€โ”€ vrf.py

See docs/architecture.md for a full breakdown.

๐Ÿ› ๏ธ Development

Prerequisites

  • Python 3.13+
  • uv โ€” fast Python package manager

Setup

git clone https://github.com/Champion2005/nbpull.git
cd nbpull
make install    # Install dependencies

Commands

make all        # format โ†’ lint โ†’ typecheck โ†’ test
make test       # unit tests (no network)
make lint       # ruff linter
make format     # auto-format with ruff
make typecheck  # mypy strict mode
make test-integration  # hits real NetBox API

Running Tests

Unit tests use mocked HTTP responses and require no network access:

make test

Integration tests require NETBOX_URL and NETBOX_TOKEN:

make test-integration

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a PR.

๐Ÿ“ Changelog

See CHANGELOG.md for a history of changes.

๐Ÿ“„ License

This project is licensed under the GNU General Public License v3.0 โ€” see the LICENSE file for details.

๐Ÿ™ Acknowledgements

  • NetBox โ€” the leading open-source IPAM/DCIM platform
  • Typer โ€” CLI framework
  • Rich โ€” beautiful terminal formatting
  • httpx โ€” async HTTP client
  • Pydantic โ€” data validation

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

nbpull-0.3.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbpull-0.3.0-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file nbpull-0.3.0.tar.gz.

File metadata

  • Download URL: nbpull-0.3.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nbpull-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4ed64ebf7437d4be457e43533bb088840948a945133758e9e549fdd1f4cf1e87
MD5 bb821aadc2ea118e847cce15a566163e
BLAKE2b-256 b3211fff3b7748997d258016b163c51493d3816939f72d4579a4cc8dacac56dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbpull-0.3.0.tar.gz:

Publisher: publish.yml on Champion2005/nbpull

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nbpull-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nbpull-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nbpull-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21d017bdeb1641f77d9d71df57cb493b6ee2d75e6c9c82a0b58d0ff86a56bc33
MD5 932606fab7d371696d7d6a6c93f0331c
BLAKE2b-256 9bc3d9d9ebd3865bf1e5d6d5b6d4ff2100cd461617fa5b9bdde930eb6ffbe27e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbpull-0.3.0-py3-none-any.whl:

Publisher: publish.yml on Champion2005/nbpull

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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