一次调用即可了解一个手机号码的全部信息:当前服务运营商、号码发行运营商、号码是否在两者之间携号转网,以及线路类型。一次调用即可了解一个电子邮件地址是否能接收邮件。与所有其他 Bird 渠道使用相同的密钥、相同的错误格式、相同的幂等性约定,因为它们全部由同一个工程团队构建。
import { BirdClient } from "@messagebird/sdk";
const bird = new BirdClient({
apiKey: process.env.BIRD_API_KEY!,
});
const answer = await bird.lookup.phoneNumber({
phone_number: "+31612345678",
type: ["porting", "score"],
});
console.log(answer.country_code, answer.line_type);
// → "NL" "mobile"
console.log(answer.network_info?.carrier_name, answer.flags);
// → "KPN" ["ported"]
// Only a block whose status is ok carries a value,
// and only that one is billed.
if (answer.score?.status === "ok") console.log(answer.score.value);
// → 84
从 npm install 到首次查询仅需5分钟
使用您已熟悉的编程语言查询号码或地址。
Go、TypeScript、Python 和 PHP SDK 中提供类型化方法,CLI 支持 bird lookup 命令。控制台同样支持逐条执行这两种操作,是在编写任何代码之前最快获取结果的方式。
const answer = await bird.lookup.phoneNumber({
phone_number: "+31612345678",
type: ["classification", "score"],
});
console.log(answer.country_code, answer.line_type);
// Only a block whose status is ok carries a value, and only that one is billed.
if (answer.score?.status === "ok") console.log(answer.score.value);Lookup 能返回什么信息,以及每项查询的费用。
来自真实数据源的命名字段,而非模型猜测。每个字段都会告知您是否已获得应答,您只需为已应答的字段付费。
- 01
国家和双网络信息
号码所属国家、当前服务运营商以及号段发行运营商。当号码已携号转网时,两者会有所不同。
- 02
线路类型检测
移动电话、固定电话、VoIP、免费电话、增值服务、卫星电话、寻呼机、公用电话、M2M、服务号码。在发送之前判断 SMS 是否可行。
- 03
携号转网标记,随基础查询免费返回
每次查询都会返回该号码是否曾经携号转网。如需获取转网日期和完整记录,请在请求中指定 porting 属性。
- 04
六个可选属性
在 type 中指定 name classification、porting、presence、roaming、sim_swap 或 score。分别返回号段分配的服务类型、携号转网记录、线路是否在线、是否处于漫游状态、SIM 卡最近一次更换时间,以及 0-100 的可信度评分。
- 05
每个属性都有状态
每个数据块返回 ok、unavailable 或 inconclusive。只有 ok 才携带值,因此您无需检查响应来判断它是否为空。
- 06
按结果付费,而非按请求付费
基础查询仅计费一次。附加属性仅在成功返回时计费,查询失败则完全不收费。
- 07
一个字段即可判定电子邮件地址
result 返回 valid、neutral、risky、undeliverable 或 typo,reason 字段说明不可投递地址无法接收邮件的原因。
- 08
拼写错误地址的自动纠正
did_you_mean 返回拼写错误可能对应的正确地址。flags 标记角色账户、一次性邮箱或免费邮箱地址,delivery_confidence 综合评估后给出 0 到 100 的评分。
- 09
重试不会重复计费
发送 Idempotency-Key 后,重复请求将返回您已付费的结果,而不会产生二次费用。
- 10
相同的认证,相同的错误响应格式
Lookup、SMS、Email、WhatsApp 和 Verify 共用一个 API 密钥。统一的错误注册表,独立的速率限制配额,确保查询不会占用您的发送额度。
我们为什么构建 Lookup
您不应该在 SMS 发送失败后才发现那是个固定电话号码。
基础查询结果来自与 Bird SMS 和 Voice 路由相同的运营商平台,这也是为什么查询成本如此低:我们本已在实时选择路由时运行这些查询。Lookup 将该查询作为一个一等端点开放,让您无需先发送消息即可验证注册、筛选潜在客户或差异化路由消息。与平台其他功能使用相同的认证、相同的错误格式和相同的幂等性约定。
import { BirdClient } from "@messagebird/sdk";
const bird = new BirdClient({
apiKey: process.env.BIRD_API_KEY!,
});
const answer = await bird.lookup.phoneNumber({
phone_number: "+31612345678",
type: ["porting", "score"],
});
console.log(answer.country_code, answer.line_type);
// → "NL" "mobile"
console.log(answer.network_info?.carrier_name, answer.flags);
// → "KPN" ["ported"]
// Only a block whose status is ok carries a value,
// and only that one is billed.
if (answer.score?.status === "ok") console.log(answer.score.value);
// → 84
两种操作,分别对应一种收件人类型。
两者都只需一个请求、一个响应。无需创建资源,无需轮询,无需事后清理。
手机号码。
国家、双网络信息、携号转网标记和线路类型,以及您在 type 中指定的任何附加属性。
电子邮件地址。
一个判定结果、一个可信度评分、解释高风险地址的标记,以及疑似拼写错误时的纠正建议。
探索 Lookup
深入了解每项操作。一个 API 密钥,一个统一错误格式。
Put it into practice.
Continue with the documentation, guides and examples for this topic. Resources are in English.