Pcornel
Automation · NetBox

REST API

Cheat sheet · https://pcornel.dk/topic.php?topic=5885

Back to the Topic

Answer

The NetBox REST API at /api/ exposes every object for create, read, update and delete with token authentication, filtering and pagination; pynetbox wraps it for Python.

Remember

  • REST API at /api/ with token authentication.
  • Supports filtering and pagination.
  • pynetbox wraps it for Python.

First checks

  • curl -s -H 'Authorization: Token <t>' 'https://<netbox>/api/dcim/devices/?limit=100&offset=0' — paginated REST
  • python3 -c "import pynetbox;nb=pynetbox.api('https://<netbox>',token='<t>');print(nb.status())" — pynetbox
  • GraphQL endpoint (/graphql/) — flexible queries

Commands

GET <resource-uri>
Read current REST API state for a bounded verification step.

Verify in this order

client → token → REST/GraphQL → objects

Where it usually breaks

Client payload/auth → HTTP transport → endpoint validation/policy → request accepted → queued/job execution → target mutation → effective state → consumer workload.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5885

Confirmation

Confirm action

Continue?