# 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: - [Get Saved Report by ID](/openapi/grid-api.openapi/other/getsavedreportbyid) - [Grid API Entities](/sections/grid-api-entities) # 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: ```text 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: ```text Request to Retrieve Saved Report GET https://api.observepoint.com/v3/reports/grid/saved/12345 ``` ```json 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](/sections/grid-api-entities#grid-api-entities) table to confirm the correct format for the endpoint. For the example `"web_audit_runs"`, the endpoint is: ```text Example Grid API Endpoint POST https://api.observepoint.com/v3/reports/grid/web-audit-runs ``` # Step 4: Collect the Report Data Make a `POST` request to the matching endpoint, using the `queryDefinition` from the saved report response as the request body. ```json Request to Execute Saved Report POST https://api.observepoint.com/v3/reports/grid/web-audit-runs Content-Type: application/json { "size": 10, "page": 0, "filters": {...}, "columns": [ {...} ], "sortBy": [ {...} ] } ``` # Example Response JSON The response format will match the documented response for that entity type, for example: ```json Example Grid API Response { "metadata": { "pagination": { "totalCount": 500, "totalPageCount": 5, "pageSize": 100, "currentPageSize": 100, "currentPageNumber": 0 } }, "rows": [ ["https://example.com/page1", 1234, 2.5], ["https://example.com/page2", 4567, 2.3] // more rows... ] } ```