Fingerprint is a device intelligence platform offering 99.5% accurate visitor identification.
The Fingerprint Server Node SDK is an easy way to interact with the Fingerprint Server API from your Node application. You can retrieve visitor history or individual identification events.
Deno and Bun might work but are not actively tested.
"Edge" runtimes might work with some modifications but are not actively tested.
See "edge" runtimes compatibility
This SDK can be made compatible with JavaScript "edge" runtimes that do not support all Node APIs, for example, Vercel Edge Runtime, or Cloudflare Workers.
To make it work, replace the SDK's built-in fetch function (which relies on Node APIs) with the runtime's native fetch function. Pass the function into the constructor with proper binding:
pnpm i @fingerprintjs/fingerprintjs-pro-server-api
Getting started
Initialize the client instance and use it to make API requests. You need to specify your Fingerprint Secret API key and the region of your Fingerprint application.
import {
FingerprintJsServerApiClient,
Region,
} from'@fingerprintjs/fingerprintjs-pro-server-api'const client = newFingerprintJsServerApiClient({
apiKey: '<SECRET_API_KEY>',
region: Region.Global,
})
// Get visit history of a specific visitor
client.getVisitorHistory('<visitorId>').then((visitorHistory) => {
console.log(visitorHistory)
})
// Get a specific identification event
client.getEvent('<requestId>').then((event) => {
console.log(event)
})
See the Examples folder for more detailed examples.
Error handling
The Server API methods can throw RequestError.
When handling errors, you can check for it like this:
import {
RequestError,
FingerprintJsServerApiClient,
TooManyRequestsError,
} from'@fingerprintjs/fingerprintjs-pro-server-api'const client = newFingerprintJsServerApiClient({
apiKey: '<SECRET_API_KEY>',
region: Region.Global,
})
// Handling getEvent errorstry {
const event = await client.getEvent(requestId)
console.log(JSON.stringify(event, null, 2))
} catch (error) {
if (error instanceofRequestError) {
console.log(error.responseBody) // Access parsed response bodyconsole.log(error.response) // You can also access the raw responseconsole.log(`error ${error.statusCode}: `, error.message)
} else {
console.log('unknown error: ', error)
}
}
// Handling getVisitorHistory errorstry {
const visitorHistory = await client.getVisitorHistory(visitorId, {
limit: 10,
})
console.log(JSON.stringify(visitorHistory, null, 2))
} catch (error) {
if (error instanceofRequestError) {
console.log(error.status, error.error)
if (error instanceofTooManyRequestsError) {
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...// }
}
Webhooks
Webhook types
When handling Webhooks coming from Fingerprint, you can cast the payload as the built-in VisitWebhook type:
Customers on the Enterprise plan can enable Webhook signatures to cryptographically verify the authenticity of incoming webhooks.
This SDK provides a utility method for verifying the HMAC signature of the incoming webhook request.
Customers on the Enterprise plan can enable Sealed results to receive the full device intelligence result on the client and unseal it on the server. This SDK provides utility methods for decoding sealed results.
To report problems, ask questions, or provide feedback, please use Issues. If you need private support, you can email us at oss-support@fingerprint.com.
The underlying Server API hasn’t changed, but we made SDK type and class generation more precise, resulting in small breaking changes for the SDK itself. This change should make the SDK API a lot more stable going forward
Rename EventUpdateRequest type to EventsUpdateRequest (54b92b2)
Remove the BrowserDetails field botProbability.
Update the IdentificationConfidence field score type format: float -> double.
Make the RawDeviceAttributeError field nameoptional .
Make the RawDeviceAttributeError field messageoptional .
events: Remove the EventsResponse field error.
[note]: The errors are represented by ErrorResponse model.
events: Update the HighActivity field dailyRequests type format: number -> int64.
events: Specify the Tampering field anomalyScore type format: double.
webhook: Make the Webhook fields optional: visitorId, visitorFound, firstSeenAt, lastSeenAt, browserDetails, incognito.
webhook: Make the WebhookClonedApp field resultoptional.
webhook: Make the WebhookDeveloperTools field resultoptional.
webhook: Make the WebhookEmulator field resultoptional.
webhook: Make the WebhookFactoryReset fields time and timestampoptional.
webhook: Make the WebhookFrida field resultoptional.
webhook: Update the WebhookHighActivity field dailyRequests type format: number -> int64.
webhook: Make the WebhookIPBlocklist fields result and detailsoptional.
webhook: Make the WebhookJailbroken field resultoptional.
webhook: Make the WebhookLocationSpoofing field resultoptional.
webhook: Make the WebhookPrivacySettings field resultoptional.
webhook: Make the WebhookProxy field resultoptional.
webhook: Make the WebhookRemoteControl field resultoptional.
webhook: Make the WebhookRootApps field resultoptional.
webhook: Make the WebhookSuspectScore field resultoptional.
webhook: Make the WebhookTampering fields result, anomalyScore and antiDetectBrowseroptional.
webhook: Specify the WebhookTampering field anomalyScore type format: double.
webhook: Make the WebhookTor field resultoptional.
webhook: Make the WebhookVelocity fields optional: distinctIp, distinctLinkedId, distinctCountry, events, ipEvents, distinctIpByLinkedId, distinctVisitorIdByLinkedId.
webhook: Make the WebhookVirtualMachine field resultoptional.
webhook: Make the WebhookVPN fields optional: result, confidence, originTimezone, methods. (68b89bf)
Added new ipEvents, distinctIpByLinkedId, and distinctVisitorIdByLinkedId fields to the velocity Smart Signal. (68b89bf)
Make the GeolocationCity field namerequired.
Make the GeolocationSubdivision field isoCoderequired.
Make the GeolocationSubdivision field namerequired.
Make the IPInfoASN field namerequired .
Make the IPInfoDataCenter field namerequired.
Add optionalIdentificationConfidence field comment.
events: Add optionalBotd field meta.
events: Add optionalIdentification field components.
events: Make the VPN field originCountryrequired.
visitors: Add optionalVisit field components.
webhook: Add optionalWebhook field components. (68b89bf)
Remove ipv4 format from ip field in Botd, Identification, Visit and Webhook models. (b707bfa)
Patch Changes
related-visitors: Add mention that the API is billable (68b89bf)
FAQs
Node.js wrapper for FingerprintJS Sever API
The npm package @fingerprintjs/fingerprintjs-pro-server-api receives a total of 6,231 weekly downloads. As such, @fingerprintjs/fingerprintjs-pro-server-api popularity was classified as popular.
We found that @fingerprintjs/fingerprintjs-pro-server-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.
Package last updated on 20 Nov 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.