Skip to content

Conversation

@dgiegold
Copy link

@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
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.

1 participant