Spaces:
Runtime error
Runtime error
API Reference
Complete API documentation for Smart LINE Bot + Dashboard + Scraper Pipeline.
Base URL
http://localhost:8000/api/v1
Authentication
Login
POST /auth/login
Content-Type: application/x-www-form-urlencoded
username=admin@example.com&password=changeme
Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer"
}
Register
POST /auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123",
"full_name": "John Doe"
}
LINE Endpoints
Webhook
POST /line/webhook
Content-Type: application/json
{
"destination": "U1234567890",
"events": [...]
}
Send Message
POST /line/send
Authorization: Bearer {token}
Content-Type: application/json
{
"line_user_id": "U1234567890",
"message": "Hello!"
}
Get LINE Users
GET /line/users
Authorization: Bearer {token}
LINE Callback (OAuth)
GET /line/callback?code=xxx&state=xxx
Dashboard Endpoints
Get Users
GET /dashboard/users
Authorization: Bearer {token}
Response:
{
"users": [
{
"id": 1,
"email": "admin@example.com",
"full_name": "Admin",
"is_active": true,
"created_at": "2024-01-01T00:00:00"
}
],
"total": 1
}
Get Statistics
GET /dashboard/stats
Authorization: Bearer {token}
Response:
{
"user_count": 10,
"line_user_count": 50,
"scraping_job_count": 100,
"completed_job_count": 80,
"ai_conversation_count": 200
}
Create User
POST /dashboard/users
Authorization: Bearer {token}
Content-Type: application/json
{
"email": "newuser@example.com",
"password": "password123",
"full_name": "New User"
}
Scraping Endpoints
Create Job
POST /scraping/jobs
Authorization: Bearer {token}
Content-Type: application/json
{
"url": "https://example.com",
"website_type": "generic",
"priority": 1
}
Get Jobs
GET /scraping/jobs
Authorization: Bearer {token}
Get Job Detail
GET /scraping/jobs/{job_id}
Authorization: Bearer {token}
Get Job Results
GET /scraping/jobs/{job_id}/results
Authorization: Bearer {token}
Cancel Job
POST /scraping/jobs/{job_id}/cancel
Authorization: Bearer {token}
AI Endpoints
Create Conversation
POST /ai/conversations
Authorization: Bearer {token}
Content-Type: application/json
{
"title": "My Chat"
}
Get Conversations
GET /ai/conversations
Authorization: Bearer {token}
Chat
POST /ai/chat
Authorization: Bearer {token}
Content-Type: application/json
{
"message": "Hello, how are you?",
"conversation_id": 1
}
Response:
{
"message": "I'm doing well, thank you!",
"conversation_id": 1,
"message_id": "msg_123"
}
Get Conversation History
GET /ai/conversations/{conversation_id}/history
Authorization: Bearer {token}
Health Check
Health
GET /health
Response:
{
"status": "healthy",
"version": "1.0.0"
}
Ready
GET /ready
Error Responses
All endpoints may return the following error codes:
| Code | Description |
|---|---|
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 500 | Internal Server Error |
Error Response Format:
{
"detail": "Error message here"
}