指纹服务器 API 节点.js SDK
指纹 是一个能提供行业领导精确度的设备智能平台.
指纹服务器节点 SDK 是和指纹互动的简单方法 服务器 API 从您的节点应用程序。 您可以搜索、更新或删除身份识别事件.
折旧通知
此版本的服务器 API 被标记为从 2026年1月7日 将被彻底废除 2027年1月7日 (中文(简体) ) 根据我们 API 折旧政策如果您仍然使用这个版本,请跟随我们 移徙指南 从这个被贬值的版本迁移到新的版本.
指纹服务器 API 允许您在服务器环境中搜索,更新并删除身份识别事件. 它可用于数据出口、决策和数据分析设想。 服务器API是用于服务器侧使用,并非从客户端方面使用,无论是浏览器还是移动设备.
所需资源
类型脚本支持 :
- 类型脚本4.5.5或以上
支持的运行时间 :
-
节点.js 18 LTS以上(我们支持所有 终止使用前的节点LTS释放) (中文(简体) ).
-
Deno和Bun可能有用,但没有得到积极测试.
-
"Edge"运行时间可能经过一些修改后起作用,但没有积极测试.
见“ edge” 运行时间兼容性
这个 SDK 可以与 JavaScript "edge" 运行时间兼容, 不支持所有节点 API, 例如, Vercel 边缘运行时间,或 云花岗工人。 。 。 .
为了成功 更换SDK的内置设备
fetch函数( 依赖于节点 APIS) , 且运行时间为本地fetch函数。 将函数传递到有适当绑定的构造器:const client = new FingerprintJsServerApiClient({ region: Region.EU, apiKey: apiKey, fetch: fetch.bind(globalThis), })
如何安装
使用您最喜欢的软件包管理器安装软件包 :
-
国家预防机制:
npm i @fingerprintjs/fingerprintjs-pro-server-api -
亚伦:
yarn add @fingerprintjs/fingerprintjs-pro-server-api -
时间 :
pnpm i @fingerprintjs/fingerprintjs-pro-server-api
开始
初始化客户端实例并使用它来提出API请求. 您需要指定您的指纹 秘密 API 密钥 和指纹工作区.
import {
FingerprintJsServerApiClient,
Region,
} from '@fingerprintjs/fingerprintjs-pro-server-api'
const client = new FingerprintJsServerApiClient({
apiKey: '<SECRET_API_KEY>',
region: Region.Global,
})
// Get visit history of a specific visitor
client.getVisits('<visitorId>').then((visitorHistory) => {
console.log(visitorHistory)
})
// Get a specific identification event
client.getEvent('<requestId>').then((event) => {
console.log(event)
})
// Search for identification events
client
.searchEvents({
limit: 10,
// pagination_key: previousSearchResult.paginationKey,
suspect: true,
})
.then((events) => {
console.log(events)
})
见 实例 更详细的示例文件夹.
处理错误
服务器 API 方法可以丢出 RequestError。 。 。 .
处理错误时, 您可以像这样检查 :
import {
RequestError,
FingerprintJsServerApiClient,
TooManyRequestsError,
} from '@fingerprintjs/fingerprintjs-pro-server-api'
const client = new FingerprintJsServerApiClient({
apiKey: '<SECRET_API_KEY>',
region: Region.Global,
})
// Handling getEvent errors
try {
const event = await client.getEvent(requestId)
console.log(JSON.stringify(event, null, 2))
} catch (error) {
if (error instanceof RequestError) {
console.log(error.responseBody) // Access parsed response body
console.log(error.response) // You can also access the raw response
console.log(`error ${error.statusCode}: `, error.message)
} else {
console.log('unknown error: ', error)
}
}
// Handling getVisits errors
try {
const visitorHistory = await client.getVisits(visitorId, {
limit: 10,
})
console.log(JSON.stringify(visitorHistory, null, 2))
} catch (error) {
if (error instanceof RequestError) {
console.log(error.status, error.error)
if (error instanceof TooManyRequestsError) {
retryLater(error.retryAfter) // Needs to be implemented on your side
}
} else {
console.error('unknown error: ', error)
}
// You can also check for specific error instance
// if(error instanceof VisitorsError403) {
// Handle 403 error...
// }
}
网络呼号
Webhook 类型
处理时 网络呼号 从指印上,你可以把有效载荷铸成内置的 VisitWebhook 类型 :
import { VisitWebhook } from '@fingerprintjs/fingerprintjs-pro-server-api'
const visit = visitWebhookBody as unknown as VisitWebhook
Webhook 签名验证
企业计划的客户可以 Webhook 签名 以加密方式验证进入的网络用户的真实性. 这个SDK为验证所接收到的webhook请求的HMAC签名提供了一种效用方法.
要学更多,看 实例/ 验证WebhookSignature.mjs。 。 。 .
密封结果
企业计划的客户可以 密封结果 以接收客户端的完整设备智能结果,并将其解封在服务器上。 这种SDK提供了解码密封结果的实用方法.
要学更多,看 实例/未担保。 。 。 .
删除访客数据
企业计划的客户可以 删除与特定访问者有关的所有数据 遵守隐私条例。 见 实例/删除Visitor.mjs。 。 。 .
语义版本
- 变动至 类型 在此寄存器中,被认为是不破解的,通常作为 PATCH 或 MINOR semver 的修改而发布(否则,每增加一个计划将是主要的版本升级).
- 强烈建议您将您的软件包版本锁定到特定的 PATCH 发布并升级,期望类型可以在任何发布之间升级.
- 节点SDK的运行时间(与类型无关)公共API仍然严格遵循semver.
支助和反馈
报告问题、提问或反馈,请使用 问题。如果你需要私人支持,你可以发电子邮件给我们 oss- support@指印.com。 。 。 .
许可证
本项目根据以下规定获得许可证: 麻省理工学院许可证。 。 。 .