Class: Scanner

Scanner(apiKeyopt)

Scanner API client. Initiates identity document scans (full KYC scan, plus quick/very-quick OCR-only variants), and configures verification, document restrictions and contract generation for the scan.

Constructor

new Scanner(apiKeyopt)

Create a new Scanner API client.
Parameters:
Name Type Attributes Default Description
apiKey string | null <optional>
null Your API key. If omitted, the `IDANALYZER_KEY` environment variable is used.
Source:

Extends

Methods

getApiKey(customKeyopt) → {string|null}

Resolve the API key, preferring the provided value and falling back to the `IDANALYZER_KEY` environment variable.
Parameters:
Name Type Attributes Default Description
customKey string | null <optional>
null Explicitly supplied API key.
Overrides:
Source:
Returns:
The resolved API key, or `null` if none is available.
Type
string | null

(async) quickScan(documentFrontopt, documentBackopt, cacheImageopt) → {Promise.<ApiResponse>}

Initiate a quick identity document OCR scan by providing input images.
Parameters:
Name Type Attributes Default Description
documentFront string <optional>
"" Front of Document (file path, base64 content or URL).
documentBack string <optional>
"" Back of Document (file path, base64 content or URL).
cacheImage boolean <optional>
false Cache uploaded image(s) for 24 hours and obtain a cache reference for each image; the reference hash can be used to start a standard scan transaction without re-uploading the file.
Source:
Throws:
If `documentFront` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>

restrictCountry(countryCodesopt) → {void}

Check if the document was issued by specified countries. Separate multiple values with comma. For example "US,CA" would accept documents from the United States and Canada.
Parameters:
Name Type Attributes Default Description
countryCodes string <optional>
"US,CA,UK" ISO ALPHA-2 Country Code separated by comma.
Source:
Returns:
Type
void

restrictState(statesopt) → {void}

Check if the document was issued by specified state. Separate multiple values with comma. For example "CA,TX" would accept documents from California and Texas.
Parameters:
Name Type Attributes Default Description
states string <optional>
'CA,TX' State full name or abbreviation separated by comma.
Source:
Returns:
Type
void

restrictType(documentTypeopt) → {void}

Check if the document was one of the specified types. For example, "PD" would accept both passport and driver license.
Parameters:
Name Type Attributes Default Description
documentType string <optional>
'DIP' P: Passport, D: Driver's License, I: Identity Card.
Source:
Returns:
Type
void

(async) scan(documentFrontopt, documentBackopt, facePhotoopt, faceVideoopt) → {Promise.<ApiResponse>}

Initiate a new identity document scan & ID face verification transaction by providing input images.
Parameters:
Name Type Attributes Default Description
documentFront string <optional>
"" Front of Document (file path, base64 content, URL, or cache reference).
documentBack string <optional>
"" Back of Document (file path, base64 content or URL, or cache reference).
facePhoto string <optional>
"" Face Photo (file path, base64 content or URL, or cache reference). Provide either this or `faceVideo`.
faceVideo string <optional>
"" Face Video (file path, base64 content or URL). Used if `facePhoto` is empty.
Source:
Throws:
If no profile is configured or `documentFront` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>

setContractOptions(templateIdopt, _formatopt, extraFillDataopt) → {void}

Automatically generate contract document using value parsed from uploaded ID
Parameters:
Name Type Attributes Default Description
templateId string <optional>
"" Up to 5 contract template IDs (separated by comma). Pass an empty string to disable contract generation.
_format string <optional>
"PDF" Output format: PDF, DOCX or HTML.
extraFillData Object.<string, *> | null <optional>
null Key-value pairs to autofill dynamic fields. Data from the user ID is used first in case of a conflict. For example, passing `{"myparameter":"abc"}` would fill `%{myparameter}` in the contract template with "abc".
Source:
Returns:
Type
void

setCustomData(customData) → {void}

Set an arbitrary string you wish to save with the transaction. e.g Internal customer reference number
Parameters:
Name Type Description
customData string Arbitrary string to store alongside the transaction.
Source:
Returns:
Type
void

setParam(key, value) → {void}

Set an API parameter and its value, this function allows you to set any API parameter without using the built-in functions
Parameters:
Name Type Description
key string Parameter key
value * Parameter value
Overrides:
Source:
Returns:
Type
void

setProfile(profile) → {void}

Set KYC Profile
Parameters:
Name Type Description
profile Profile KYC Profile object.
Source:
Throws:
If `profile` is not a Profile instance.
Type
InvalidArgumentException
Returns:
Type
void

setUserIp(ip) → {void}

Pass in user IP address to check if ID is issued from the same country as the IP address, if no value is provided http connection IP will be used.
Parameters:
Name Type Description
ip string User IP address. If empty, the HTTP connection IP is used.
Source:
Returns:
Type
void

throwApiException(swopt) → {void}

Whether an exception should be thrown if API response contains an error message
Parameters:
Name Type Attributes Default Description
sw boolean <optional>
false Set to `true` to throw an APIError when the API response contains an error, or `false` to return the raw error response instead.
Overrides:
Source:
Returns:
Type
void

verifyUserInformation(documentNumberopt, fullNameopt, dobopt, ageRangeopt, addressopt, postcodeopt) → {void}

Check if customer information matches with uploaded document
Parameters:
Name Type Attributes Default Description
documentNumber string <optional>
"" Document or ID number.
fullName string <optional>
"" Full name.
dob string <optional>
"" Date of birth in YYYY/MM/DD.
ageRange string <optional>
"" Age range, example: 18-40.
address string <optional>
"" Address.
postcode string <optional>
"" Postcode.
Source:
Throws:
If `dob` is not in YYYY/MM/DD format or `ageRange` is not in minAge-maxAge format.
Type
InvalidArgumentException
Returns:
Type
void

(async) veryQuickScan(documentFrontopt, documentBackopt, cacheImageopt) → {Promise.<ApiResponse>}

Initiate a very quick (fast) identity document OCR scan by providing input images. Faster but less thorough than quickScan, useful for high-throughput OCR-only use cases.
Parameters:
Name Type Attributes Default Description
documentFront string <optional>
"" Front of Document (file path, base64 content or URL).
documentBack string <optional>
"" Back of Document (file path, base64 content or URL).
cacheImage boolean <optional>
false Cache uploaded image(s) for 24 hours and obtain a cache reference for each image; the reference hash can be used to start a standard scan transaction without re-uploading the file.
Source:
Throws:
If `documentFront` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>