Extract Device List via Spectrum REST API in XML or CSV Format
search cancel

Extract Device List via Spectrum REST API in XML or CSV Format

book

Article ID: 435963

calendar_today

Updated On:

Products

Network Observability

Issue/Introduction

need to extract a comprehensive list of all devices from DX NetOps Spectrum using the REST API for automation or reporting purposes

Environment

Spectrum 25.4.x

Cause

The DX NetOps Spectrum REST API natively returns data in XML format and implements a default 1,000-record throttle to protect system performance

Resolution

 

  • CONSTRUCT REST API GET QUERY:

    Use the HTTP GET method to pull specific attributes for all devices.

    URL Format: http://[hostname]:[port]/spectrum/restful/devices?attr=[attr_id]&attr=[attr_id]

    Commonly Used Attribute IDs:

    • System Name: 0x133f4

    • Contact Person: 0x23000c

    • Location: 0x23000d

    • Device Type: 0x23000e

    EXPECTED: The API returns an XML response containing the requested device attributes.

  • HANDLE LARGE DATASETS (PAGINATION): Adjust the throttle parameter if you have more than 1,000 devices.

    Action: Append &throttle=5000 to the URL to increase the limit.

    EXPECTED: The API returns up to the specified number of records in a single response.

  • AUTOMATE AUTHENTICATION: Use Basic Authentication headers to bypass manual login prompts in browsers.

    Method A (cURL with credentials): curl -vu [username]:[password] -X GET "http://[hostname]:[port]/spectrum/restful/devices?attr=0x1006e&attr=0x12d7f" -H "Accept: application/xml"

    Method B (Base64 Header): Generate a Base64 hash of "[username]:[password]" and use it in the header: curl -H "Authorization: Basic [base64-hash]" -X GET "http://[hostname]:[port]/spectrum/restful/devices..."

    EXPECTED: Data is retrieved without an interactive login prompt.

  • CONVERT XML TO CSV: Use external tools to format the XML output into CSV.

    PowerShell Example: Use Invoke-RestMethod to capture XML data and Export-Csv to save it.

    Excel Method: Use Data > Get Data > From File > From XML to import the API response and save as CSV.