cyber witchery lab

nautobot.rs: the netbox.rs companion for nautobot

interact with nautobot in your code and cli
cargo add nautobot

links: repo docs crates.io

in the same vein as netbox.rs, i’m releasing its sibling: nautobot.rs, a rust client for nautobot.

for those unfamiliar: nautobot is a fork of netbox maintained by network to code. it diverged to add features like jobs, git integration, and a plugin ecosystem that differs from netbox’s. many organizations run one or the other (or both), so tooling for both is essential.

structure

like netbox.rs, the project provides three crates:

quick start

from rust:

use nautobot::{Client, ClientConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::new("https://nautobot.example.com", "your-api-token");
    let client = Client::new(config)?;

    let devices = client.dcim().devices().list(None).await?;
    for device in devices.results {
        println!("device: {} (id: {})", device.display, device.id);
    }

    Ok(())
}

in the cli:

# list devices
nautobot-cli --url https://nautobot.example.com --token $TOKEN dcim devices list

# or use environment variables
export NAUTOBOT_URL=https://nautobot.example.com
export NAUTOBOT_TOKEN=your-token
nautobot-cli dcim devices list

nautobot-specific features

nautobot has a few capabilities that netbox does not have (and vice versa!), and nautobot.rs provides typed helpers for them:

// trace an interface's connection path
let path = client.dcim().interfaces().trace(interface_id).await?;

// find available IPs in a prefix
let available = client.ipam().prefixes().available_ips(prefix_id).await?;

// execute a job with typed input
let result = client.extras().jobs().run(job_id, &job_input).await?;

what’s next

both clients will continue to evolve as i build out alembic. having consistent, ergonomic rust interfaces to both netbox and nautobot is foundational for that work.