> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 洞察

> 取得透過 Ayrshare 推廣的 Snapchat 廣告即時每日指標，包括花費、曝光、上滑、CPM、CPC 和 CTR。

取得 Snapchat 廣告的即時成效，每個廣告每天一列，適用於你透過[推廣貼文](https://www.ayrshare.com/docs/apis/ads/snapchat/boost-post.md)建立的廣告。

<ul>
  <li>數據在呼叫時從 Snapchat 讀取。每日花費記錄請使用[歷史記錄](https://www.ayrshare.com/docs/apis/ads/snapchat/get-ad-history.md)。</li>
  <li>Snapchat 依廣告回報，因此請傳送 `level=ad`。其他層級會回傳 `code: 101`。</li>
  <li>日期依廣告帳戶所在時區計算。金額以廣告帳戶的貨幣計，在每一列的 `currency` 中回傳。</li>
  <li>一個請求只涵蓋一個廣告帳戶。來自多個廣告帳戶的廣告會回傳 `code: 101`。</li>
  <li>透過 Ayrshare 為其他個人檔案建立的廣告會回傳 `code: 400`。</li>
  <li>範圍內每 31 天，每個廣告會從 Snapchat 讀取一次，一個請求最多可進行 100 次此類讀取。例如，50 個廣告跨 62 天即為 100 次讀取。更大的請求會回傳 `code: 101`：請傳送較少的廣告或較短的範圍。</li>
</ul>

## 請求頭參數

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## 查詢參數

**level** `string` *required*

必須為 `ad`。

**ids** `string`

以逗號分隔的 Snapchat 廣告 ID，最多 50 個。

你可以省略 `ids`，改為傳送 `accountId`。這樣會回報你在該廣告帳戶中透過 Ayrshare 為此個人檔案推廣的廣告。如果該帳戶中你的廣告超過 50 個，請求會回傳 `code: 101`：請改為傳送它們的 ID。如果未找到任何廣告，報告為空。

**accountId** `string`

Snapchat 廣告帳戶 ID。省略 `ids` 時必填。使用 `ids` 時，Ayrshare 有記錄的每個廣告都必須在此帳戶中。Ayrshare 沒有記錄的 ID 會從你包含該 ID 的廣告帳戶中讀取，因此 `accountId` 不會限制它。

**metrics** `string`

要回傳的指標，以逗號分隔。省略則回傳全部。請參閱[指標](#metrics)。

**startDate** `string` (default: 30 days ago)

第一天，格式為 `YYYY-MM-DD`。最多可追溯到 37 個月前。

**endDate** `string` (default: today)

最後一天，格式為 `YYYY-MM-DD`。

## 指標

| 指標 | 類型 | 意義 |
| - | - | - |
| `spend` | number | 花費金額 |
| `impressions` | number | 廣告曝光次數 |
| `clicks` | number | 廣告的上滑次數 |
| `cpm` | number 或 `null` | 每 1,000 次曝光的費用。無曝光的日期為 `null` |
| `cpc` | number 或 `null` | 每次上滑的費用。無上滑的日期為 `null` |
| `ctr` | number 或 `null` | 每次曝光的上滑率，以百分比表示。無曝光的日期為 `null` |

每一列還包含 `swipes`（與 `clicks` 計數相同）以及 `spendUsd`（貨幣為 USD 時等於 `spend`，否則為 `null`）。

Snapchat 不依天回報 `reach`、`actions` 或 `conversionValue`。請求這些指標會回傳 `code: 101`。Snapchat 也沒有細分維度，因此傳送 `breakdowns` 會回傳 `code: 101`。

## 分頁

所有列都在一個回應中回傳，因此 `meta.pagination.hasMore` 一律為 `false`。

## 錯誤

| Code | 何時 |
| - | - |
| `101` | 參數缺失或錯誤、`level` 不是 `ad`、指標或細分不受支援、`startDate` 早於 37 個月前、傳送了超過 50 個 ID、僅 `accountId` 就涵蓋了你超過 50 個廣告、廣告分布在多個廣告帳戶中、某個廣告不在 `accountId` 中，或請求需要超過 100 次讀取 |
| `400` | 某個廣告不屬於你，或 `accountId` 不是 Ayrshare 為這些廣告記錄的廣告帳戶 |
| `364` | 已達到 Snapchat 的速率限制。請等待一分鐘後重試 |
| `370` | Snapchat 無法回傳洞察資料。請重試 |

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/snapchat/insights?level=ad&ids=c3a1e2d4-0000-4000-8000-0000000000ad&startDate=2026-11-20&endDate=2026-11-21"
```

```json 200: Success theme={"system"}
{
  "status": "success",
  "platform": "snapchat",
  "level": "ad",
  "startDate": "2026-11-20",
  "endDate": "2026-11-21",
  "insights": [
    {
      "date": "2026-11-20",
      "level": "ad",
      "id": "c3a1e2d4-0000-4000-8000-0000000000ad",
      "currency": "USD",
      "spend": 12.5,
      "impressions": 3000,
      "clicks": 30,
      "cpm": 4.17,
      "cpc": 0.42,
      "ctr": 1,
      "swipes": 30,
      "spendUsd": 12.5
    },
    {
      "date": "2026-11-21",
      "level": "ad",
      "id": "c3a1e2d4-0000-4000-8000-0000000000ad",
      "currency": "USD",
      "spend": 18,
      "impressions": 4000,
      "clicks": 42,
      "cpm": 4.5,
      "cpc": 0.43,
      "ctr": 1.05,
      "swipes": 42,
      "spendUsd": 18
    }
  ],
  "count": 2,
  "meta": { "pagination": { "hasMore": false } }
}
```

```json 400: Wrong level theme={"system"}
{
  "action": "request",
  "status": "error",
  "code": 101,
  "message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
  "details": "Insights on snapchat report by ad: use level \"ad\" with the ad ids."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.