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,
"platform": "string",
"result": {
"dispatched": true,
"dispatched_keywords": "keyword_id : string, keyword: string",
"status": "Tasks dispatched to queue"
}
}

cURL:

curl -X 'GET' \
'https://smbrand-be-test.ganapatih.com/api/ai-service/single-sosmed?platform={platform}&keyword_id={keyword_id}&keyword_text={keyword_text}' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <token>'

POST /scrap-project-keywords

Run scraping for the keywords in a specific project.

Headers:

  • Authorization: Bearer <token>

Request Body:

{
"keyword_id": "string"
}

Response:

{
"success": true,
"result": {
"dispatched_keywords": ["string", "string", "string"],
"status": "Tasks dispatched to queue"
}
}s

cURL:

curl -X 'POST' \
'https://smbrand-be-test.ganapatih.com/api/ai-service/scrap-project-keywords' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"keyword_id": "string"
}'

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
}