Description
This endpoint allows you to retrieve the complete chat history associated with a specific chat token.
Path Parameters
Name | Required | Type | Description |
---|
token | Yes | string | The unique token identifying the chat session |
Request
Content-Type: application/json
Example Request
curl --request GET \
--url "https://aitutor-api.vercel.app//api/v1/chat/token/history" \
--header 'accept: application/json'
Response
{
"success": true,
"history": [
{
"role": "user",
"content": "Hello, how can you help me today?",
"timestamp": "2023-12-01T10:30:00Z"
},
{
"role": "assistant",
"content": "I'm here to assist you with any questions or tasks you have.",
"timestamp": "2023-12-01T10:30:02Z"
}
]
}
Error Responses
{
"success": false,
"error": {
"message": "Invalid token provided",
"code": "invalid_token"
}
}
{
"success": false,
"error": {
"message": "Chat history not found",
"code": "history_not_found"
}
}
Code Examples
Python
import requests
token = "your_chat_token"
url = f"https://aitutor-api.vercel.app/api/v1/chat/{token}/history"
headers = {
"accept": "application/json"
}
response = requests.get(url, headers=headers)
print(response.json())
Node.js
const axios = require('axios');
const token = 'your_chat_token';
const url = `https://aitutor-api.vercel.app/api/v1/chat/${token}/history`;
const headers = {
'accept': 'application/json'
};
axios.get(url, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));