Skip to content

Fetching data via API

With vScope’s open REST API, you can export tables as CSV or XLSX files. This is helpful for automating data use in other systems, allowing vScope to handle data gathering and structuring.


Prerequisites

Access the vScope API documentation at:

https://[vscope-server-name]/apidoc

You’ll need:

  • An API token generated for an authorized vScope user (preferably an admin).
  • vScope admin rights to manage API tokens.

Create an API Token

  1. Go to Settings > API Tokens in vScope.
  2. Select a user for the token. To simplify tracking, consider creating a dedicated user for API tokens, e.g., “apiuser.”
  3. Optionally, set an expiry date. If left blank, the token will remain valid for ten years.

The new token will now be visible in the list. To revoke it, click the X next to it.

Using the Token

Add the token to your API requests as a header with the key token.

Example with CURL:

Terminal window
curl -X GET --header 'token: [token]' https://[vscope-server]/[endpoint]

Example to fetch user info and save to a file me.txt:

Terminal window
curl -X GET --header 'token: 6483b55a3083b516' https://vscope/rest/usermanager/me > me.txt

This command retrieves user information associated with the token and saves it to a text file named me.txt. This is useful for verifying that your API token works and that you have the necessary permissions to access vScope data via the API.


Exporting a Table to CSV or XLSX

Using the vScope API, you can export any saved table in vScope to a CSV or XLSX file. Here’s how:

Prepare and Save Your Table

  1. Go to Tables in vScope.
  2. Create a new table, selecting the resource type and adding any relevant columns and filters to match the data you need.
  3. Once configured, Save the table.

Locate the Table ID

After saving the table, obtain its unique ID:

  • Open the Collaborators section in the saved table view.
  • Copy the last part of the permalink displayed; this is the table’s ID.

Export Data Using the API

With the table ID in hand, you can now export data in CSV or XLSX format using the following endpoints.

Exporting as CSV

Replace {tableId} with your actual table ID to export as CSV:

Terminal window
curl -X GET --header 'token: 6483b55a3083b516' 'https://vscope/rest/tables/{tableId}/csv' > table.csv

This will save the table data in a CSV file named table.csv, containing all rows and columns specified in your saved vScope table. If you need this data in a different format or require adjustments to columns, you can return to Tables in vScope to modify the table configuration, then export again.


Exporting Data in XLSX Format

If you prefer to work with Excel files, you can use the same API endpoint to export the table data as an XLSX file by replacing csv with xlsx in the URL:

Terminal window
curl -X GET --header 'token: 6483b55a3083b516' 'https://vscope/rest/tables/{tableId}/xlsx' > table.xlsx

This command will save the table data in an Excel file named table.xlsx. This format is often useful for reports, as it allows for additional formatting, sorting, and analysis directly within Excel or other spreadsheet tools.


Next Steps: Further Automation with vScope’s API

Beyond data exports, you can further automate interactions with vScope by exploring additional endpoints in the API:

Initiate Discovery Scans: Automate scans on a schedule to keep your data fresh and updated without manual intervention. Retrieve Tracker Case Statuses: Regularly export or check open Tracker cases for integration with your ticketing or incident management systems. Update Tags and Metadata: Dynamically manage asset tags and metadata directly through the API for enhanced asset categorization and tracking.