queryType: getSavedResults*
The getSavedResults queryType is passed to the API to get results for a given saved analysis, and return time series secondary output tables.
This functionality is currently only supported for Origin and Destination, Route Analysis, O/D Segment Analysis, Stop Analytics, and Regional Travel Metrics.
How it works
getSavedResults retrieves the output of a previously run analysis using a two-step pattern:
-
Run an analysis (for example,
getOriginDestinationMatrix) usingcreateQueryJoband poll withgetJobStatusuntil complete. -
Pass the
JobIdfrom that completed analysis as theanalysisJobIdparameter in agetSavedResultscall to retrieve the results.
Results are only retrievable for 24 hours after an analysis completes unless the analysis has been saved in the Altitude application. Use getSavedAnalyses to retrieve the JobId of a previously saved analysis.
Parameters
Pass these parameters to the functionParameters object regardless of which method you use to make an API request.
| Parameter | Description | Type | Defined Value Set | Value Required |
|---|---|---|---|---|
| queryType | Must equal "getSavedResults". | STRING | "getSavedResults" | Y |
| analysisJobId | The JobId of the original analysis whose results you want to retrieve. This is not a new ID, it is the JobId returned in the response of the original analysis job (for example, from getOriginDestinationMatrix), or from the getSavedAnalysesAPI. Results are only retrievable for 24 hours after the analysis completes unless the analysis has been saved. | STRING | - | Y |
| analysisType | Must equal the queryType of the results you are trying to get. | STRING | Any queryType whose results are saved | Y |
The response schema for this API depends on the queryType of the analysis you are retrieving. For example, if you are loading up a saved origin/destination matrix, then the response schema will match that of the getOriginDestinationMatrix API.
This example shows the complete two-step flow for retrieving saved results for a getOriginDestinationMatrix analysis.
Step 1: Find the saved analysis and get its JobId using getSavedAnalyses
{
"queryType": "getSavedAnalyses",
"analysisTypes": ["getOriginDestinationMatrix"],
"statuses": [1]
}
The response includes a JobId for each saved analysis. Copy the JobId of the analysis whose results you want to retrieve.
Step 2: Retrieve the results using getSavedResults
{
"queryType": "getSavedResults",
"analysisJobId": "<JobId from Step 1>",
"analysisType": "getOriginDestinationMatrix"
}
Common mistakes
The most common error is not passing analysisJobId at all. This is a required parameter; the call fails without it.
The second common mistake is passing the wrong job ID. analysisJobId must be the JobId from the original analysis (for example, from getOriginDestinationMatrix), not the jobId that getSavedResults returns for its own tracking.
Responses
| Code | Type | Description |
|---|---|---|
| 200 | JSON | The requested data. |
| 401 | JSON | Occurs for various unauthorized tasks, such as not providing credentials in your parameters. |
| 500 | JSON | Occurs if an internal server error occurs. Contact Altitude Support if this occurs. |