Piloterr

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 completed run created before it, retries aside. ?against=RUN_ID names another finished run (completed, failed or cancelled) of the same project instead. A retry stands for the run it retries: run_id is 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. row and previous_row are its numbers in each run, from 0: null for a row added (not in the earlier run) or removed (only in the earlier run). A row in both is changed when a compared field differs, unchanged otherwise, and failed when either run has no successful result for it.
  • Which fields. The fields are named as the columns of the CSV export, such as price or headquarters.city, and a name covers the fields nested under it. By default, the project's tracked_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,stock compares other fields for this request only. A field missing on one side counts as empty.
  • Filters and pages. items holds the added, removed and changed rows; ?change= keeps one kind only, unchanged and failed included. summary always counts all five, and total the rows that match change. Page with offset (default 0) and limit (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.csv

format=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).

StatusCodeWhen
404run_not_foundThe run, or the against run, is not one of your workspace's.
409run_not_finishedThe run, or the against run, has not ended yet.
409no_previous_runThe project has no earlier completed run: name one with ?against=RUN_ID.
409run_read_no_rowsThe run, or the against run, failed or was cancelled before reading any row: there is nothing to compare.
410results_expiredEither run's results were deleted, 30 days after it ended.
422not_same_projectThe against run belongs to another project.
422same_runThe against run is the same run, or a retry of it.