---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/th/api-reference/contacts/activity/get-stats

ผู้ติดต่อ: กิจกรรม

# ดูสถิติ

ยอดรวมของทั้งบัญชีในการเรียกครั้งเดียว: ผู้ติดต่อ ผู้ติดต่อตามสถานะ สมาชิกตามรายชื่อ และผู้ติดต่อตามแท็ก

POST `https://g.sendcorex.com/v1/contacts` command: get_stats

ต้องมีขอบเขต `contact:read` บน API key ของคุณ

เป็นตัวนับที่อัปเดตทุกครั้งที่มีการเปลี่ยนแปลง จึงเรียกได้เบาๆ เมื่อเปิดแดชบอร์ด

## อาร์กิวเมนต์

endpoint นี้ไม่มีอาร์กิวเมนต์

## เริ่มต้นอย่างรวดเร็ว

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "get_stats"
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);
```

## การตอบกลับ

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "get_stats",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "total": 2040,
        "status": {
          "subscribed": 1951,
          "unsubscribed": 61,
          "bounced": 22,
          "complained": 3,
          "blocked": 3
        },
        "lists": {
          "customers": {
            "total": 1834,
            "ok": 1790,
            "opened": 912,
            "clicked": 233
          },
          "newsletter": {
            "total": 640,
            "ok": 602,
            "opened": 288,
            "clicked": 41
          }
        },
        "tags": {
          "customer": 1834,
          "vip": 120,
          "black-friday": 512
        }
      }
    }
  ]
}
```

### ฟิลด์การตอบกลับ

- `total`
ผู้ติดต่อในบัญชี
- `status`
ผู้ติดต่อตามสถานะรวม
- `lists.<id>`
สมาชิก `total` สมาชิกที่ส่งได้ `ok` และสมาชิกที่ `opened` หรือ `clicked`
- `tags`
ผู้ติดต่อตามแท็ก

## ข้อผิดพลาด

ข้อผิดพลาดระดับ HTTP ส่งกลับ `type`, `code` และ `message` ข้อผิดพลาดที่มีเครื่องหมาย CMD จะกลับมาในผลลัพธ์ของคำสั่ง พร้อม HTTP 200

- 401`INVALID_API_KEY`
API key ไม่มีอยู่ ถูกเพิกถอน หรือถูกปิดในแดชบอร์ด
- 429`RATE_LIMITED`
เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + API key เดียวกัน รอจำนวนวินาทีใน Retry-After
- CMD`MISSING_SCOPE`
API key ไม่มีขอบเขตที่คำสั่งนี้ต้องการ คำสั่งอื่นในคำขอยังทำงาน
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
