Complete API documentation for the TSTP system
The TSTP API provides programmatic access to the TSTP platform, allowing you to integrate tutorials, analytics, and user management into your applications.
https://system.tstp.xyz/api/
All API requests and responses use application/json content type.
The TSTP API uses session-based authentication. Include your session cookie in requests to access protected endpoints.
curl -X GET "https://system.tstp.xyz/api/users" \
-H "Cookie: PHPSESSID=your_session_id" \
-H "Content-Type: application/json"
API requests are rate limited to prevent abuse and ensure fair usage:
The API uses standard HTTP status codes and returns error details in JSON format:
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": {
"field": "email",
"reason": "Invalid email format"
}
}
}
Authenticate a user and create a session.
{
"username": "user@example.com",
"password": "password123"
}
{
"success": true,
"data": {
"user": {
"id": "123",
"username": "user@example.com",
"role": "user"
},
"session_id": "abc123"
}
}
Log out the current user and destroy the session.
{
"success": true,
"message": "Logged out successfully"
}
Get a list of users (admin only).
page - Page number (default: 1)limit - Items per page (default: 25)role - Filter by user role{
"success": true,
"data": {
"users": [
{
"id": "123",
"username": "user@example.com",
"role": "user",
"created_at": "2024-01-01T00:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 25,
"total": 100
}
}
}
Get a list of tutorials.
category - Filter by categorystatus - Filter by status (published, draft)search - Search in title and content{
"success": true,
"data": [
{
"id": "1",
"title": "Getting Started with HTML",
"description": "Learn the fundamentals of HTML",
"category": "web-development",
"status": "published",
"created_at": "2024-01-01T00:00:00Z"
}
]
}
Create a new tutorial (authenticated users only).
{
"title": "New Tutorial",
"description": "Tutorial description",
"content": "Tutorial content",
"category": "web-development",
"tags": ["html", "css"]
}
Get analytics data (admin only).
action - Analytics action (user_stats, tutorial_stats, system_stats)period - Time period (day, week, month, year){
"success": true,
"data": {
"total_users": 1000,
"active_users": 750,
"total_tutorials": 50,
"page_views": 10000
}
}
Switch the current user's theme.
{
"theme": "dark"
}
{
"success": true,
"theme": "dark",
"message": "Theme updated successfully"
}
// Fetch tutorials
fetch('/api/tutorials')
.then(response => response.json())
.then(data => {
if (data.success) {
console.log('Tutorials:', data.data);
}
})
.catch(error => {
console.error('Error:', error);
});
// Create tutorial
$data = [
'title' => 'New Tutorial',
'description' => 'Tutorial description',
'content' => 'Tutorial content'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://system.tstp.xyz/api/tutorials');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cookie: PHPSESSID=' . $session_id
]);
$response = curl_exec($ch);
curl_close($ch);