Skip to main content

AI Service API

Base URL

/api/ai-service

All endpoints require authentication and are subject to rate limiting:

  • Authorization: Bearer <token>
  • Rate limiting rules are configured per environment/account.

Endpoints

GET /single-sosmed

Process data from a single social media platform.

Headers:

  • Authorization: Bearer <token>

Query Parameters:

  • platform: Platform media sosial (twitter, instagram, facebook, dll)
  • keyword: Keyword untuk pencarian
  • limit: Jumlah data yang akan diambil (default: 100)
  • project_id: ID project untuk menyimpan hasil

Response:

{
"success": true,
"message": "Single platform processing completed",
"data": {
"platform": "twitter",
"keyword": "brand monitoring",
"processed_count": 85,
"contents": [
{
"id": "string",
"content": "string",
"author": "string",
"posted_at": "datetime",
"engagement": {
"likes": 10,
"comments": 5,
"shares": 2
},
"sentiment": "positive|negative|neutral"
}
],
"processing_time": "2.5s"
}
}

POST /scrap-project-keywords

Run scraping for the keywords in a specific project.

Headers:

  • Authorization: Bearer <token>

Request Body:

{
"project_id": "string",
"keywords": [
"keyword1",
"keyword2",
"keyword3"
],
"platforms": [
"twitter",
"instagram",
"facebook"
],
"date_range": {
"from": "2024-01-01",
"to": "2024-12-31"
},
"max_results_per_keyword": 500
}

Response:

{
"success": true,
"message": "Scraping completed successfully",
"data": {
"project_id": "string",
"total_keywords": 3,
"total_platforms": 3,
"scraping_summary": [
{
"keyword": "keyword1",
"platform": "twitter",
"found_count": 150,
"processed_count": 145
}
],
"total_contents_found": 450,
"total_contents_processed": 435,
"processing_time": "15.3s",
"start_time": "2024-12-19T10:00:00Z",
"end_time": "2024-12-19T10:15:30Z"
}
}

Error Responses

400 Bad Request

{
"error": "Invalid request parameters",
"details": "Platform parameter is required"
}

401 Unauthorized

{
"error": "Invalid or missing token"
}

403 Forbidden

{
"error": "Access denied or rate limit exceeded"
}

404 Not Found

{
"error": "Project not found"
}

429 Too Many Requests

{
"error": "Rate limit exceeded",
"retry_after": 60
}

500 Internal Server Error

{
"error": "Internal server error during processing"
}

Processing Status

Long-running process status

For endpoints that take longer to complete, the initial response will be:

{
"success": true,
"message": "Processing started",
"task_id": "string",
"estimated_time": "30s",
"status": "processing"
}

Check processing status

Use task_id to check the status:

GET /api/ai-service/status/{task_id}

Response:

{
"task_id": "string",
"status": "completed|processing|failed",
"progress": 100,
"result": { ... } // jika completed
}