const PATHS = {
AGE: "/age-verify",
AGE_LIVENESS: "/age-antispoofing-verify",
};
const data = {
img: "base64img",
threshold: 25,
operator: "OVER",
metadata: {
"device": "mobile"
}
};
const request = new RequestBuilder()
.withBaseUrl('https://api.yoti.com/ai/v1')
.withPemFilePath('<YOTI_KEY_FILE_PATH>')
.withEndpoint(PATHS.AGE_LIVENESS)
.withPayload(new Payload(data))
.withMethod('POST')
.withHeader('X-Yoti-Auth-Id', '<YOTI_CLIENT_SDK_ID>')
.build();
const response = request.execute();
String AGE = "/age-verify";
String AGE_LIVENESS = "/age-antispoofing-verify";
JsonObject metadata = new JsonObject();
metadata.put("device", "mobile");
JsonObject body = new JsonObject();
body.put("img", imageBytes);
body.put("threshold", 25);
body.put("operator", "OVER");
body.put("metadata", metadata);
byte[] payload = body.encode().getBytes();
try {
SignedRequest signedRequest = new SignedRequestBuilder()
.withKeyPair(<YOTI_KEY_FILE_PATH>)
.withBaseUrl("https://api.yoti.com/ai/v1")
.withEndpoint(AGE_LIVENESS)
.withPayload(payload)
.withHttpMethod("POST")
.withHeader("X-Yoti-Auth-Id", "<YOTI_CLIENT_SDK_ID>")
.build();
YourPojo yourPojo = signedRequest.execute(YourPojo.class);
} catch (GeneralSecurityException | URISyntaxException | IOException | ResourceException ex) {
ex.printStackTrace();
}
<?php
use Yoti\Http\RequestBuilder;
use Yoti\Http\Payload;
define("AGE_", "/age-verify");
define("AGE_LIVENESS", "/age-antispoofing-verify");
$data = (object)[
"img" => "base64Image",
"threshold" => 25,
"operator" => "OVER",
"metadata" => (object)[
"device" => "mobile",
]
];
$request = (new RequestBuilder())
->withBaseUrl('https://api.yoti.com/ai/v1')
->withPemFilePath('<YOTI_KEY_FILE_PATH>')
->withEndpoint(AGE_LIVENESS)
->withPayload(Payload::fromJsonData($data)) // For version < 3, use ->withPayload(new Payload($data))
->withMethod('POST')
->withHeader('X-Yoti-Auth-Id', '<YOTI_CLIENT_SDK_ID>')
->build();
// Execute request
$response = $request->execute();
// Get response body
$body = $response->getBody();
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Yoti.Auth.Web;
HttpClient httpClient = new HttpClient();
StreamReader privateKeyStream = System.IO.File.OpenText(_pemFilePath);
string serializedData = Newtonsoft.Json.JsonConvert.SerializeObject(new
{
img = "base64Image",
threshold = 25,
operator = "OVER",
metadata = {
device: "mobile"
}
});
byte[] byteContent = Encoding.UTF8.GetBytes(serializedData);
Uri _baseUrl = new UriBuilder("https", "api.yoti.com", 443, "ai/v1").Uri;
Yoti.Auth.Web.Request ageScanRequest = new RequestBuilder()
.WithStreamReader(privateKeyStream)
.WithBaseUri(_baseUrl)
.WithEndpoint("/age-antispoofing")
.WithHttpMethod(HttpMethod.Post)
.WithContent(byteContent)
.WithHeader("X-Yoti-Auth-Id", _clientSdkId)
.Build();
HttpResponseMessage response = ageScanRequest.Execute(httpClient).Result;
import (
"io/ioutil"
"net/http"
"github.com/getyoti/yoti-go-sdk/v3/requests"
)
data := []byte(`{
"img": "base64img",
"threshold": 25,
"operator": "OVER",
"metadata": {
"device": "mobile",
}
}`)
key, _ := ioutil.ReadFile("<YOTI_KEY_FILE_PATH>")
// Create session
request,_ := requests.SignedRequest{
HTTPMethod: http.MethodPost,
BaseURL: "https://api.yoti.com/ai/v1",
Endpoint: "/age-antispoofing",
Headers: map[string][]string{
"Content-Type": {"application/json"},
"Accept": {"application/json"},
"X-Yoti-Auth-Id":{"<YOTI_CLIENT_SDK_ID>"},
},
Body: data,
}.WithPemFile(key).Request()
//get Yoti response
response, _ := http.DefaultClient.Do(request)
require 'json'
require 'yoti'
Yoti.configure do |config|
config.client_sdk_id = '<YOTI_CLIENT_SDK_ID>'
config.key_file_path = '<YOTI_KEY_FILE_PATH>'
end
data = '{
"img":"base64Image",
"threshold":25,
"operator":"OVER",
"metadata":{
"device":"mobile",
}
}'
request = Yoti::Request
.builder
.with_base_url('https://api.yoti.com/ai/v1')
.with_http_method('POST')
.with_endpoint('/age-antispoofing')
.with_payload(data)
.with_header('X-Yoti-Auth-Id', Yoti.configuration.client_sdk_id)
.build
response = request.execute
body = response.body
puts body