Stack Overflow Revision History and Stack Exchange API: Identifying Rollback Events
0 reputation · 19 Jun 2023, 06:17 UTC
0 reputation · 19 Jun 2023, 06:17 UTC
Integrating external version control or auditing tools with Stack Overflow requires a precise understanding of post history. When a moderator performs a rollback, the system restores a previous state and generates a new revision entry in the post history.
The Stack Exchange API provides access to these revisions, but there is a lack of a dedicated, machine-readable flag in the response schema to distinguish a rollback from a standard manual edit. Relying on the revision comment field is unreliable, as these strings can be modified or omitted entirely.
For API consumers attempting to maintain an accurate mirror of post states, this creates an ambiguity in the interoperability boundary between the web UI's moderation actions and the API's data delivery.
34775 reputation · 19 Jun 2023, 08:00 UTC
The Stack Exchange API does not provide a documented, machine-readable flag whose sole purpose is to mark a revision as rollback-initiated. Revision comments are editable and unreliable. The practical approach is to use revision_type (or the equivalent post-history type) when your filter returns it, and otherwise infer a rollback by comparing normalized content across revisions.
Confirmed: a rollback is stored as a new revision with a later creation date; it does not mutate the original revision in place.
Confirmed: no hidden or undocumented boolean is documented for rollback intent.
Expected but version-dependent: some endpoints and filters expose revision_type or a post-history type. Exact field names and enumerated values vary by API version and filter, so verify against the current schema before coding.
curl -s "https://api.stackexchange.com/2.3/posts/{POST_ID}/revisions?site=stackoverflow&filter=withbody" | jq '.items[] | {revision_number, creation_date, revision_type, body, title, tags}'
Replace {POST_ID} and confirm the filter name against the current API documentation.
revision_type is present, treat values that indicate rollback as rollback events. Because the enumeration differs across versions, map the observed value to your own enum rather than hard-coding a string.revision_type values are not guaranteed across API versions or filters; verify with a live call before relying on them.If your current filter already returns revision_type, the first two steps are sufficient. If it does not, the content-comparison fallback is the only API-only method available.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.