Generate Historical Data Archive
Purpose
The Generate Historical Data Archive endpoint allows you to create an archive generation task for selected junctions within a specified date range.
Request data
You can generate an archive by sending a POST request.
HTTPS method: POST
https://api.tomtom.com/junction-analytics/junctions/1/archive/data/tasks/generate?key={Your_API_Key}POST request body example
{ "junctionIds": ["65268ff77cd5d952a185b9b5", "65268ff77cd5d952a185b9b6"], "startDay": "2024-08-01", "endDay": "2025-08-01"}Request parameters
The following table shows the query parameters:
- Required parameters must be used or the call will fail.
- Optional parameters may be used.
| Required parameters | Description |
|---|---|
| An API Key valid for the requested service. Value: Your valid API Key. |
Post request body fields
| Field | Type | Description |
|---|---|---|
junctionIds | array | List of junction IDs for which the archive generation task is created. |
startDay | date | Start date of the archive generation task in the format YYYY-MM-DD. This is the first day for which the archive will be generated. |
endDay | date | End date of the archive generation task in the format YYYY-MM-DD. This is the last day for which the archive will be generated. |
Request headers
| Header | Value |
|---|---|
| Content-Type | application/json |
Example request
The following is an example curl request to generate an archive for specific junction IDs and date range:
$ curl 'https://api.tomtom.com/junction-analytics/junctions/1/archive/data/tasks/generate?key={Your_API_Key}' -i -H 'Content-Type: application/json' -X POST -d '{ "junctionIds": ["65268ff77cd5d952a185b9b5", "65268ff77cd5d952a185b9b6"], "startDay": "2024-08-01", "endDay": "2025-08-01"}'Response data
This response returns the ID of the archive generation task.
The response status tells you whether a task was created:
- 202 Accepted - the archive generation was triggered for at least one of the requested junctions. The body contains the task
idand lists the junctions that were and were not triggered. - 422 Unprocessable Entity - none of the requested junctions could be triggered. No task is created,
idisnullandisSuccessisfalse. The body has the same shape as for 202 and lists the reason for every junction.
Response body example
{ "id": "65268ff77cd5d952a185b9b7", "isSuccess": true, "triggeredJunctions": ["65268ff77cd5d952a185b9b5"], "notTriggeredJunctions": { "NO_ARRIVAL_POINTS": ["65268ff77cd5d952a185b9b6"] }}Response fields
The following section describes all of the fields that can appear in a response.
id (string) - Unique identifier for the archive generation task. This ID can be used to check the status of the task later. null when no junction was triggered (422).
isSuccess (boolean) - true when the archive generation was triggered for at least one junction (202), even if other junctions were not triggered. false when no junction was triggered (422).
triggeredJunctions (array) - List of junction IDs for which the archive generation task was successfully triggered.
notTriggeredJunctions (object) - Contains junction IDs that were not triggered, along with the reason for failure. The keys represent the failure reasons, and the values are arrays of junction IDs. Possible keys:
JUNCTION_NOT_FOUND- the junction does not exist or does not belong to your account.NO_ARRIVAL_POINTS- the junction has no arrival points, so no arrival-time data can be generated for it.JUNCTION_IN_PROGRESS- another archive generation task of the samearchiveTypethat is stillIN_PROGRESSalready covers this junction and an overlapping date range.
Errors
The system generates an error response if there is an error in the supplied parameters or any other internal problem. This response is generated in the requested format.
Error response codes
The following table shows the HTTP error response codes.
| Code | Description |
|---|---|
| 401 | Unauthorized |
| 403 | Forbidden |
| 422 | Unprocessable Entity None of the requested junctions could be triggered. The body has the same shape as the success response, with |
Error response field
| Field | Description |
|---|---|
| The problem description. |
Example error response
The following is an example error response for Unprocessable Entity:
{ "id": null, "isSuccess": false, "triggeredJunctions": [], "notTriggeredJunctions": { "JUNCTION_NOT_FOUND": ["65268ff77cd5d952a185b9b5"], "NO_ARRIVAL_POINTS": ["65268ff77cd5d952a185b9b6"] }}