Example script to export a list of all observed entities in the SolarWinds Observability SaaS platform.
Required pre-reading. documentation.solarwinds.com/.../api-swagger.htm
import requests
import csv
# Set up base URL and API token
API_TOKEN = "YOUR TOKEN HERE"
BASE_URL = "YOUR URL HERE"
HEADERS = {"Authorization": f"Bearer {API_TOKEN}"}
# List of entity types to exclude from the request
excluded_entity_types = [
"ApplicationComponent", "ThinAccessPoint", "DatabaseQueryDigest","IpAddress","PhysicalPort","WirelessInterface","AsaSiteToSiteTunnel",
"DeviceVolume", "ServiceInstance", "Service", "KubernetesPod","NetworkShadowDevice","Vlan","VlanDevice",
"KubernetesJob", "KubernetesContainer", "Container", "NetworkInterface","HardwareSensor","VirtualMachine","KubernetesReplicaSet","KubernetesDeployment","VirtualMachineVolume"
] # Add more types to exclude as needed
# Initialize the list to collect entity data
all_entities = []
# First request to get entity types
response = requests.get(f"{BASE_URL}/metadata/entities/types", headers=HEADERS)
entity_types = response.json().get("types", [])
# Loop through each entity type and make paginated requests
for entity_type in entity_types:
if entity_type in excluded_entity_types:
print(f"Skipping excluded entity type: {entity_type}")
continue
print(f"Processing entity type: {entity_type}")
entity_count = 0
page_url = f"{BASE_URL}/entities?type={entity_type}"
while page_url:
response = requests.get(page_url, headers=HEADERS)
data = response.json()
# Collect entity data
entities = data.get("entities", [])
for entity in entities:
all_entities.append([entity["id"], entity["type"], entity["name"]])
entity_count += 1
# Show progress for each page
print(f"Retrieved {len(entities)} entities for {entity_type} (Total so far: {entity_count})")
# Check for next page URL
page_url = data.get("pageInfo", {}).get("nextUrl")
# Write data to CSV with UTF-8 encoding
with open("entities_data.csv", mode="w", encoding="utf-8", newline="") as csvfile:
writer = csv.writer(csvfile)
writer.writerow(["Entity ID", "Type", "Name"]) # Header row
writer.writerows(all_entities)
print("Data saved to entities_data.csv successfully.")