Skip to main content

NetBox Python

Python API client library for NetBox.

Note: This is a preliminary release and still under development.

Release Build status Commit activity License

Project license

Pull Requests welcome code with love by netbox-community

Table of Contents

About

This is a thin python wrapper over the NetBox API.

Getting Started

To install run pip install netbox-python.

Alternatively, you can clone the repo and run python setup.py install.

Usage

The full documentation is at https://netbox-community.github.io/netbox-python/, but the following should be enough to get started using it.

To begin, import the NetBox client and instantiate it:

from netbox_python import NetBoxClient, Result
nb = NetBoxClient(
    base_url="http://127.0.0.1:8000/", token="1dc6fa5bfcef8390dd83a261c36ed8f1551b2d6b"
)

The first argument NetBoxClient takes is the NetBox URL. The 'token' argument is from NetBox.

Now using the client you can make calls to the api, for example:

# 1. List (paginated)
ret = nb.dcim.sites.list(limit=3)

# 2. Filtered List
ret = nb.dcim.sites.list(region_id="43")

# 3. All
ret = nb.dcim.sites.all()

# 4. Get
ret = nb.dcim.sites.get(24)

# 5. Create
ret = nb.dcim.sites.create(name="foo3", slug="foo3")

# 6. Bulk Create
data = [
    {"name": "foo4", "slug": "foo4"},
    {"name": "foo5", "slug": "foo5"},
    {"name": "foo6", "slug": "foo6"},
]
ret = nb.dcim.sites.create(data)

# 7. Update
ret = nb.dcim.sites.update(26, name="foo2-new", slug="foo2-new-slug")

# 8. Bulk Update
data = [
    {"id": 28, "name": "foo4-new", "slug": "foo4-new"},
    {"id": 29, "name": "foo5-new", "slug": "foo5-new"},
]
ret = nb.dcim.sites.update(data)

# 9. Delete
ret = nb.dcim.sites.delete(37)

# 10. Bulk Delete
data = [{"id": 25}, {"id": 27}]
ret = nb.dcim.sites.delete(data)

The methods on the api's correspond to the NetBox REST API, so ('circuits', 'core', 'dcim', 'extras', 'ipam', 'plugins', 'tenancy', 'users', 'virtualization', 'wireless')

circuits would have 'circuit_terminations', 'circuit_types', etc... off of it. Each of the endpoints has 'list', 'get', 'create', 'update' and 'delete' functions.

Roadmap

See the open issues for a list of proposed features (and known issues).

Support

Reach out to the maintainer at one of the following places:

Contributing

First off, thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Please read our contribution guidelines, and thank you for being involved!

Authors & contributors

The original setup of this repository is by Arthur Hanson.

For a full list of all authors and contributors, see the contributors page.

License

This project is licensed under the Apache Software License 2.0.

See LICENSE for more information.

Metadata

Release files for netbox-python 0.1.8

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

Source distribution (sdist)

Source distribution for netbox-python 0.1.8
File Size Uploaded
netbox_python-0.1.8.tar.gz 54.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for netbox-python 0.1.8
File Interpreter ABI Platform
netbox_python-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 71.8 kB

Release files / netbox_python-0.1.8.tar.gz

Download URL netbox_python-0.1.8.tar.gz
Size 54.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bf77520e8e6a830178e7c97a799775f369e736f9091b556b1bcfd3eb35bc000e
BLAKE2b-256 checksum
How to use checksums
de0bdc0733d3c79cc4364d71cc1e1e2ef2c11e45822dc950f2e609b687450e72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / netbox_python-0.1.8-py3-none-any.whl

Download URL netbox_python-0.1.8-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b40cbc2cf0e323303d068cc23c064730fd17706c3cfc4b9a6aaf590060f8c05
BLAKE2b-256 checksum
How to use checksums
8623ef59b45d9cd107564eedcc40d57ee7d7b406ed2d4140fb5a8da5b83ec8c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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