-
Notifications
You must be signed in to change notification settings - Fork 181
Vonage Number Insights V2
Vonage Number Insights V2 • Docs
Documentation / Vonage Number Insights V2
Enum representing the types of insights available for phone number checks.
Enumeration Member | Value | Description | Defined in |
---|---|---|---|
FRAUD_SCORE |
"fraud_score" |
Use this insight to check the fraud score associated with a phone number. | number-insight-v2/lib/enums/insight.ts:8 |
SIM_SWAP |
"sim_swap" |
Use this insight to check if a SIM swap has occurred for a phone number in the last 7 days. | number-insight-v2/lib/enums/insight.ts:13 |
Enum representing the labels for risk scores.
Enumeration Member | Value | Description | Defined in |
---|---|---|---|
HIGH |
"high" |
Represents a high risk score. | number-insight-v2/lib/enums/label.ts:18 |
LOW |
"low" |
Represents a low risk score. | number-insight-v2/lib/enums/label.ts:8 |
MEDIUM |
"medium" |
Represents a medium risk score. | number-insight-v2/lib/enums/label.ts:13 |
Enum representing the recommendations based on risk scores.
Enumeration Member | Value | Description | Defined in |
---|---|---|---|
ALLOW |
"allow" |
Indicates that it is recommended to allow the action based on the risk score. | number-insight-v2/lib/enums/riskRecommendation.ts:8 |
BLOCK |
"block" |
Indicates that it is recommended to block the action based on the risk score. | number-insight-v2/lib/enums/riskRecommendation.ts:18 |
FLAG |
"flag" |
Indicates that it is recommended to flag the action based on the risk score. | number-insight-v2/lib/enums/riskRecommendation.ts:13 |
Enum representing the possible status values for an operation.
Enumeration Member | Value | Description | Defined in |
---|---|---|---|
COMPLETED |
"completed" |
Indicates that the operation has been completed successfully. | number-insight-v2/lib/enums/status.ts:8 |
FAILED |
"failed" |
Indicates that the operation has failed. | number-insight-v2/lib/enums/status.ts:13 |
Number Insight v2 is designed to give fraud scores for Application Integrations. This class represents the client for making fraud check requests.
new NumberInsightV2(credentials, options?): NumberInsightV2
Creates a new instance of the Client.
• credentials: AuthInterface
| AuthParams
The authentication credentials or an authentication instance.
• options?: ConfigParams
Optional configuration settings for the client.
server-client/dist/lib/client.d.ts:35
protected auth: AuthInterface;
The authentication instance responsible for generating authentication headers and query parameters.
server-client/dist/lib/client.d.ts:24
protected authType: AuthenticationType = AuthenticationType.BASIC;
The type of authentication used for the client's requests.
number-insight-v2/lib/numberInsightV2.ts:9
protected config: ConfigParams;
Configuration settings for the client, including default hosts for various services and other request settings.
server-client/dist/lib/client.d.ts:28
static transformers: object;
Static property containing utility transformers.
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys: PartialTransformFunction;
omit: (keys, obj) => TransformedObject;
• keys: string
[]
• obj: ObjectToTransform
snakeCaseObjectKeys: PartialTransformFunction;
server-client/dist/lib/client.d.ts:11
addAuthenticationToRequest(request): Promise<VetchOptions>
Adds the appropriate authentication headers or parameters to the request based on the authentication type.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addAuthenticationToRequest
server-client/dist/lib/client.d.ts:43
protected addBasicAuthToRequest(request): Promise<VetchOptions>
Adds basic authentication headers to the request.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
server-client/dist/lib/client.d.ts:71
protected addJWTToRequest(request): Promise<VetchOptions>
Adds a JWT to the request.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
server-client/dist/lib/client.d.ts:64
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>
Adds API key and secret to the request.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addQueryKeySecretToRequest
server-client/dist/lib/client.d.ts:57
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>
Adds API key and secret to the request body.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addQueryKeySecretToRequestBody
server-client/dist/lib/client.d.ts:50
checkForFraud(params): Promise<FraudCheck>
Make a fraud check request with the provided parameters.
• params: FraudCheckParameters
The parameters for the fraud check request.
Promise
<FraudCheck
>
- A Promise that resolves with the fraud score response.
Check for fraud on a phone number.
import { Insight } from '@vonage/number-insight-v2';
const score = await client.numberInsightV2.checkForFraud({
type: 'phone',
number: '447700900000',
insights: [
Insight.FRAUD_SCORE,
],
});
console.log(`Fraud score: ${score.riskScore}`);
Check for SIM swap on a phone number.
import { Insight } from '@vonage/number-insight-v2';
const score = await client.numberInsightV2.checkForFraud({
type: 'phone',
number: '447700900000',
insights: [
Insight.SIM_SWAP,
],
});
console.log(`SIM swap detected: ${score.simSwap ? 'Yes' : 'No'}`);
Check both fraud score and SIM swap on a phone number.
import { Insight } from '@vonage/number-insight-v2';
const score = await client.numberInsightV2.checkForFraud({
type: 'phone',
number: '447700900000',
insights: [
Insight.SIM_SWAP,
Insight.FRAUD_SCORE,
],
});
console.log(`SIM swap detected: ${score.simSwap ? 'Yes' : 'No'}`);
console.log(`Fraud score: ${score.riskScore}`);
number-insight-v2/lib/numberInsightV2.ts:60
getConfig(): ConfigParams
server-client/dist/lib/client.d.ts:36
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>
Parses the response based on its content type.
• T
The expected type of the parsed response data.
• request: VetchOptions
The request options.
• response: Response
The raw response from the request.
Promise
<VetchResponse
<T
>>
- The parsed response.
server-client/dist/lib/client.d.ts:168
protected prepareBody(request): undefined | string
Prepares the body for the request based on the content type.
• request: VetchOptions
The request options.
undefined
| string
- The prepared request body as a string or undefined.
server-client/dist/lib/client.d.ts:158
protected prepareRequest(request): Promise<VetchOptions>
Prepares the request with necessary headers, authentication, and query parameters.
• request: VetchOptions
The initial request options.
Promise
<VetchOptions
>
- The modified request options.
server-client/dist/lib/client.d.ts:151
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>
Sends a DELETE request to the specified URL.
• T
• url: string
The URL endpoint for the DELETE request.
Promise
<VetchResponse
<T
>>
- The response from the DELETE request.
server-client/dist/lib/client.d.ts:78
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a POST request with form data to the specified URL.
• T
• url: string
The URL endpoint for the POST request.
• payload?: Record
<string
, undefined
| string
>
Optional payload containing form data to send with the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
server-client/dist/lib/client.d.ts:86
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>
Sends a GET request to the specified URL with optional query parameters.
• T
• url: string
The URL endpoint for the GET request.
• queryParams?
Optional query parameters to append to the URL. These should be compatible with Node's URLSearchParams.
Promise
<VetchResponse
<T
>>
- The response from the GET request.
server-client/dist/lib/client.d.ts:94
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a PATCH request to the specified URL with an optional payload.
• T
• url: string
The URL endpoint for the PATCH request.
• payload?
Optional payload to be sent as the body of the PATCH request.
Promise
<VetchResponse
<T
>>
- The response from the PATCH request.
server-client/dist/lib/client.d.ts:104
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a POST request to the specified URL with an optional payload.
• T
• url: string
The URL endpoint for the POST request.
• payload?
Optional payload to be sent as the body of the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
server-client/dist/lib/client.d.ts:114
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a PUT request to the specified URL with an optional payload.
• T
• url: string
The URL endpoint for the PUT request.
• payload?
Optional payload to be sent as the body of the PUT request.
Promise
<VetchResponse
<T
>>
- The response from the PUT request.
server-client/dist/lib/client.d.ts:124
sendRequest<T>(request): Promise<VetchResponse<T>>
Sends a request adding necessary headers, handling authentication, and parsing the response.
• T
• request: VetchOptions
The options defining the request, including URL, method, headers, and data.
Promise
<VetchResponse
<T
>>
- The parsed response from the request.
server-client/dist/lib/client.d.ts:144
sendRequestWithData<T>(
method,
url,
payload?): Promise<VetchResponse<T>>
Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.
• T
• method: POST
| PUT
| PATCH
The HTTP method to be used for the request (only POST, PATCH, or PUT are acceptable).
• url: string
The URL endpoint for the request.
• payload?
Optional payload to be sent as the body of the request, JSON-encoded.
Promise
<VetchResponse
<T
>>
- The response from the request.
server-client/dist/lib/client.d.ts:135
type FraudCheck: object;
Represents the result of a fraud check request.
optional fraudScore: FraudScore;
The result of the 'fraud_score' insight operation (optional).
phone: PhoneInfo;
An object containing information about the phone number used in the fraud check operation(s).
requestId: string;
Unique UUID for this request for reference.
optional simSwap: SimSwap;
The result of the 'sim_swap' insight operation (optional).
type: "phone";
The type of lookup used in the request. Currently always 'phone'.
number-insight-v2/lib/types/fraudCheck.ts:8
type FraudCheckParameters: object;
Represents the parameters for making a fraud check request.
insights: Insight[];
The insight(s) you need, at least one of: 'fraud_score' and 'sim_swap'.
phone: string;
A single phone number that you need insight about in the E.164 format. Don't use a leading + or 00 when entering a phone number, start with the country code, e.g., 447700900000.
type: "phone";
The type of lookup used in the request. Currently always 'phone'.
number-insight-v2/lib/types/parameters/fraudParameters.ts:6
type FraudCheckRequest: object;
Represents a fraud check request.
insights: Insight[];
The insight(s) you need, at least one of: 'fraud_score' and 'sim_swap'.
phone: string;
A single phone number that you need insight about in the E.164 format. Don't use a leading + or 00 when entering a phone number, start with the country code, e.g., 447700900000.
type: "phone";
The type of lookup used in the request. Currently always 'phone'.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
number-insight-v2/lib/types/requests/fraudCheckRequest.ts:10
type FraudCheckResponse: object & Omit<FraudCheck, "requestId" | "fraudScore" | "simSwap">;
Represents the response from a fraud check request.
fraud_score: FraudScoreResponse;
The response data for the 'fraud_score' insight operation.
request_id: string;
Unique UUID for this request for reference.
sim_swap: SimSwap;
The response data for the 'sim_swap' insight operation.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
number-insight-v2/lib/types/responses/fraudCheckResponse.ts:12
type FraudScore: object;
Represents the result of the fraud_score insight operation.
label: Label;
Mapping of risk score to a verbose description. Must be one of the values from the 'Label' enum.
riskRecommendation: RiskRecommendation;
Recommended action based on the riskScore. Must be one of the values from the 'RiskRecommendation' enum.
riskScore: string;
Score derived from evaluating fraud-related data associated with the phone number.
status: Status;
The status of the fraud_score call. Must be one of the values from the 'Status' enum.
number-insight-v2/lib/types/fraudScore.ts:6
type FraudScoreResponse: object & Omit<FraudScore, "riskRecommendation" | "riskScore">;
Represents the response data for the 'fraud_score' insight operation.
risk_recommendation: RiskRecommendation;
Recommended action based on the risk_score. Must be one of the values from the 'RiskRecommendation' enum.
risk_score: string;
Score derived from evaluating fraud-related data associated with the phone number.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
number-insight-v2/lib/types/responses/fraudScoreResponse.ts:11
type PhoneInfo: object;
Represents information about a phone number.
optional carrier: string;
The name of the network carrier (optional). Included if insights included 'fraud_score'.
phone: string;
The phone number.
optional type: string;
Type of phone (optional). Examples include Mobile, Landline, VOIP, PrePaid, Personal, Toll-Free. Included if insights included 'fraud_score'.
number-insight-v2/lib/types/phoneInfo.ts:4
type SimSwap: object;
Represents the result of the sim_swap insight operation.
optional reason: string;
The reason for a sim swap error response. Returned only if the sim swap check fails.
status: Status;
The status of the sim_swap call. Must be one of the values from the 'Status' enum.
optional swapped: boolean;
true if the sim was swapped in the last 7 days, false otherwise. Returned only if the sim swap check succeeds.