pynetbox


Namepynetbox JSON
Version 7.4.1 PyPI version JSON
download
home_pagehttps://github.com/netbox-community/pynetbox
SummaryNetBox API client library
upload_time2024-10-25 15:59:12
maintainerNone
docs_urlNone
authorZach Moody, Arthur Hanson
requires_pythonNone
licenseApache2
keywords netbox
VCS
bugtrack_url
requirements requests urllib3 packaging
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pynetbox
Python API client library for [NetBox](https://github.com/netbox-community/netbox).

> **Note:** Version 6.7 and later of the library only supports NetBox 3.3 and above.

## Compatibility

Each pyNetBox Version listed below has been tested with its corresponding NetBox Version.

| NetBox Version | Plugin Version |
|:--------------:|:--------------:|
|      4.0.6     |     7.4.1      |
|      4.0.0     |     7.3.4      |
|      3.7       |     7.3.0      |
|      3.6       |     7.2.0      |
|      3.5       |     7.1.0      |
|      3.3       |     7.0.0      |

## Installation

To install run `pip install pynetbox`.

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


## Quick Start

The full pynetbox API is documented on [Read the Docs](http://pynetbox.readthedocs.io/en/latest/), but the following should be enough to get started using it.

To begin, import pynetbox and instantiate the API.

```
import pynetbox
nb = pynetbox.api(
    'http://localhost:8000',
    token='d6f4e314a5b5fefd164995169f28ae32d987704f'
)
```

The first argument the .api() method takes is the NetBox URL. There are a handful of named arguments you can provide, but in most cases none are required to simply pull data. In order to write, the `token` argument should to be provided.


## Queries

The pynetbox API is setup so that NetBox's apps are attributes of the `.api()` object, and in turn those apps have attribute representing each endpoint. Each endpoint has a handful of methods available to carry out actions on the endpoint. For example, in order to query all the objects in the `devices` endpoint you would do the following:

```
>>> devices = nb.dcim.devices.all()
>>> for device in devices:
...     print(device.name)
...
test1-leaf1
test1-leaf2
test1-leaf3
>>>
```

Note that the all() and filter() methods are generators and return an object that can be iterated over only once.  If you are going to be iterating over it repeatedly you need to either call the all() method again, or encapsulate the results in a `list` object like this:
```
>>> devices = list(nb.dcim.devices.all())
```

### Threading

pynetbox supports multithreaded calls for `.filter()` and `.all()` queries. It is **highly recommended** you have `MAX_PAGE_SIZE` in your Netbox install set to anything *except* `0` or `None`. The default value of `1000` is usually a good value to use. To enable threading, add `threading=True` parameter to the `.api`:

```python
nb = pynetbox.api(
    'http://localhost:8000',
    threading=True,
)
```

## Alternative Library

> **Note:** For those interested in a different approach, there is an alternative Python API client library available for NetBox called [netbox-python](https://github.com/netbox-community/netbox-python). This library provides a thin Python wrapper over the NetBox API.

[netbox-python](https://github.com/netbox-community/netbox-python) offers a minimalistic interface to interact with NetBox's API. While it may not provide all the features available in pynetbox, it offers a lightweight and straightforward option for interfacing with NetBox.

To explore further details and access the documentation, please visit the [netbox-python](https://github.com/netbox-community/netbox-python).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/netbox-community/pynetbox",
    "name": "pynetbox",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "netbox",
    "author": "Zach Moody, Arthur Hanson",
    "author_email": "ahanson@netboxlabs.com",
    "download_url": "https://files.pythonhosted.org/packages/1a/f9/e6c524e5ddc4c2788ab2f5ee1ab2d9afad49cad9c7cd3a372cf5b8433ed3/pynetbox-7.4.1.tar.gz",
    "platform": null,
    "description": "# Pynetbox\nPython API client library for [NetBox](https://github.com/netbox-community/netbox).\n\n> **Note:** Version 6.7 and later of the library only supports NetBox 3.3 and above.\n\n## Compatibility\n\nEach pyNetBox Version listed below has been tested with its corresponding NetBox Version.\n\n| NetBox Version | Plugin Version |\n|:--------------:|:--------------:|\n|      4.0.6     |     7.4.1      |\n|      4.0.0     |     7.3.4      |\n|      3.7       |     7.3.0      |\n|      3.6       |     7.2.0      |\n|      3.5       |     7.1.0      |\n|      3.3       |     7.0.0      |\n\n## Installation\n\nTo install run `pip install pynetbox`.\n\nAlternatively, you can clone the repo and run `python setup.py install`.\n\n\n## Quick Start\n\nThe full pynetbox API is documented on [Read the Docs](http://pynetbox.readthedocs.io/en/latest/), but the following should be enough to get started using it.\n\nTo begin, import pynetbox and instantiate the API.\n\n```\nimport pynetbox\nnb = pynetbox.api(\n    'http://localhost:8000',\n    token='d6f4e314a5b5fefd164995169f28ae32d987704f'\n)\n```\n\nThe first argument the .api() method takes is the NetBox URL. There are a handful of named arguments you can provide, but in most cases none are required to simply pull data. In order to write, the `token` argument should to be provided.\n\n\n## Queries\n\nThe pynetbox API is setup so that NetBox's apps are attributes of the `.api()` object, and in turn those apps have attribute representing each endpoint. Each endpoint has a handful of methods available to carry out actions on the endpoint. For example, in order to query all the objects in the `devices` endpoint you would do the following:\n\n```\n>>> devices = nb.dcim.devices.all()\n>>> for device in devices:\n...     print(device.name)\n...\ntest1-leaf1\ntest1-leaf2\ntest1-leaf3\n>>>\n```\n\nNote that the all() and filter() methods are generators and return an object that can be iterated over only once.  If you are going to be iterating over it repeatedly you need to either call the all() method again, or encapsulate the results in a `list` object like this:\n```\n>>> devices = list(nb.dcim.devices.all())\n```\n\n### Threading\n\npynetbox supports multithreaded calls for `.filter()` and `.all()` queries. It is **highly recommended** you have `MAX_PAGE_SIZE` in your Netbox install set to anything *except* `0` or `None`. The default value of `1000` is usually a good value to use. To enable threading, add `threading=True` parameter to the `.api`:\n\n```python\nnb = pynetbox.api(\n    'http://localhost:8000',\n    threading=True,\n)\n```\n\n## Alternative Library\n\n> **Note:** For those interested in a different approach, there is an alternative Python API client library available for NetBox called [netbox-python](https://github.com/netbox-community/netbox-python). This library provides a thin Python wrapper over the NetBox API.\n\n[netbox-python](https://github.com/netbox-community/netbox-python) offers a minimalistic interface to interact with NetBox's API. While it may not provide all the features available in pynetbox, it offers a lightweight and straightforward option for interfacing with NetBox.\n\nTo explore further details and access the documentation, please visit the [netbox-python](https://github.com/netbox-community/netbox-python).\n",
    "bugtrack_url": null,
    "license": "Apache2",
    "summary": "NetBox API client library",
    "version": "7.4.1",
    "project_urls": {
        "Homepage": "https://github.com/netbox-community/pynetbox"
    },
    "split_keywords": [
        "netbox"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f04ffab3934a0dae677e4c23381749ad379c716c6f7fbae5711ebf8fd0cf1bdc",
                "md5": "bd9f65aaa398e5ed528fe6cc4b13ce60",
                "sha256": "f42ce4df6ce97765df91bb4cc0c0e315683d15135265270d78f595114dd20e2b"
            },
            "downloads": -1,
            "filename": "pynetbox-7.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bd9f65aaa398e5ed528fe6cc4b13ce60",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 35075,
            "upload_time": "2024-10-25T15:59:10",
            "upload_time_iso_8601": "2024-10-25T15:59:10.998060Z",
            "url": "https://files.pythonhosted.org/packages/f0/4f/fab3934a0dae677e4c23381749ad379c716c6f7fbae5711ebf8fd0cf1bdc/pynetbox-7.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1af9e6c524e5ddc4c2788ab2f5ee1ab2d9afad49cad9c7cd3a372cf5b8433ed3",
                "md5": "2331d17dd24fa725eb284092b81ae113",
                "sha256": "3f82b5964ca77a608aef6cc2fc48a3961f7667fbbdbb60646655373e3dae00c3"
            },
            "downloads": -1,
            "filename": "pynetbox-7.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2331d17dd24fa725eb284092b81ae113",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 68223,
            "upload_time": "2024-10-25T15:59:12",
            "upload_time_iso_8601": "2024-10-25T15:59:12.421760Z",
            "url": "https://files.pythonhosted.org/packages/1a/f9/e6c524e5ddc4c2788ab2f5ee1ab2d9afad49cad9c7cd3a372cf5b8433ed3/pynetbox-7.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-25 15:59:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "netbox-community",
    "github_project": "pynetbox",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.32.3"
                ],
                [
                    "<",
                    "3.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "<",
                    "3"
                ],
                [
                    ">=",
                    "2.2.3"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": []
        }
    ],
    "lcname": "pynetbox"
}
        
Elapsed time: 0.37823s