Follow these steps to get familiar with the following:
- REST API
- GraphQL API
-
Scroll down to the footer of the Web UI. On the left hand side there are 5 icons, and a tool tip appears over each one when you hover over it. Click on the one called REST API. This opens a separate browser tab in the root of the REST API.
-
Explore the API from here - e.g click on the
circuits
hyperlink, and then oncircuits
(the full API request is nowGET /api/circuits/circuits/
). This API request will return all the circuits NetBox. -
Continue to explore the REST API and make API calls to retrieve other data from NetBox
-
Return to the main NetBox Web UI and scroll down to the footer. On the left hand side there are 5 icons, and a tool tip appears over each one when you hover over it. Click on the one called REST API Documentation. This opens the Swagger documentation for the REST API in a separate browser tab.
The Swagger docs are where you can experiment with building API calls. Note that there are sections for each area of the NetBox data model eg.
circuits
,dcim
,wireless
etc. -
Make an API call to retrieve a list of devices in the
Amsterdam
site. Under theDCIM
section find theGET /api/dcim/devices/
API call. Click to open it, and then click Try it out on the right hand side -
To filter on only the
amsterdam
site, scroll down and find thesite
parameter, clickAdd string item
and enter the site slug ofamsterdam
(lowercase) -
Scroll further down and click on Execute and then scroll down to the Responses section. Note the full
curl
request andRequest URL
and then scroll down to the Response Body to view the data that has been returned from NetBox.
- In the main NetBox Web UI, scroll down to the footer on the left hand side there are 5 icons, and a tool tip appears over each one when you hover over it. Click on the one called GraphQL API. This opens a separate browser tab in which you can use the GraphiQL utility to build API calls.
- Try this out by building a query to retrieve all the devices in the Amsterdam site (
site id: 1
), along with theirID
,name
andplatform
. If there is an example query already, delete it and replace it with the following:
query GetDevicesAtSite {
site(id: 1) {
devices {
id
name
platform {
name
}
}
}
}
- Click on the Play button, and then review the device data returned in the panel on the right-hand side.
- Try running this query to return the
name
andlocation
of the rack at the Amsterdam site
query GetRacksAtSite {
site(id: 1) {
racks {
name
location {
name
}
}
}
}