mcpField
N
netbox-integration-best-practices

netbox-integration-best-practices

github.com/netboxlabsDevelopment31171 installsUpdated 38w ago
Repository

About netbox-integration-best-practices

NetBox Integration Best Practices Skill guides developers building integrations and automations with NetBox REST and GraphQL APIs. It covers authentication, pagination, performance, data ingestion, and branching workflows, but not plugin development or NetBox administration.

Key features

  1. 01Guidance for REST API integrations
  2. 02GraphQL query and pagination practices
  3. 03Token authentication and security advice
  4. 04Performance and filtering recommendations
  5. 05Diode data-ingestion patterns
  6. 06Branching plugin lifecycle guidance

Use cases

  1. 01Plan NetBox API automation
  2. 02Review existing integration code
  3. 03Troubleshoot API performance
  4. 04Design NetBox data-ingestion workflows

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/netboxlabs/netbox-best-practices --skill netbox-integration-best-practices

After installing, type/netbox-integration-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
netbox-integration-guidelines.md
references/rules/
_sections.md
_template.md
auth-provisioning-endpoint.md
auth-use-v2-tokens.md
data-custom-fields.md
data-dependency-order.md
data-ipam-hierarchy.md
data-natural-keys.md
data-site-hierarchy.md
data-tags-usage.md
data-tenant-isolation.md
graphql-always-paginate.md
graphql-avoid-nested-filters.md
graphql-calibrate-optimizer.md
graphql-complexity-budgets.md
graphql-filter-by-id.md
graphql-max-depth.md
graphql-pagination-at-each-level.md
graphql-prefer-filters.md
graphql-select-only-needed.md
graphql-use-query-optimizer.md
graphql-vs-rest-decision.md
integ-branch-api-workflow.md
integ-branch-async-operations.md
integ-branch-context-header.md
integ-change-tracking.md
integ-diode-ingestion.md
integ-pynetbox-client.md
integ-webhook-configuration.md

Details

From the project README

NetBox Integration Best Practices Skill

This skill provides best practices guidance for building integrations and automations with NetBox REST and GraphQL APIs.

Target Audience

  • Engineers building integrations atop NetBox APIs
  • Teams planning new automations with Claude
  • Developers learning NetBox API best practices

Scope: This skill covers API integration patterns. It does NOT cover plugin development, custom scripts, or NetBox administration.

NetBox Version Requirements

FeatureVersion Required
REST APIAll versions
GraphQL API2.9+
v2 Tokens4.5+ (use these!)
v1 Token Deprecation4.7+ (migrate before this)

Primary target: NetBox 4.4+ with 4.5+ for v2 token features.

When to Apply This Skill

Apply these practices when:

  • Building new NetBox API integrations
  • Reviewing existing integration code
  • Troubleshooting performance issues
  • Planning automation architecture
  • Writing scripts that interact with NetBox

Priority Levels

LevelDescriptionAction
CRITICALSecurity vulnerabilities, data loss, severe performanceMust fix immediately
HIGHSignificant performance/reliability impactShould fix soon
MEDIUMNotable improvements, best practicesPlan to address
LOWMinor improvements, optionalConsider when convenient

Quick Reference

Authentication
  • Use v2 tokens on NetBox 4.5+: Bearer nbt_<key>.<token>
  • Migrate from v1 before NetBox 4.7 (deprecation planned)
REST API
  • Always paginate: ?limit=100 (max 1000)
  • Use PATCH for partial updates, not PUT
  • Use ?brief=True for list operations
  • Exclude config_context: ?exclude=config_context (major performance impact)
  • Avoid ?q= search filter at scale; use specific filters
  • Bulk operations use list endpoints with JSON arrays (not separate endpoints)
