# 从 Apollo.io 迁移

本指南将 Apollo.io 的 People Enrichment（`POST /api/v1/people/match`）和 Bulk People Enrichment（`POST /api/v1/people/bulk_match`）端点映射到 Tomba。Apollo.io API 的行为已于 2026-09-30 对照 [Apollo.io API 参考](https://docs.apollo.io/reference/people-enrichment)进行核实。

## 开始之前

- 获取您的 API 密钥（`ta_…`）和 Secret（`ts_…`）；请参阅[认证](/authentication)。
- 在[积分消耗](/usage-and-quotas#credit-costs)中查看每个端点的费用，并在[各套餐的限制](/rate-limits#limits-by-plan)中查看您套餐的限流规则。
- Apollo.io 会根据您发送的任意标识符匹配人员。Tomba 为每种输入提供一个端点，因此请根据您拥有的标识符选择端点：姓名和公司、LinkedIn URL 或邮箱地址。
- 请将 HTTP 客户端超时设为至少 180 秒。Tomba 会在响应中返回最终结果，包括电话号码。

## 端点映射

将基础 URL `https://api.apollo.io/api/v1` 替换为 `https://api.tomba.io/v1`。Apollo.io 接收 `POST` 请求；Tomba 的查询是带查询参数的 `GET` 请求。

| Apollo.io                                                            | Tomba                                               | 备注                                                                                      |
| -------------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| 带姓名以及 `domain` 或 `organization_name` 的 `POST /people/match` | [`GET /v1/email-finder`](/api/finder#email-finder)  | 返回该人员的工作邮箱地址。                                                         |
| 带 `linkedin_url` 的 `POST /people/match`                             | [`GET /v1/linkedin`](/api/finder#linkedin-finder)   | 返回与邮箱查找器相同的字段。                                               |
| 带 `email` 的 `POST /people/match`                                    | [`GET /v1/people/find`](/api/enrichment#person-api) | 以 Clearbit 风格的格式返回人员；请参阅[数据丰富](/attributes/enrichment)。 |
| 带 `reveal_phone_number` 的 `POST /people/match`                      | [`GET /v1/phone-finder`](/api/phone#phone-finder)   | 或者在邮箱查找器或 LinkedIn 查找器请求中添加 `enrich_mobile=true`。                |
| `POST /people/bulk_match`                                            | 批量任务                                           | 请参阅[批量任务和异步任务](#bulk-and-async-jobs)。                                           |

## 认证变更

Apollo.io 从 `x-api-key` 请求头或 OAuth 2.0 Bearer 令牌读取密钥。Tomba 需要 `X-Tomba-Key` 和 `X-Tomba-Secret` 这 2 个请求头。Tomba 也支持 OAuth 2.0；请参阅 [OAuth 2.0](/authentication#oauth-20)。

```bash
# Apollo.io
curl -X POST "https://api.apollo.io/api/v1/people/match?first_name=Jane&last_name=Doe&domain=stripe.com" \
  -H "x-api-key: $APOLLO_API_KEY"

# Tomba
curl "https://api.tomba.io/v1/email-finder?first_name=Jane&last_name=Doe&domain=stripe.com" \
  -H "X-Tomba-Key: $TOMBA_API_KEY" \
  -H "X-Tomba-Secret: $TOMBA_SECRET_KEY"
```

Tomba 的 API 密钥会过期；请参考[密钥过期](/authentication#key-expiry)规划轮换。

## 参数映射

| Apollo.io                                    | Tomba                                                          | 备注                                                                                                                                                                        |
| -------------------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `first_name`, `last_name`                    | `first_name`, `last_name`                                      | 邮箱查找器。                                                                                                                                                                |
| `name`                                       | `full_name`                                                    | 邮箱查找器。在未同时发送 `first_name` 和 `last_name` 时使用。                                                                                                       |
| `domain`                                     | `domain`                                                       | 邮箱查找器。一次性邮箱或网页邮箱域名会返回 `400 unknown_record`。                                                                                                   |
| `organization_name`                          | `company`                                                      | 邮箱查找器。Apollo.io 还会匹配以前的雇主；Tomba 搜索您发送的公司。提供域名效果更好。                                                |
| `linkedin_url`                               | [`GET /v1/linkedin`](/api/finder#linkedin-finder) 的 `url`     |                                                                                                                                                                              |
| `email`                                      | [`GET /v1/people/find`](/api/enrichment#person-api) 的 `email` |                                                                                                                                                                              |
| `reveal_phone_number`                        | `enrich_mobile=true`                                           | 号码会在同一响应的 `data.phone_data` 中返回，需额外付费；不需要 webhook。                                                                      |
| `webhook_url`                                | `webhook_url`                                                  | 在 Tomba 中为可选。结果仍会在响应中返回，并在符合条件时另外通过 POST 发送到您的 URL。请参阅[单次请求回调](/webhook#per-request-callbacks)。 |
| `id`, `hashed_email`                         | 无对应项                                                  |                                                                                                                                                                              |
| `reveal_personal_emails`                     | 无对应项                                                  | Tomba 返回工作邮箱地址。                                                                                                                                                |
| `run_waterfall_email`, `run_waterfall_phone` | 无对应项                                                  |                                                                                                                                                                              |
| `poll_only`                                  | 无对应项                                                  | Tomba 的每个响应都是最终结果。                                                                                                                                               |

## 响应字段映射

Apollo.io 在 `person` 中返回人员。Tomba 的邮箱查找器和 LinkedIn 查找器在 `data` 中返回人员；字段说明见[人员响应](/attributes/person)。

| Apollo.io                                    | Tomba                               | 备注                                                                                                                  |
| -------------------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `person.email`                               | `data.email`                        | 未找到地址时为 `null`；状态码仍为 `200`。                                                            |
| `person.email_status`                        | `data.verification.status`          | 请参阅[状态映射](#status-mapping)。                                                                                 |
| `person.first_name`, `last_name`             | `data.first_name`, `data.last_name` |                                                                                                                        |
| `person.name`                                | `data.full_name`                    |                                                                                                                        |
| `person.title`                               | `data.position`                     |                                                                                                                        |
| `person.linkedin_url`                        | `data.linkedin`                     |                                                                                                                        |
| `person.country`                             | `data.country`                      | 在 Tomba 中为 2 位字母国家代码。                                                                                    |
| `person.departments[]`                       | `data.department`                   | 1 个部门。部门名称有所不同。                                                                           |
| `person.organization`                        | `data.company`, `data.website_url`  | 公司名称和域名。如需完整的公司资料，请调用 [`GET /v1/companies/find`](/api/enrichment#company-api)。 |
| `person.phone_numbers[].sanitized_number`    | `data.phone_data[].e164_format`     | 需设置 `enrich_mobile=true`。`line_type` 表示号码类型；请参阅[电话响应](/attributes/phone)。                 |
| `person.match_confidence`                    | `data.score`                        | 计算方式不同。请重新校准您对它设置的任何阈值。                                                       |
| `person.city`, `state`                       | 无对应项                       | [`GET /v1/people/find`](/api/enrichment#person-api) 在 Tomba 有相应数据时返回 `data.geo.city` 和 `data.geo.state`。  |
| `person.seniority`                           | 无对应项                       | [`GET /v1/people/find`](/api/enrichment#person-api) 在 Tomba 有相应数据时返回 `data.employment.seniority`。             |
| `person.id`, `contact_id`, `organization_id` | 无对应项                       |                                                                                                                        |
| `person.headline`, `employment_history`      | 无对应项                       |                                                                                                                        |
| `request_id`, `waterfall`                    | 无对应项                       | Tomba 在 `X-Request-ID` 响应头中返回请求 ID；请参阅[上线生产环境](/going-to-production)。              |

Tomba 还会返回 `pattern`、`type`、`gender`、`accept_all` 以及找到该地址的 `sources`。对于邮箱查询，`GET /v1/people/find` 返回 `data.name`、`data.employment`、`data.geo` 和 `data.linkedin.handle`；请参阅[数据丰富](/attributes/enrichment)。

## 状态映射

| Apollo.io `email_status` | Tomba `verification.status` |
| ------------------------ | --------------------------- |
| `verified`               | `valid`                     |

Tomba 还会返回 `accept_all`、`invalid` 和 `unknown`，地址尚未验证时返回 `null`。比较 `status` 时请忽略大小写。各个值的定义见[状态值](/attributes/verifier#status-values)。

## 错误映射

Apollo.io 返回 `error` 字符串。Tomba 返回包含 `type`、`message` 和 `code` 的 `errors` 对象：

| Apollo.io                                              | Tomba                                                                                                                        | 建议操作                                                                                          |
| ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `400` 验证错误                                 | `422 params_invalid`                                                                                                         | 修正消息中指出的参数。                                                             |
| `400` 使用 `reveal_phone_number` 时缺少 `webhook_url` | 不会返回                                                                                                                 | Tomba 获取电话号码不需要 webhook。                                                     |
| `401` API 密钥无效                                  | `400 authentication_failed`（缺失或格式错误）、`400 api_key_expired`、`401 authentication_failed`（密钥或 Secret 错误） | 检查这两个请求头；[轮换](/authentication#rotate-keys)已过期的密钥。                           |
| `429` 超出速率限制                              | `429 rate_limit`                                                                                                             | 在 `Retry-After` 指定的延迟后重试；请参阅[处理 429 响应](/rate-limits#handle-429-responses)。 |

还要处理以下情况：积分用完时返回的 `402 quota_exceeded`，邮箱查找器收到一次性邮箱或网页邮箱域名时返回的 `400 unknown_record`，以及地址所有者要求 Tomba 停止处理该地址时返回的 `451 claimed_email`。当 Tomba 没有该地址的数据时，`GET /v1/people/find` 返回 `200` 以及类型为 `not_found` 的 `errors` 对象，因此请检查响应体中是否有 `errors`。错误响应不消耗积分；所有类型都列在[错误](/error-handling#error-types)中。

Apollo.io 在 `x-rate-limit-*` 和 `x-*-requests-left` 响应头中报告其限制。Tomba 的响应头见[速率限制响应头](/rate-limits#rate-limit-headers)。

## 批量任务和异步任务

Apollo.io 的批量端点在 `details[]` 中最多接收 10 个人员，并在响应中返回 `matches[]`。Tomba 以批量任务的形式处理列表；各类型的行数限制见[批量类型](/bulks#bulk-types)。

| Apollo.io `details[]` 条目 | Tomba 批量类型                                                                                         |
| ----------------------------- | ------------------------------------------------------------------------------------------------------- |
| 姓名以及 `domain` 或公司  | `finder`：包含姓名和公司列的 CSV 文件。请参阅[邮箱查找器](/bulks#email-finder)。            |
| `linkedin_url`                | `linkedin`：个人资料 URL 的 JSON `list` 或 CSV 文件。请参阅 [LinkedIn 查找器](/bulks#linkedin-finder)。 |
| `email`                       | `enrich`：地址的 JSON `list` 或 CSV 文件。请参阅[邮箱数据丰富](/bulks#email-enrichment)。    |
| `reveal_phone_number`         | 在任务上将 `phone` 设为 `true`，需额外付费。                                                     |

每个任务都需要创建、启动、轮询，并以 CSV 格式下载；请参阅[生命周期](/bulks#lifecycle)。如需在任务结束时收到通知，请设置 `webhook_url`；请参阅[批量任务事件](/webhook#bulk-job-events)。任务在您首次下载其结果时计费；请参阅[计费](/bulks#billing)。

批量响应字段 `total_requested_enrichments`、`unique_enriched_records`、`missing_records` 和 `credits_consumed` 没有对应项。请改为轮询任务进度。

## 代码示例

此函数替代使用姓名和公司或 LinkedIn URL 发起的 `people/match` 调用。它返回 Apollo.io 的 `person` 字段名称，Tomba 未找到地址时返回 `null`。需要 Node.js 18 或更高版本。

```js title="people-match.mjs"
const TOMBA_HEADERS = {
    "X-Tomba-Key": process.env.TOMBA_API_KEY,
    "X-Tomba-Secret": process.env.TOMBA_SECRET_KEY,
};

// Accepts Apollo.io's parameters: linkedin_url, or first_name + last_name
// (or name) with domain or organization_name.
async function peopleMatch(params) {
    let url;
    if (params.linkedin_url) {
        url = new URL("https://api.tomba.io/v1/linkedin");
        url.searchParams.set("url", params.linkedin_url);
    } else {
        url = new URL("https://api.tomba.io/v1/email-finder");
        const map = {
            first_name: "first_name",
            last_name: "last_name",
            name: "full_name",
            domain: "domain",
            organization_name: "company",
        };
        for (const [apollo, tomba] of Object.entries(map)) {
            if (params[apollo]) url.searchParams.set(tomba, params[apollo]);
        }
    }
    if (params.reveal_phone_number)
        url.searchParams.set("enrich_mobile", "true");

    const res = await fetch(url, { headers: TOMBA_HEADERS });
    const body = await res.json();
    if (body.errors) {
        throw new Error(
            `${res.status} ${body.errors.type}: ${body.errors.message}`,
        );
    }

    const found = body.data;
    if (!found.email) return null;
    const status = found.verification?.status?.toLowerCase() ?? null;
    return {
        first_name: found.first_name,
        last_name: found.last_name,
        name: found.full_name,
        email: found.email,
        // Apollo.io's "verified" is Tomba's "valid"; other statuses pass through.
        email_status: status === "valid" ? "verified" : status,
        title: found.position,
        linkedin_url: found.linkedin,
        country: found.country,
        phone_numbers: (found.phone_data ?? []).map((phone) => ({
            sanitized_number: phone.e164_format,
        })),
    };
}

console.log(
    await peopleMatch({
        first_name: "Jane",
        last_name: "Doe",
        domain: "stripe.com",
    }),
);
```

## 切换检查清单

1. 将 Tomba 密钥和 Secret 存储为 `TOMBA_API_KEY` 和 `TOMBA_SECRET_KEY`，并以 `X-Tomba-Key` 和 `X-Tomba-Secret` 发送，取代 `x-api-key`。
2. 按输入路由每个 `people/match` 调用：姓名和公司路由到 `/v1/email-finder`，LinkedIn URL 路由到 `/v1/linkedin`，邮箱地址路由到 `/v1/people/find`。
3. 用 `enrich_mobile=true` 替代 `reveal_phone_number` 及其 webhook，并从 `data.phone_data` 读取号码。
4. 更新响应解析：读取 `data` 而不是 `person`，`position` 而不是 `title`，`linkedin` 而不是 `linkedin_url`，并根据[状态映射](#status-mapping)转换 `email_status`。
5. 积分耗尽时处理 `402`，在 `Retry-After` 之后重试 `429`，并丢弃返回 `451` 的地址。
6. 将 `bulk_match` 批次迁移到 `finder`、`linkedin` 或 `enrich` 批量任务。
7. 在切换生产流量之前，用两个服务处理同一批样本人员，并比较结果。
