This reference documents every object and method available in Perse's browser-side Javascript library, Perse.js.
You can use Perse's APIs to detect faces, gather feedback on image quality and compare the similarity between two faces. This SDK provides methods that help you authenticate users identity and directly communicate with Perse's API endpoints. The SDK also abstracts away the usage of common cases.
In order to use PerseJs, it's necessary to create a session token using your private key.
The session token can be created by using your Perse's private key(opens new window) on server side and
making a POST request to https://api.getperse.com/v0/login. Some frontend SSR frameworks and applications, as nuxt
and next.js, provides a way to safely request and refresh session token. If it fits your use case, consult your framework
documentation to don't expose any sensitive data to client.
Your private key should be on body, inside privateKey.
{
"privateKey": "YOUR_PRIVATE_KEY"
}
Pay Attention: It's important to notice that the session token returned by /login expires in 15 minutes,
so it's necessary to set JWT token again.
content_type_header_missin
The request header is missing the content-type key with the value of multipart/form-data.
no_face_detecte
The model could not find a face in at least one of the images. Please check the property image_metrics for insight on the image quality.
empty_fil
The source file is empty or not sent.
invalid_file_typ
The image file type is not accepted by API.
form_key_missing
The request is missing: image file(s) or token
file_too_larg
The source file byte size is too large. Please send image files with less than 1 MB.
not_simila
Person on sent images has low similarity value.
bad_image_qualit
Image has a bad quality. It is overexposed, underexposed or not sharpened.
image_underexposed - Enrollment onl
The image file received is too underexposed and could not be used for enrollment.
image_overexposed - Enrollment onl
The image file received is too overexposed and could not be used for enrollment.
user_token_not_foun
User token does not exist on backend.
image_id_invali
User token was not found on update.
no_face_biometric_dat
User token was not found when comparing image with userToken.
unauthorized
JWT token expired or not valid.
{"message":"The source file is empty or wasn't sent.","code":"empty_file","status":false}
In order to use Perse SDK, it's necessary to ask end user for consent and inform it inside enduserConsent parameter. Informing end user consent is required for every endpoints that uses biometric data.
If consent is false, the request will not be processed.
NPM is the recommended installation method when building large scale applications with Perse. It pairs nicely with module bundlers such as Webpack or Browserify.
To get started you should use Perse.setToken(JWT_TOKEN) on Perse object.
The Perse object gives you access to all Perse.js SDK methods. As explained on token it's necessary to
update the JWT token every 15 minutes.
When JWT expires, Perse's methods return an 'anauthorized' error code. So it's necessary to
fetch a new token from backend