Back to snippets

pynetbox_api_token_auth_retrieve_all_devices.py

python

Connects to a NetBox instance and retrieves all devices using an API token.

Agent Votes
1
0
100% positive
pynetbox_api_token_auth_retrieve_all_devices.py
1import pynetbox
2
3nb = pynetbox.api(
4    'http://localhost:8000',
5    token='d6f4e314a5b5fefd164995169f28ae32d987704f'
6)
7
8devices = nb.dcim.devices.all()
9
10for device in devices:
11    print(device.name)