Skip to main content

Nautobot API client library

Project description



Python API client library for Nautobot.

Pynautobot was initially developed as a fork of pynetbox. Pynetbox was originally developed by Zach Moody at DigitalOcean and the NetBox Community.

The complete documentation for pynautobot can be found at Read the Docs.

Questions? Comments? Join us in the #nautobot Slack channel on Network to Code!


You can install via pip or poetry

Using pip

$ pip install pynautobot

Using poetry

$ git clone
$ pip install poetry
$ poetry shell
Virtual environment already activated: /home/user/pynautobot/.venv
$ poetry install

Quick Start

A short introduction is provided here; the full documention for pynautobot is at Read the Docs.

To begin, import pynautobot and instantiate an Api object, passing the url and token.

import pynautobot
nautobot = pynautobot.api(

The Api object provides access to the Apps in Nautobot. The Apps provide access to the Models and the field data stored in Nautobot. Pynautobot uses the Endpoint class to represent Models. For example, here is how to access Devices stored in Nautobot:

devices = nautobot.dcim.devices
<pynautobot.core.endpoint.Endpoint object at 0x7fe801e62fa0>


Pynautobot provides a specialized Endpoint class to represent the Jobs model. This class is called JobsEndpoint. This extends the Endpoint class by adding the run method so pynautobot can be used to call/execute a job run.

  1. Run from a instance of a job.
>>> gc_backup_job =[14]
>>> job_result =
'1838f8bd-440f-434e-9f29-82b46549a31d' # <-- Job Result ID.
  1. Run with Job Inputs
job =[7]{"hostname_regex": ".*"})
  1. Run by providing the job id
>>> gc_backup_job =[14].id)
'548832dc-e586-4c65-a7c1-a4e799398a3b' # <-- Job Result ID.


Pynautobot provides several ways to retrieve objects from Nautobot. Only the get() method is show here. To continue from the example above, the Endpoint object returned will be used to get the device named hq-access-01.

switch = devices.get(nam="hq-access-01")

The object returned from the get() method is an implementation of the Record class. This object provides access to the field data from Nautobot.


Pynautobot supports multithreaded calls for .filter() and .all() queries. It is highly recommended you have MAX_PAGE_SIZE in your Nautobot 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 when instantiating the Api object:

nautobot = pynautobot.api(


Used for Nautobot Rest API versioning. Versioning can be controlled globally by setting api_version on initialization of the API class and/or for a specific request e.g (list(), get(), create() etc.) by setting an optional api_version parameter.

Global versioning

import pynautobot
nautobot = pynautobot.api(

Request specific versioning

import pynautobot
nautobot = pynautobot.api(
  url="http://localhost:8000", token="d6f4e314a5b5fefd164995169f28ae32d987704f",
tags = nautobot.extras.tags
tags.create(name="Tag", slug="tag", api_version="1.2",)

Retry logic

By default, the client will not retry any operation. This behavior can be adjusted via the retries optional parameters. This will only affect for HTTP codes: 429, 500, 502, 503 and 504.


import pynautobot
nautobot = pynautobot.api(

Related projects

Please see our wiki for a list of relevant community projects.

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

pynautobot-1.4.0.tar.gz (26.5 kB view hashes)

Uploaded source

Built Distribution

pynautobot-1.4.0-py3-none-any.whl (32.8 kB view hashes)

Uploaded py3

Supported by

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