Python API Example

Example: The following example show on how to read retrieve data where equipment type is 'CHASIS'

Step 1: Import required library (CaaSClient)

from cfxdx.dataapi import CaaSClient

Step 2: Credentials to connect to the system.

Use API keys to connect to the system

credentials = {   "login-method": "access-key",   "host": "hostname or ipaddress",   "access-key": "value for API-access-key",   "secret-key": "value for API-secret-key"}

Step 3: Create CaaSClient object

client = CaaSClient(credentials, page_size=500)

Step 4: Connect to inventory API and execute (alternative API )

inv = client.assetInventory()

Step 5: Get the number of rows in inventory table

Step 6: Get number of modules in inventory

count = inv.count(cfxql_query="Equipment_Type is 'MODULE'")

Step 7: Using Inventory API get all CHASSIS (return value is a pandas DataFrame object)

df = inv.get_data(cfxql_query="Equipment_Type is 'CHASSIS'", max_rows=1000)

Now you can query the dataframe df using normal Pandas functions.

Last updated