Assign API (LIKEPION)#

Internal API cho Assign service — quản lý dispatch tasks, servers, requests, links, retry, và rate limiting.

Base URL: https://apitest.likepion.com/api/v1/worker

Authentication#

Yêu cầu header X-API-Key từ server có service='assign':

X-API-Key: <assign_server_api_key>

Servers#

GET /servers — Danh sách servers & health #

curl "https://apitest.likepion.com/api/v1/worker/servers?status=online&inactive_minutes=5" \
  -H "X-API-Key: assign-key"
Tham sốMô tả
statusLọc theo status (online, offline, maintenance)
inactive_minutesServers không heartbeat quá N phút

Response:

{
  "success": true,
  "data": [
    {
      "id": "uuid",
      "name": "server-01",
      "ip": "1.2.3.4",
      "service": "tool",
      "status": "online",
      "active_threads": 5,
      "active_tasks": 12,
      "max_threads": 20,
      "priority": 10,
      "last_health_check": "2025-12-01T10:00:00Z",
      "last_active": "2025-12-01T10:00:00Z"
    }
  ],
  "total": 5
}

GET /servers/available — Servers còn slot #

curl "https://apitest.likepion.com/api/v1/worker/servers/available?status=online&service=tool" \
  -H "X-API-Key: assign-key"
Tham sốMặc địnhMô tả
statusonlineTrạng thái server
service-Lọc theo loại service

Response item bao gồm: avail_slots = max_threads - active_tasks

PUT /servers/:id/status — Cập nhật status server #

curl -X PUT "https://apitest.likepion.com/api/v1/worker/servers/{id}/status" \
  -H "X-API-Key: assign-key" \
  -H "Content-Type: application/json" \
  -d '{"status": "offline"}'

Requests#

GET /requests — Danh sách requests cần xử lý #

curl "https://apitest.likepion.com/api/v1/worker/requests?status=pending,running&service_type=entity&limit=50" \
  -H "X-API-Key: assign-key"
Tham sốMô tả
statusComma-separated: pending, running, completed, failed
service_typeentity, social, blog20, stacking, podcast, indexing
type_requestLoại request
limitTối đa 1000, mặc định 100

Response item:

{
  "id": "uuid",
  "user_id": "uuid",
  "service_type": "entity",
  "group_id": "uuid",
  "name": "Campaign A",
  "website": "https://target.com",
  "auction_price": 100,
  "target": 50,
  "created_links": 30,
  "status": "running",
  "type_request": "normal",
  "priority": 5,
  "config": {...},
  "data": {...},
  "folder_urls": {...},
  "started_at": "...",
  "created_at": "..."
}

GET /requests/completable — Requests có thể hoàn thành #

curl "https://apitest.likepion.com/api/v1/worker/requests/completable?status=running&all_links_done=true" \
  -H "X-API-Key: assign-key"
Tham sốMô tả
statusLọc theo status
typeService type
all_links_completedtrue — không còn link active
all_links_doneTương tự all_links_completed
no_active_linkstrue — không còn link pending/queued/running
curl "https://apitest.likepion.com/api/v1/worker/requests/{id}/links/count" \
  -H "X-API-Key: assign-key"

Response:

{
  "success": true,
  "request_id": "uuid",
  "counts": [
    {"status": "completed", "count": 30},
    {"status": "failed", "count": 5},
    {"status": "pending", "count": 15}
  ],
  "total": 50,
  "profile_count": 30,
  "post_count": 25
}

PUT /requests/:id/status — Cập nhật status request #

curl -X PUT "https://apitest.likepion.com/api/v1/worker/requests/{id}/status" \
  -H "X-API-Key: assign-key" \
  -H "Content-Type: application/json" \
  -d '{"status": "running"}'

Status tự động set timestamps: runningstarted_at, completed/failedcompleted_at

PUT /requests/:id/connect — Chuyển sang phase connecting #

Reset completed links về connect status, cancel links chưa có profile.

curl -X PUT "https://apitest.likepion.com/api/v1/worker/requests/{id}/connect" \
  -H "X-API-Key: assign-key"

Response:

{
  "success": true,
  "updated": true,
  "links_connect": 25,
  "links_canceled": 5
}

PUT /requests/:id/complete — Hoàn thành request #

