Pular para conteúdo

Integração & API

Info

English (en): This page was not translated yet! Portuguese (pt-br): Essa página não foi traduzida ainda!

NetBox includes a slew of features which enable integration with other tools and resources powering your network.

REST API

NetBox's REST API, powered by the Django REST Framework, provides a robust yet accessible interface for creating, modifying, and deleting objects. Employing HTTP for transfer and JSON for data encapsulation, the REST API is easily consumed by clients on any platform and extremely well suited for automation tasks.

curl -s -X POST \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
http://netbox/api/ipam/prefixes/ \
--data '{"prefix": "192.0.2.0/24", "site": {"name": "Branch 12"}}'

The REST API employs token-based authentication, which maps API clients to user accounts and their assigned permissions. The API endpoints are fully documented using OpenAPI, and NetBox even includes a convenient browser-based version of the API for exploration. The open source pynetbox and go-netbox API client libraries are also available for Python and Go, respectively.

To learn more about this feature, check out the REST API documentation.

GraphQL API

NetBox also provides a GraphQL API to complement its REST API. GraphQL enables complex queries for arbitrary objects and fields, enabling the client to retrieve only the specific data it needs from NetBox. This is a special-purpose read-only API intended for efficient queries. Like the REST API, the GraphQL API employs token-based authentication.

To learn more about this feature, check out the GraphQL API documentation.

Webhooks

A webhook is a mechanism for conveying to some external system a change that took place in NetBox. For example, you may want to notify a monitoring system whenever the status of a device is updated in NetBox. This can be done by creating a webhook for the device model in NetBox and identifying the webhook receiver. When NetBox detects a change to a device, an HTTP request containing the details of the change and who made it be sent to the specified receiver. Webhooks are an excellent mechanism for building event-based automation processes.

To learn more about this feature, check out the webhooks documentation.

NAPALM

NAPALM is a Python library which enables direct interaction with network devices of various platforms. When configured, NetBox supports fetching live operational and status data directly from network devices to be compared to what has been defined in NetBox. This allows for easily validating the device's operational state against its desired state. Additionally, NetBox's REST API can act as a sort of proxy for NAPALM commands, allowing external clients to interact with network devices by sending HTTP requests to the appropriate API endpoint.

To learn more about this feature, check out the NAPALM documentation.

Prometheus Metrics

NetBox includes a special /metrics view which exposes metrics for a Prometheus scraper, powered by the open source django-prometheus library. To learn more about this feature, check out the Prometheus metrics documentation.