You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2025. It is now read-only.
The first argument NetBoxClient takes is the NetBox URL. The 'token' argument is from NetBox, see the [Authentication documentation](https://docs.netbox.dev/en/stable/integrations/rest-api/#authentication) in the NetBox docs for more about creating and using API Tokens.
27
+
28
+
Now using the client you can make calls to the api.
29
+
30
+
### Basic CRUD APIs
31
+
32
+
Each of these objects has the standard CRUD endpoints as follows:
33
+
34
+
```
35
+
# 1. List (paginated)
36
+
ret = nb.dcim.sites.list(limit=3)
37
+
38
+
# 2. Filtered List
39
+
ret = nb.dcim.sites.list(region_id="43")
40
+
41
+
# 3. All
42
+
ret = nb.dcim.sites.all()
43
+
44
+
# 4. Get
45
+
ret = nb.dcim.sites.get(24)
46
+
47
+
# 5. Create
48
+
ret = nb.dcim.sites.create(name="foo3", slug="foo3")
49
+
50
+
# 6. Update
51
+
ret = nb.dcim.sites.update(26, name="foo2-new", slug="foo2-new-slug")
52
+
53
+
# 7. Delete
54
+
ret = nb.dcim.sites.delete(37)
55
+
```
56
+
57
+
### Bulk APIs
58
+
59
+
In addition, bulk operations are available on the API's as well:
In addition to the standard API calls above, devices also have a special API for rendering config context:
83
+
```
84
+
ret = nb.dcim.devices.render_config(107)
85
+
```
86
+
87
+
### Endpoints
88
+
89
+
The methods on the api's correspond to the NetBox REST API - the best reference to the objects that can be called is by using the [browsable API](https://demo.netbox.dev/api/) on the netbox instance. The root objects that can be called are:
90
+
91
+
- circuits
92
+
- core
93
+
- dcim
94
+
- extras
95
+
- ipam
96
+
- plugins
97
+
- status
98
+
- tenancy
99
+
- users
100
+
- virtualization
101
+
- wireless
102
+
103
+
circuits would have 'circuit_terminations', 'circuit_types', etc... off of it. Each of the endpoints has 'list', 'get', 'create', 'update' and 'delete' functions.
104
+
105
+
106
+
## Return Object
107
+
108
+
The return object from the API calls is a dictionary with two values (response and data). **data** is the actual data returned from the call and response contains detailed information on the call, including the HTTP status code returned. Netbox-python is a wrapper around the python [requests](https://github.com/psf/requests) library. Detailed information on the response object can be found in python requests library [documentation](https://requests.readthedocs.io/en/latest/). After making an API call you can check the status code and get the returned data as follows:
0 commit comments