Time-travel

Every law has a git-style history of commits. You can fetch the full text of any law at any past revision by its SHA. No other legal API ships this — use it to compare versions, diff clauses, or surface "as of X date" views in your product.

How it works

Behind the scenes, every law lives in a git repository — one per country — where each reform is a commit that modifies the law's Markdown. That repo is public (legalize-es, legalize-fr, etc.) — you could clone it. The API is the convenience layer: SHAs are surfaced directly, and you can fetch the text at any SHA in one call.

Walk the history

Start from a law ID and ask for its commits. Each commit has a SHA, a date, and a one-line summary derived from the reform that produced it.

history = client.laws.commits("es", "BOE-A-1978-31229") for c in history.items: print(c.sha[:7], c.date, c.summary) # Oldest commit — the original text of the constitution in 1978. original = client.laws.at_commit("es", "BOE-A-1978-31229", sha=history.items[-1].sha) print(original.content[:500])
const history = await client.laws.commits("es", "BOE-A-1978-31229"); for (const c of history.items) { console.log(c.sha.slice(0, 7), c.date, c.summary); } // Oldest commit — the original 1978 text. const original = await client.laws.atCommit( "es", "BOE-A-1978-31229", history.items.at(-1).sha ); console.log(original.content.slice(0, 500));
history, _ := client.Laws().Commits(ctx, "es", "BOE-A-1978-31229") for _, c := range history.Items { fmt.Println(c.SHA[:7], c.Date, c.Summary) } oldest := history.Items[len(history.Items)-1].SHA original, _ := client.Laws().AtCommit(ctx, "es", "BOE-A-1978-31229", oldest) fmt.Println(original.Content[:500])

Common use cases

  • Compliance "as of" views. Your users click a date; you show the law the way it read that day. Fetch the commits, pick the one with date ≤ click, call at_commit.
  • Diff between two reforms. Fetch the text at two SHAs and run any Markdown diff library. We'll expose a server-side /diff endpoint in a later release.
  • LLM grounding with dated citations. When a user asks "what did Article 8 say in 2003", you cite the exact SHA alongside the passage — auditable, reproducible.

SHAs vs. reform IDs

Each reform has its own stable ID (reform.id), which the webhook payload carries. The SHA is the commit that the reform produced — one reform → one commit. You can look up a commit by its SHA directly via at_commit, or walk from a reform via its commit_sha attribute. Both paths reach the same text.

SHAs are stable. We never rewrite history. A SHA you cached a year ago still resolves. If a commit must be rolled back, a new commit with a new SHA reverses it — git-style.