Loading...
Loading...
Best practices for building integrations with NetBox REST and GraphQL APIs. Use when building NetBox API integrations, reviewing integration code, troubleshooting NetBox performance issues, planning automation architecture, writing scripts that interact with NetBox, using pynetbox, configuring Diode for data ingestion, or implementing NetBox webhooks.
npx skill4agent add netboxlabs/netbox-best-practices netbox-integration-best-practices| Feature | Version Required |
|---|---|
| REST API | All versions |
| GraphQL API | 2.9+ |
| v2 Tokens | 4.5+ (use these!) |
| v1 Token Deprecation | 4.7+ (migrate before this) |
| Level | Description | Action |
|---|---|---|
| CRITICAL | Security vulnerabilities, data loss, severe performance | Must fix immediately |
| HIGH | Significant performance/reliability impact | Should fix soon |
| MEDIUM | Notable improvements, best practices | Plan to address |
| LOW | Minor improvements, optional | Consider when convenient |
Bearer nbt_<key>.<token>?limit=100?exclude=config_contextpip install netboxlabs-diode-sdkRequires netbox-branching plugin.
X-NetBox-Branch: {schema_id}{"commit": false}| Rule | Impact | Description |
|---|---|---|
| auth-use-v2-tokens | CRITICAL | Use v2 tokens on NetBox 4.5+ |
| auth-provisioning-endpoint | MEDIUM | Use provisioning endpoint for automated token creation |
| Rule | Impact | Description |
|---|---|---|
| rest-list-endpoint-bulk-ops | CRITICAL | Use list endpoints for bulk operations |
| rest-pagination-required | HIGH | Always paginate list requests |
| rest-patch-vs-put | HIGH | Use PATCH for partial updates |
| rest-brief-mode | HIGH | Use ?brief=True for lists |
| rest-field-selection | HIGH | Use ?fields= to select fields |
| rest-exclude-config-context | HIGH | Exclude config_context from device lists |
| rest-avoid-search-filter-at-scale | HIGH | Avoid q= with large datasets |
| rest-filtering-expressions | MEDIUM | Use lookup expressions |
| rest-custom-field-filters | MEDIUM | Filter by custom fields |
| rest-nested-serializers | LOW | Understand nested serializers |
| rest-ordering-results | LOW | Use ordering parameter |
| rest-options-discovery | LOW | Use OPTIONS for discovery |
| Rule | Impact | Description |
|---|---|---|
| graphql-use-query-optimizer | CRITICAL | Use query optimizer |
| graphql-always-paginate | CRITICAL | Paginate every list query |
| graphql-pagination-at-each-level | HIGH | Paginate nested lists |
| graphql-select-only-needed | HIGH | Request only needed fields |
| graphql-calibrate-optimizer | HIGH | Calibrate against production |
| graphql-max-depth | HIGH | Keep depth ≤3 |
| graphql-prefer-filters | MEDIUM | Filter server-side |
| graphql-vs-rest-decision | MEDIUM | Choose appropriate API |
| graphql-complexity-budgets | LOW | Establish complexity budgets |
| Rule | Impact | Description |
|---|---|---|
| perf-exclude-config-context | HIGH | Exclude config_context |
| perf-brief-mode-lists | HIGH | Use brief mode for lists |
| Rule | Impact | Description |
|---|---|---|
| data-dependency-order | CRITICAL | Create objects in dependency order |
| data-site-hierarchy | MEDIUM | Understand site hierarchy |
| data-ipam-hierarchy | MEDIUM | Understand IPAM hierarchy |
| data-custom-fields | MEDIUM | Use custom fields properly |
| data-tags-usage | MEDIUM | Use tags for classification |
| data-tenant-isolation | MEDIUM | Use tenants for separation |
| data-natural-keys | MEDIUM | Use natural keys |
| Rule | Impact | Description |
|---|---|---|
| integ-diode-ingestion | HIGH | Use Diode for high-volume data ingestion |
| integ-pynetbox-client | HIGH | Use pynetbox for Python |
| integ-branch-api-workflow | HIGH | Complete branching lifecycle (plugin) |
| integ-branch-context-header | HIGH | Branch context with X-NetBox-Branch header (plugin) |
| integ-branch-async-operations | MEDIUM | Job polling for sync/merge/revert (plugin) |
| integ-webhook-configuration | MEDIUM | Configure webhooks |
| integ-change-tracking | LOW | Query object changes |
| Document | Purpose |
|---|---|
| HUMAN.md | Human-readable guide for engineers |
| netbox-integration-guidelines.md | Comprehensive technical reference |