GraphQL
  • Use the query optimizer: netbox-graphql-query-optimizer
  • Always paginate every list query
  • Paginate at every level of nesting
  • Beware offset pagination at scale: Deep offsets are slow; use ID range filtering in 4.5.x, cursor-based in 4.6.0+ (#21110)
  • Request only needed fields
  • Keep depth ≤3, never exceed 5
Performance
  • Exclude config_context from device lists
  • Use brief mode for large lists
  • Parallelize independent requests
Data Ingestion (Diode)
  • For high-volume data ingestion, use Diode instead of direct API
  • Specify dependencies by name, not ID—Diode resolves or creates them
  • No dependency order needed—Diode handles object creation order
  • Use pip install netboxlabs-diode-sdk for Python
  • Use REST/GraphQL API for reading; use Diode for writing/populating
Branching (Plugin)

Requires netbox-branching plugin.

  • Lifecycle: Create → Wait (PROVISIONING→READY) → Work → Sync → Merge
  • Context header: X-NetBox-Branch: {schema_id} (8-char ID, not name)
  • Async operations: sync/merge/revert return Job objects—poll for completion
  • Dry-run: All async ops accept {"commit": false} for validation

Rules by Category

Authentication Rules
RuleImpactDescription
auth-use-v2-tokensCRITICALUse v2 tokens on NetBox 4.5+
auth-provisioning-endpointMEDIUMUse provisioning endpoint for automated token creation
REST API Rules
RuleImpactDescription
rest-list-endpoint-bulk-opsCRITICALUse list endpoints for bulk operations
rest-pagination-requiredHIGHAlways paginate list requests
rest-patch-vs-putHIGHUse PATCH for partial updates
rest-brief-modeHIGHUse ?brief=True for lists
rest-field-selectionHIGHUse ?fields= to select fields
rest-exclude-config-contextHIGHExclude config_context from device lists
rest-avoid-search-filter-at-scaleHIGHAvoid q= with large datasets
rest-filtering-expressionsMEDIUMUse lookup expressions
rest-custom-field-filtersMEDIUMFilter by custom fields
rest-nested-serializersLOWUnderstand nested serializers
rest-ordering-resultsLOWUse ordering parameter
rest-options-discoveryLOWUse OPTIONS for discovery
GraphQL Rules
RuleImpactDescription
graphql-use-query-optimizerCRITICALUse query optimizer
graphql-always-paginateCRITICALPaginate every list query
graphql-pagination-at-each-levelHIGHPaginate nested lists
graphql-select-only-neededHIGHRequest only needed fields
graphql-calibrate-optimizerHIGHCalibrate against production
graphql-max-depthHIGHKeep depth ≤3
graphql-prefer-filtersMEDIUMFilter server-side
graphql-vs-rest-decisionMEDIUMChoose appropriate API
graphql-complexity-budgetsLOWEstablish complexity budgets
Performance Rules
RuleImpactDescription
perf-exclude-config-contextHIGHExclude config_context
perf-brief-mode-listsHIGHUse brief mode for lists
Data Modeling Rules
RuleImpactDescription
data-dependency-orderCRITICALCreate objects in dependency order
data-site-hierarchyMEDIUMUnderstand site hierarchy
data-ipam-hierarchyMEDIUMUnderstand IPAM hierarchy
data-custom-fieldsMEDIUMUse custom fields properly
data-tags-usageMEDIUMUse tags for classification
data-tenant-isolationMEDIUMUse tenants for separation
data-natural-keysMEDIUMUse natural keys
Integration Rules
RuleImpactDescription
integ-diode-ingestionHIGHUse Diode for high-volume data ingestion
integ-pynetbox-clientHIGHUse pynetbox for Python
integ-branch-api-workflowHIGHComplete branching lifecycle (plugin)
integ-branch-context-headerHIGHBranch context with X-NetBox-Branch header (plugin)
integ-branch-async-operationsMEDIUMJob polling for sync/merge/revert (plugin)
integ-webhook-configurationMEDIUMConfigure webhooks
integ-change-trackingLOWQuery object changes

External References

Official Documentation
Essential Tools
Community

Reference Documentation

DocumentPurpose
HUMAN.mdHuman-readable guide for engineers
netbox-integration-guidelines.mdComprehensive technical reference

Comments

Markdown supported