The Paradigm API can be used by company or instance administrators to track usage of the platform.
Below is a possible use of the:
- latest connections,
- active users,
- chat sessions,
- tool usage.
Retrieve chat sessions
import requests
base_url = "https://paradigm.lighton.ai/api/v2"
url = f"{base_url}/reporting/chat-sessions/"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"company_id": 2,
"start_date": "2025-01-01", # Required
# "end_date": "2025-04-01" # Optional, defaults to today
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
try:
data = response.json()
except requests.JSONDecodeError:
print("Received non-JSON response:", response.text)
else:
print("Error:", response.status_code, response.text)
If you have a private Paradigm instance, please replace your base URL by your company's instance.
Structure chat session data in a Pandas dataframe
import pandas as pd
# Flatten the structure
flattened_data = []
for entry in data["reporting"][0]["dates"]:
flat_entry = {
'date': entry['date'],
'nb_sessions': entry['sessions']['sessions_count'],
'unique_models': entry['sessions']['unique_models_count'],
'average_session': entry['sessions']['average_session_length'],
'user_queries': entry['chats']['user_queries_count'],
'model_responses': entry['chats']['model_responses_count'],
'model_responses_with_docs': entry['chats']['model_responses_with_docs_count'],
}
flattened_data.append(flat_entry)
# Create DataFrame
df_sessions = pd.DataFrame(flattened_data)
Going further with more endpoints
The same approach can be done with:
- the feedbacks endpoint:
/reporting/chats-feedback/
- the tools usage endpoint:
/reporting/tools/
Then, merging everything into the same dataframe allows a complete data analysis on the usage of the platform.