Skip to content
Last updated

Example: Gather Data from Saved Report Configuration

Often, you may want to run the same report repeatedly but don’t want to maintain the full configuration in your code. By pulling the saved configuration from ObservePoint, you can keep your scripts lean, minimize maintenance, and ensure consistency with what’s defined in the UI.

This is especially useful when:

  • You have multiple reports managed by different teams.
  • You want to automate report execution without hardcoding parameters.
  • You want to ensure your automation stays in sync with changes made in the ObservePoint interface.

This example shows how to use the Grid API to:

  1. Retrieve the configuration of a saved report in ObservePoint using its report ID.
  2. Execute that report dynamically by sending the retrieved configuration (queryDefinition) to the correct Grid API endpoint.

This approach removes the need to hardcode configurations in your scripts. Instead, you can manage configurations directly in ObservePoint and collect data from those reports programmatically.

For reference:


Step 1: Get the Desired Report ID

To retrieve a specific report configuration, you first need its report ID.

Navigate to the desired report in ObservePoint.
In the browser URL, you will see something like:

Example Report URL
https://app.observepoint.com/reports/12345

The digits at the end (12345) are the report ID.


Step 2: Retrieve Saved Report Configuration

Make a GET request to retrieve the saved report:

Request to Retrieve Saved Report
GET https://api.observepoint.com/v3/reports/grid/saved/12345
Example Saved Report Response
{
  "id": 12345,
  "name": "Top Pages by Load Time",
  "gridEntityType": "web_audit_runs",
  "queryDefinition": {
    "columns": [...],
    "filters": {...},
    "sortBy": [...],
    "page": 0,
    "size": 100
  }
}

Step 3: Identify the Correct Grid API Endpoint

Take the gridEntityType value from the response (e.g., "web_audit_runs") and use it to determine the final segment of the Grid API URL. Note that the actual endpoint uses hyphens instead of underscores (e.g., web-audit-runs). You can also reference the Grid API Entities table to confirm the correct format for the endpoint. For the example "web_audit_runs", the endpoint is:

Example Grid API Endpoint
POST https://api.observepoint.com/v3/reports/grid/web-audit-runs

Step 4: Collect the Report Data

You have two options for retrieving data from the saved report configuration.

Option 1: Use the Grid API and Paginate to Collect All Data

Make a POST request to the matching endpoint, using the queryDefinition from the saved report response as the request body. You will need to paginate to retrieve all rows by incrementing the page parameter until no additional data is returned. See Grid API Pagination for details.

Request to Execute Saved Report
curl -X POST "https://api.observepoint.com/v3/reports/grid/web-audit-runs" \
  -H "Authorization: api_key API_TOKEN" \
  -H "Content-Type: application/json" \
  --data-raw '{
    "size": 100,
    "page": 0,
    "filters": { ... },
    "columns": [ ... ],
    "sortBy": [ ... ]
  }'

This will return data in JSON format, where each row corresponds to a record in the report.

Option 2: Export the Report Data as a File

To retrieve the saved report data as a downloadable file, use the export process described in Grid API Exports.

This method lets you export the saved report in a single call and retrieve the results as a file in one of the supported formats:

  • TSV (Tab-separated values)
  • CSV (Comma-separated values)
  • XLSX (Excel)
  • Parquet (Apache Parquet)

Include the queryDefinition from the saved report response as the request body, and add a fileFormat attribute to specify your desired output format (e.g., "csv", "tsv", "xlsx", or "parquet").

Refer to the Grid API Exports documentation for detailed request examples and additional support.