import { FingerprintJsServerApiClient, Region } from'@fingerprintjs/fingerprintjs-pro-server-api';
// Init client with the given region and the secret api_keyconst client = newFingerprintJsServerApiClient({region: Region.Global, apiKey: "<api_key>"});
// Get visitor history
client.getVisitorHistory("<visitorId>").then(visitorHistory => {
console.log(visitorHistory);
});
This SDK might be also compatible, however not actively tested, 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:
Gets history for the given visitor and given filter, returns a promise with visitor history response.
Usage
client.getVisitorHistory("<visitorId>", filter)
.then(visitorHistory => {
console.log(visitorHistory);
})
.catch(error => {
if (error.status === 403) {
console.log(error.error);
} elseif (error.status === 429) {
retryLater(error.retryAfter); // this function needs to be implemented on your side
}
});
Params
visitorId: string - identifier of the visitor
filter?: VisitorHistoryFilter - visitor history filter, more info in the API documentation
Returns
Promise<VisitorsResponse> - promise with visitor history response
Every identification request has a unique identifier associated with it called requestId. This identifier is returned to the client in the identification result. When you filter visits by requestId, only one visit will be returned.
linked_id: string - filter visits by your custom identifier.
You can use linkedId to associate identification requests with your own identifier, for example: session ID, purchase ID, or transaction ID. You can then use this linked_id parameter to retrieve all events associated with your custom identifier.
limit: number - limit scanned results.
For performance reasons, the API first scans some number of events before filtering them. Use limit to specify how many events are scanned before they are filtered by requestId or linkedId. Results are always returned sorted by the timestamp (most recent first). By default, the most recent 100 visits are scanned, the maximum is 500.
paginationKey: string - use paginationKey to get the next page of results.
When more results are available (e.g., you requested 200 results using limit parameter, but a total of 600 results are available), the paginationKey top-level attribute is added to the response. The key corresponds to the requestId of the last returned event. In the following request, use that value in the paginationKey parameter to get the next page of results:
First request, returning most recent 200 events: GET api-base-url/visitors/:visitorId?limit=200
Use response.paginationKey to get the next page of results: GET api-base-url/visitors/:visitorId?limit=200&paginationKey=1683900801733.Ogvu1j
Pagination happens during scanning and before filtering, so you can get less visits than the limit you specified with more available on the next page. When there are no more results available for scanning, the paginationKey attribute is not returned.
{"visitorId":"Ibk1527CUFmcnjLwIs4A9","visits":[{"requestId":"0KSh65EnVoB85JBmloQK","incognito":true,"linkedId":"somelinkedId","time":"2019-05-21T16:40:13Z",// timestamp of the event with millisecond precision"timestamp":1582299576512,"url":"https://www.example.com/login","ip":"61.127.217.15","ipLocation":{"accuracyRadius":10,"latitude":49.982,"longitude":36.2566,"postalCode":"61202","timezone":"Europe/Dusseldorf","city":{"name":"Dusseldorf"},"continent":{"code":"EU","name":"Europe"},"country":{"code":"DE","name":"Germany"},"subdivisions":[{"isoCode":"63","name":"North Rhine-Westphalia"}]},"browserDetails":{"browserName":"Chrome","browserMajorVersion":"74","browserFullVersion":"74.0.3729","os":"Windows","osVersion":"7","device":"Other","userAgent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) ....",},"confidence":{"score":0.97},"visitorFound":true,"firstSeenAt":{"global":"2022-03-16T11:26:45.362Z","subscription":"2022-03-16T11:31:01.101Z"},"lastSeenAt":{"global":"2022-03-16T11:28:34.023Z","subscription":null}}],// optional, if more results are available for pagination."lastTimestamp":1582299576512}
{"products":{"identification":{"data":{"visitorId":"Ibk1527CUFmcnjLwIs4A9","requestId":"0KSh65EnVoB85JBmloQK","incognito":true,"linkedId":"somelinkedId","time":"2019-05-21T16:40:13Z","timestamp":1582299576512,"url":"https://www.example.com/login","ip":"61.127.217.15","ipLocation":{"accuracyRadius":10,"latitude":49.982,"longitude":36.2566,"postalCode":"61202","timezone":"Europe/Dusseldorf","city":{"name":"Dusseldorf"},"continent":{"code":"EU","name":"Europe"},"country":{"code":"DE","name":"Germany"},"subdivisions":[{"isoCode":"63","name":"North Rhine-Westphalia"}],},"browserDetails":{"browserName":"Chrome","browserMajorVersion":"74","browserFullVersion":"74.0.3729","os":"Windows","osVersion":"7","device":"Other","userAgent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) ....",},"confidence":{"score":0.97},"visitorFound":true,"firstSeenAt":{"global":"2022-03-16T11:26:45.362Z","subscription":"2022-03-16T11:31:01.101Z"},"lastSeenAt":{"global":"2022-03-16T11:28:34.023Z","subscription":null}}},"botd":{"data":{"bot":{"result":"notDetected"},"url":"https://example.com/login","ip":"61.127.217.15","time":"2019-05-21T16:40:13Z"}}}}
Using with TypeScript
getEvent and getVisitorHistory methods return generic types Promise<EventResponse> and Promise<VisitorsResponse> and throw EventError and VisitorsError.
You can use typeguards to narrow error types as in example below.
import { isVisitorsError, isEventError } from'@fingerprintjs/fingerprintjs-pro-server-api';
client
.getVisitorHistory("<visitorId>", filter)
.then(result =>console.log(result))
.catch(err => {
if (isVisitorsError(err)) {
if (err.code === 429) {
// VisitorsError429 typeretryLater(err.retryAfter); // this function needs to be implemented on your side
} else {
console.log('error: ', err.error)
}
} else {
console.log('unknown error: ', err)
}
});
client
.getEvent("<requestId>")
.then(result =>console.log(result))
.catch(err => {
if (isEventError(err)) {
console.log(`error ${err.code}: `, err.error.message)
} else {
console.log('unknown error: ', err)
}
});
The npm package @fingerprintjs/fingerprintjs-pro-server-api receives a total of 4,194 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 31 Jul 2023
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.
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
By Kirill Boychenko, Peter van der Zee - Jan 29, 2025