curl -X PUT "https://apitest.likepion.com/api/v1/worker/requests/{id}/complete" \
  -H "X-API-Key: assign-key"

# Links pending chưa gán server
curl "https://apitest.likepion.com/api/v1/worker/links?status=pending&service_type=entity&limit=100" \
  -H "X-API-Key: assign-key"

# Links stale (running/connecting quá lâu)
curl "https://apitest.likepion.com/api/v1/worker/links?stale=true&timeout_minutes=15" \
  -H "X-API-Key: assign-key"
Tham sốMặc địnhMô tả
statuspendingStatus cần lấy
service_type-Lọc service type
stalefalsetrue → lấy links running/connecting quá timeout
timeout_minutes15Ngưỡng timeout cho stale links
limit100Tối đa 1000
curl -X PUT "https://apitest.likepion.com/api/v1/worker/links/{id}/assign" \
  -H "X-API-Key: assign-key" \
  -H "Content-Type: application/json" \
  -d '{"server_id": "uuid"}'

Chỉ assign link đang pending. Status tự chuyển sang queued.

POST /links/bulk — Tạo links hàng loạt #

curl -X POST "https://apitest.likepion.com/api/v1/worker/links/bulk" \
  -H "X-API-Key: assign-key" \
  -H "Content-Type: application/json" \
  -d '{
    "links": [
      {
        "request_id": "uuid",
        "service_type": "entity",
        "server_id": "uuid",
        "site_id": "uuid",
        "site_name": "example.com",
        "email": "user@gmail.com",
        "username": "user123",
        "password": "pass",
        "about": "Bio",
        "max_retries": 3,
        "details": {"key": "value"}
      }
    ]
  }'

Tối đa 5000 links mỗi request.

Response:

{
  "success": true,
  "created": 100
}
curl "https://apitest.likepion.com/api/v1/worker/links/retryable?service_type=entity&limit=200" \
  -H "X-API-Key: assign-key"

Reset link failed về pending, tăng retry_count.

curl -X PUT "https://apitest.likepion.com/api/v1/worker/links/{id}/retry" \
  -H "X-API-Key: assign-key"
curl -X PUT "https://apitest.likepion.com/api/v1/worker/links/bulk-retry" \
  -H "X-API-Key: assign-key" \
  -H "Content-Type: application/json" \
  -d '{"link_ids": ["uuid-1", "uuid-2"]}'

PUT /links/mark-final-failed — Đánh dấu hết retry #

Chuyển links failed đã hết max_retries sang canceled.

curl -X PUT "https://apitest.likepion.com/api/v1/worker/links/mark-final-failed" \
  -H "X-API-Key: assign-key" \
  -H "Content-Type: application/json" \
  -d '{"request_id": "uuid"}'

GET /links/account-stats — Thống kê posting account #

curl "https://apitest.likepion.com/api/v1/worker/links/account-stats?email=user@gmail.com&request_id=uuid" \
  -H "X-API-Key: assign-key"

Response:

{
  "success": true,
  "email": "user@gmail.com",
  "pending_count": 5,
  "today_count": 10,
  "total_completed": 150,
  "last_post_at": "2025-12-01T09:30:00Z",
  "request_pending": 3,
  "request_completed": 20
}

Other Resources#

GET /sites — Danh sách sites #

curl "https://apitest.likepion.com/api/v1/worker/sites?type=entity&active=true&limit=100" \
  -H "X-API-Key: assign-key"

# Hoặc theo IDs cụ thể
curl "https://apitest.likepion.com/api/v1/worker/sites?ids=uuid1,uuid2" \
  -H "X-API-Key: assign-key"

GET /accounts — Danh sách accounts trong group #

curl "https://apitest.likepion.com/api/v1/worker/accounts?group_id=uuid&status=active" \
  -H "X-API-Key: assign-key"

GET /settings — Lấy settings theo group #

curl "https://apitest.likepion.com/api/v1/worker/settings?group=rate_limit" \
  -H "X-API-Key: assign-key"

Response:

{
  "success": true,
  "group": "rate_limit",
  "settings": {
    "max_posts_per_day": "50",
    "cooldown_minutes": "5"
  }
}

Error Responses#

HTTPMô tả
400Request không hợp lệ / thiếu required fields
401API key không hợp lệ hoặc không phải assign server
404Không tìm thấy resource
500Lỗi hệ thống