Compare runs
See which rows were added, removed or changed since the project's previous run, and download the comparison.
GET /v1/runs/{id}/diff tells what changed in a finished run's results since the project's previous run: rows added, removed or changed, with the fields that changed. It is what the run.changes_detected event sums up, and the Changes section of a run in the dashboard.
curl "https://dataflow.piloterr.com/v1/runs/RUN_ID/diff?limit=100" -H "x-api-key: YOUR_API_KEY"{
"run_id": "RUN_ID",
"against_run_id": "PREVIOUS_RUN_ID",
"tracked_fields": ["price", "stock"],
"summary": { "added": 3, "removed": 1, "changed": 12, "unchanged": 1180, "failed": 4 },
"total": 16,
"items": [
{
"change": "changed",
"key": { "query": "B0BSHF7WHW", "domain": "com" },
"row": 4,
"previous_row": 4,
"fields": [{ "field": "price", "before": "499.99", "after": "449.99" }]
},
{
"change": "added",
"key": { "query": "B0D1XD1ZV3", "domain": "com" },
"row": 1200,
"previous_row": null,
"fields": []
}
]
}- Which runs. By default, the run is compared with the project's latest
completedrun created before it, retries aside.?against=RUN_IDnames another finished run (completed,failedorcancelled) of the same project instead. A retry stands for the run it retries:run_idis the run first launched, and each run counts with its retries, the latest attempt of each row winning, as in the merged export. - Which rows. Rows are matched by the parameters they were called with (
key), not by their number, so a row that moved in the file is the same row.rowandprevious_roware its numbers in each run, from 0:nullfor a rowadded(not in the earlier run) orremoved(only in the earlier run). A row in both ischangedwhen a compared field differs,unchangedotherwise, andfailedwhen either run has no successful result for it. - Which fields. The fields are named as the columns of the CSV export, such as
priceorheadquarters.city, and a name covers the fields nested under it. By default, the project'stracked_fields; when it has none, every field but volatile ones that change at every call whatever the data, such as request ids and fetch times (request_id,timestamp,scraped_at…).?fields=price,stockcompares other fields for this request only. A field missing on one side counts as empty. - Filters and pages.
itemsholds theadded,removedandchangedrows;?change=keeps one kind only,unchangedandfailedincluded.summaryalways counts all five, andtotalthe rows that matchchange. Page withoffset(default0) andlimit(1 to 500, default 100).
To download the whole comparison, use GET /v1/runs/{id}/diff/export, with the same against, change and fields:
curl "https://dataflow.piloterr.com/v1/runs/RUN_ID/diff/export?format=csv" \
-H "x-api-key: YOUR_API_KEY" -o changes.csvformat=csv (the default) gives one line per changed field, and one line for each other row, with the columns change, key.<parameter> for each call parameter, field, before and after. It is UTF-8 with a byte order mark, and protected against formulas like the results export. format=json gives the same object as above, with every item and no paging. The file is named run-RUN_ID-diff-AGAINST_RUN_ID.csv (or .json).
| Status | Code | When |
|---|---|---|
404 | run_not_found | The run, or the against run, is not one of your workspace's. |
409 | run_not_finished | The run, or the against run, has not ended yet. |
409 | no_previous_run | The project has no earlier completed run: name one with ?against=RUN_ID. |
409 | run_read_no_rows | The run, or the against run, failed or was cancelled before reading any row: there is nothing to compare. |
410 | results_expired | Either run's results were deleted, 30 days after it ended. |
422 | not_same_project | The against run belongs to another project. |
422 | same_run | The against run is the same run, or a retry of it. |