The OTbase Inventory API allows you to easily access and retrieve information about all of your hardware products. You can browse through your full catalog or narrow down your search by vendor, model, version, and even hardware type and product lifecycle stage. All of this is made possible through the use of the GET
method and the Portable Inventory Data format. With this resource, you'll have all the information you need to make informed decisions about your hardware choices.
Follow along with our Postman Collection
To access the requests associated with the Hardware endpoint, click on the Hardware product data folder in our Postman collection.
Retrieve the full hardware catalog
Retrieve all hardware products in the hardware product catalog.
API Request
Python
Request:
GET ot-base/api/v1/hardware
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware'
response = requests.get(url, auth=auth)
print(response.status_code)
print(response.text)
Retrieve hardware products of a particular vendor
Retrieve all hardware products of a particular vendor.
Note: The vendor name might need to be quoted if it contains special characters.
API Request
Python
Request:
GET ot-base/api/v1/hardware/?vendor=vendorName
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
# Replace vendorName with a vendor's name between the quotes.
params = {'vendor': 'vendorName'}
response = requests.get(url, params=params, auth=auth)
print(response.status_code)
print(response.text)
A wildcard search is supported by using the special character % in the vendor name.
In the request below, results where the vendor name starts with "Rockwell" will be returned. Therefore, both products with the vendor name "Rockwell Software" and "Rockwell Automation/Allen-Bradley" will be returned in the result set
API Request
Python
Request:
GET ot-base/api/v1/hardware/?vendor=Rockwell%
Response:
"data": [
{
"vendor": "Rockwell Automation/Allen-Bradley",
...
},
{
"vendor": "Rockwell Software, Inc.",
...
},
...
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
# This example shows a vendor name using the wildcard % symbol.
params = {'vendor': 'Rock%'}
response = requests.get(url, params=params, auth=auth)
print(response.status_code)
print(response.text)
Retrieve particular hardware models
Retrieve all versions of a hardware product of a particular vendor.
Note: The model filter can only be used for queries that also specify a vendor filter.
API Request
Python
Request:
GET ot-base/api/v1/hardware/?vendor=vendorName&model=modelName
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
# You can use the model filter with queries that also specify a vendor.
params = {
'vendor': 'vendorName',
'model': 'modelName'
}
response = requests.get(url, params=params, auth=auth)
print(response.status_code)
print(response.text)
Retrieve particular hardware model versions
Retrieve product data for a particular hardware product version.
Note: The version filter can only be used for queries that also specify a vendor and model filter. Also, if the vendor name, model name, and version name/number should be quoted if they contain special characters.
API Request
Python
Request:
GET ot-base/api/v1/hardware/?vendor=vendorName&model=modelName&version=versionNameOrNumber
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
# Retrieves product data for a particular hardware product version using the following params
params = {
'vendor': 'vendorName',
'model': 'modelName',
'version': 'versionNameOrNumber'
}
response = requests.get(url, params=params, auth=auth)
print(response.status_code)
print(response.text)
Retrieve specific types of hardware products
Filtering by hardware type can be done by using the type filter. For example, the following query will output only devices of the PLC type.
API Request
Python
Request:
GET ot-base/api/v1/hardware/?type=plc
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
# Replace enterType with a type that is define in your OTbase Inventory.
params = {'type': 'enterType'}
response = requests.get(url, params=params, auth=auth)
print(response.status_code)
print(response.text)
Type filters can be combined in order to search for multiple types in one query. As an example, the following query retrieves both server and desktop hardware products.
API Request
Python
Request:
GET ot-base/api/v1/hardware/?type=desktop,server
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
# The type paramater can accept multiple types.
params = {'type': 'enterType1,enterType2'}
response = requests.get(url, params=params, auth=auth)
print(response.status_code)
print(response.text)
Retrieve hardware products at a particular location
You can limit the result set to products installed at a particular location by providing the location ID of that location using the parameter locationid.
API Request
Python
Request:
GET ot-base/api/v1/hardware/?locationid=usa
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
params = {'locationid': 'enterLocationID'}
response = requests.get(url, params=params, auth=auth)
print(response.status_code)
print(response.text)
Retrieve hardware products in a particular product lifecycle stage
Filtering by lifecycle stage is accomplished by using the lifecycle filter. It can take the following values active, phaseout, end of life, and discontinued.
In the following example, we search for all Cisco products that either have reached the end of their product life (no new versions coming), or are discontinued (no spares available).
API Request
Python
Request:
GET ot-base/api/v1/hardware/?vendor=cisco&lifecycle=end%20of%20life&lifecycle=discontinued
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/hardware/'
params = {'vendor': 'cisco', 'lifecycle': ['end of life', 'discontinued']}
response = requests.get(url, params=params, auth=('username', 'password'))
print(response.status_code)
print(response.text)
Comments
0 comments
Please sign in to leave a comment.