https://your-domain.com/api
The Terms-inator API provides programmatic access to our AI-powered legal document analysis platform. Integrate T&C analysis directly into your applications with our RESTful API.
The API uses JWT (JSON Web Token) authentication. First, obtain a token by logging in with your credentials, then include the token in the Authorization header for subsequent requests.
Authenticate and receive a JWT token for API access.
| Parameter | Type | Required | Description |
|---|---|---|---|
email |
string | Required | User email address |
password |
string | Required | User password |
curl -X POST "https://your-domain.com/api/auth/login" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "email=user@example.com&password=your_password"
{
"success": true,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"user": {
"id": 123,
"email": "user@example.com",
"name": "John Doe",
"credits": 50
},
"credits": 50
}
Rate limits are enforced per user account. When you exceed the rate limit, you'll receive a 429 status code with retry information in the response headers.
X-RateLimit-Limit: Maximum requests per hourX-RateLimit-Remaining: Remaining requests in current windowX-RateLimit-Reset: Unix timestamp when the rate limit resetsAnalyse Terms & Conditions text using AI and get comprehensive insights.
| Header | Value | Required |
|---|---|---|
Authorization |
Bearer {token} | Required |
Content-Type |
application/json | Required |
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string | Required | The Terms & Conditions text to analyse (min 50 characters) |
source_url |
string | Optional | URL where the terms were found |
title |
string | Optional | Document title for reference |
curl -X POST "https://your-domain.com/api/v1/analyze" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "Your terms and conditions text here...",
"source_url": "https://example.com/terms",
"title": "Example Terms of Service"
}'
{
"success": true,
"session_id": "sess_abc123def456",
"document_id": 789,
"progress_url": "/api/v1/progress/sess_abc123def456",
"message": "Analysis started successfully",
"estimated_time": "30-60 seconds"
}
{
"success": false,
"error": "Invalid input",
"message": "Text must be at least 50 characters long",
"details": {
"field": "text",
"received_length": 25,
"minimum_length": 50
}
}
Get real-time progress updates for an analysis session using Server-Sent Events (SSE).
| Header | Value | Required |
|---|---|---|
Authorization |
Bearer {token} | Required |
Accept |
text/event-stream | Optional |
curl -X GET "https://your-domain.com/api/v1/progress/sess_abc123def456" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Accept: text/event-stream"
data: {"stage": "processing", "progress": 25, "message": "Analyzing document structure..."}
data: {"stage": "ai_analysis", "progress": 75, "message": "Running AI analysis..."}
data: {"stage": "complete", "progress": 100, "document_id": 789, "redirect_url": "/document/789"}
Retrieve the user's document analysis history with pagination support.
| Parameter | Type | Default | Description |
|---|---|---|---|
limit |
integer | 20 | Number of documents to return (max 100) |
offset |
integer | 0 | Number of documents to skip |
{
"success": true,
"documents": [
{
"id": 789,
"title": "Example Terms of Service",
"source_url": "https://example.com/terms",
"overall_rating": 7.2,
"created_at": "2024-01-15T10:30:00Z",
"summary": "Generally user-friendly terms with some concerns about data collection..."
}
],
"pagination": {
"total": 15,
"limit": 20,
"offset": 0,
"has_more": false
}
}
Get complete analysis results for a specific document.
{
"success": true,
"document": {
"id": 789,
"title": "Example Terms of Service",
"source_url": "https://example.com/terms",
"overall_rating": 7.2,
"scores": {
"clarity": 8.0,
"fairness": 6.5,
"privacy": 7.0,
"user_rights": 7.5
},
"concerns": [
{
"title": "Data Collection Practices",
"description": "The terms allow extensive data collection...",
"severity": "medium",
"category": "privacy"
}
],
"recommendations": [
"Consider reviewing the data sharing policies",
"Be aware of the arbitration clause"
],
"created_at": "2024-01-15T10:30:00Z"
}
}
The API uses conventional HTTP status codes to indicate success or failure.
| Status Code | Meaning | Description |
|---|---|---|
200 |
OK | Request successful |
400 |
Bad Request | Invalid request parameters |
401 |
Unauthorized | Invalid or missing authentication |
403 |
Forbidden | Insufficient credits or permissions |
404 |
Not Found | Resource not found |
429 |
Too Many Requests | Rate limit exceeded |
500 |
Internal Server Error | Server error occurred |
{
"success": false,
"error": "Error type",
"message": "Human-readable error message",
"details": {
"additional": "context-specific information"
}
}
// Login and analyse a document
async function analyseDocument(text, sourceUrl) {
// First, authenticate
const loginResponse = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
email: 'user@example.com',
password: 'password'
})
});
const { token } = await loginResponse.json();
// Then analyze
const analyzeResponse = await fetch('/api/v1/analyze', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ text, source_url: sourceUrl })
});
const result = await analyzeResponse.json();
console.log('Analysis started:', result);
// Listen for progress updates
const eventSource = new EventSource(`/api/v1/progress/${result.session_id}`);
eventSource.onmessage = (event) => {
const progress = JSON.parse(event.data);
console.log('Progress:', progress);
if (progress.stage === 'complete') {
eventSource.close();
// Fetch final results
fetchDocument(progress.document_id, token);
}
};
}
import requests
import json
class TLDRClient:
def __init__(self, base_url, email, password):
self.base_url = base_url
self.token = self._authenticate(email, password)
def _authenticate(self, email, password):
response = requests.post(f"{self.base_url}/api/auth/login", data={
'email': email,
'password': password
})
return response.json()['token']
def analyse(self, text, source_url=None, title=None):
headers = {
'Authorization': f'Bearer {self.token}',
'Content-Type': 'application/json'
}
data = {'text': text}
if source_url:
data['source_url'] = source_url
if title:
data['title'] = title
response = requests.post(
f"{self.base_url}/api/v1/analyze",
headers=headers,
json=data
)
return response.json()
def get_document(self, document_id):
headers = {'Authorization': f'Bearer {self.token}'}
response = requests.get(
f"{self.base_url}/api/v1/document/{document_id}",
headers=headers
)
return response.json()
# Usage
client = TLDRClient('https://your-domain.com', 'user@example.com', 'password')
result = client.analyse('Your terms and conditions text here...')
print(f"Analysis started: {result['session_id']}")
Full-featured SDK with TypeScript support
Pythonic interface with async support
PSR-4 compliant with Composer support
Lightweight and efficient Go client
We welcome community contributions for SDKs in other programming languages. Check out our contribution guidelines to get started.