Skip to content

Conversation

@dgiegold
Copy link
Contributor

@dgiegold dgiegold commented Nov 16, 2025

🎯 Overview

This PR implements the /api/history/{org}/{database} REST API endpoint, enabling users to retrieve commit history for individual documents.

💻 Usage Examples

Basic Usage

from terminusdb_client import Client

client = Client("http://127.0.0.1:6363")
client.connect(db="my_database")

# Get complete document history
history = client.get_document_history("Person/Jane")

for entry in history:
    print(f"{entry['timestamp']}: {entry['message']} by {entry['author']}")

With Pagination

# Get the 10 most recent changes
recent_history = client.get_document_history(
    "Person/Jane", 
    start=0, 
    count=10
)

Get Only Creation or Last Update

# Get only when document was created
creation = client.get_document_history("Person/Jane", created=True)

# Get only last update
last_update = client.get_document_history("Person/Jane", updated=True)

Query Different Database

# Override team/db to query different database
history = client.get_document_history(
    "Person/Jane",
    team="my_team",
    db="other_database"
)

📊 Response Format

[
  {
    "author": "admin",
    "identifier": "tbn15yq6rw1l4e9bgboyu3vwcoxgri5",
    "message": "Updated document",
    "timestamp": datetime.datetime(2023, 4, 6, 19, 1, 14, 324928)
  },
  {
    "author": "admin",
    "identifier": "3v3naa8jrt8612dg5zryu4vjqwa2w9s",
    "message": "Created document",
    "timestamp": datetime.datetime(2023, 4, 6, 19, 0, 47, 406387)
  }
]

@dgiegold dgiegold changed the title [Feature] Add get_document_history() method to retrieve document-specific commit history [Feature] Add get_document_history() method Nov 16, 2025
@hoijnet
Copy link
Collaborator

hoijnet commented Dec 13, 2025

Apologies, I had missed this one, I'll look into it to get it in! Thanks for your contribution!!

@hoijnet
Copy link
Collaborator

hoijnet commented Jan 2, 2026

This PR implements the /api/history/{org}/{database} REST API endpoint, enabling users to retrieve commit history for individual documents.

The default count was set to -1 which provided a zero size list back. Adjusted the count default to 10 entries which also aligns with the Javascript client.

Looks good and will be merged. Thanks for submitting the PR!

Copy link
Collaborator

@hoijnet hoijnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

Default count is now 10, some lint errors fixed too.

@hoijnet hoijnet merged commit 9f69b3d into terminusdb:main Jan 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants