> ## 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`。

## 错误

| 代码 | 何时 |
| - | - |
| `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.