Getting Comparison Results as a JSON via the Change-Details Endpoint (API Self Hosted)
Draftable provides a useful API endpoint called the change-details endpoint, which allows users to retrieve comparison results as a structured JSON response. This article provides details on how to access this endpoint and outlines an example for retrieving the JSON data via code.
your-self-hosted-domain: This should be the base URL for your self-hosted Draftable installation.
Comparison_ID: This is the unique identifier for the comparison you want to retrieve the details of.
You will need to authenticate using your API credentials to access the endpoint if you wish to view it directly in the browser. Hence, ensure you are logged in with the appropriate credentials before attempting to access this URL.
You can also access the change-details endpoint programmatically using your preferred coding language. For the below example, we are using Python of how to retrieve the JSON response for a given comparison ID.Note: Retrieval or usage of the change-details endpoint is not apart of any existing client library, it will need to be created yourselves.
Copy
Ask AI
import requests# Replace with your actual endpoint URL and API access tokenurl = 'https://example.com/api/v1/comparisons/<Comparison_ID>/change-details'access_token = 'your_access_token'# Set up headers with the authorization tokenheaders = { 'Authorization': f'Token {access_token}',}# Make the GET request to the endpointresponse = requests.get(url, headers=headers)# Check if the request was successfulif response.status_code == 200: # Parse and print the JSON response json_response = response.json() print(json_response)else: print(f"Request failed with status code: {response.status_code}")
Authentication: You need to pass the correct API token as part of the request headers. Ensure that your token is up to date and correctly scoped for accessing comparison data.
Error Handling: The response will include an HTTP status code, so ensure to handle possible errors such as 401 Unauthorized or 404 Not Found in your code.
Data Privacy: The comparison results might contain sensitive information depending on the documents compared. Ensure appropriate measures are in place to secure this data.
The change-details endpoint provides a convenient way to programmatically retrieve detailed comparison results in JSON format, which can be integrated into various workflows or applications. Whether accessed directly via the URL or programmatically through code, this endpoint offers flexibility for users needing detailed change data.For more information on other API endpoints or configuration options, please refer to the Draftable API Documentation.If you encounter any issues accessing the endpoint or need assistance, feel free to reach out to our support team.