Get age estimation

AI Tools

Below are the end points and integration configuration you need to integrate.

Before you start
You will need the Yoti App on your phone and to have registered your business with Yoti.

The image requirements to use Age Scan are:

  • Yoti only accepts JPEG’s encoded as a base64 image

  • Base64 body must be below 100KB (~70KB JPEG)

  • The minimum face dimensions we accept is 96 x 96 pixels

Get Age Estimation

After completing the Yoti onboarding, you will need to complete authentication for the API by using the Yoti SDK to simplify the process for requesting to Yoti. The Yoti SDKs are available via popular dependency management systems. Further details can be found on the pages of the specific projects.

npm install -S -E yoti
// Get the Yoti PHP SDK library via a Composer package composer require yoti/yoti-php-sdk
pip install yoti
// If you are using Maven, add the following dependency: <dependency> <groupId>com.yoti</groupId> <artifactId>yoti-sdk-impl</artifactId> <version>2.6.0</version> </dependency> // If you are using Gradle, add the following dependency: compile group: 'com.yoti', name: 'yoti-sdk-impl', version: '2.6.0'
// As of version 2.4.0, modules are used. This means it's not necessary to get a copy or fetch all dependencies // as instructed below, as the Go toolchain will fetch them as necessary. // You can simply add a `require github.com/getyoti/yoti-go-sdk/v2` to go.mod. // To download and install the Yoti SDK and its dependencies, run the following command from your terminal: go get "github.com/getyoti/yoti-go-sdk/v2"
// To install the Yoti NuGet package you will need to install NuGet. // To import the latest Yoti SDK into your project, enter the following // command from NuGet Package Manager Console in Visual Studio: Install-Package Yoti // For other installation methods, see https://www.nuget.org/packages/Yoti
gem install yoti # The gem provides a configuration generator for Ruby on Rails: rails generate yoti:install

Once you have added the Yoti SDK dependency to your project, you can use it to build and send your request. See the code snippets below for examples.

const { RequestBuilder, Payload } = require('yoti'); const request = new RequestBuilder() .withBaseUrl('https://api.yoti.com/api/v1/age-verification') .withPemFilePath('<YOTI_KEY_FILE_PATH>') .withEndpoint('/checks') .withPayload(new Payload(data)) .withMethod('POST') .withHeader('X-Yoti-Auth-Id', '<YOTI_CLIENT_SDK_ID>') .build(); //get Yoti response const response = request.execute();
<?php use Yoti\Http\RequestBuilder; use Yoti\Http\Payload; $data = [ "data" => "base64Image" ]; $request = (new RequestBuilder()) ->withBaseUrl('https://api.yoti.com/api/v1/age-verification') ->withPemFilePath('<YOTI_KEY_FILE_PATH>') ->withEndpoint('/checks') ->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();
from yoti_python_sdk.http import SignedRequest, RequestHandler import json import requests def execute(request): response = requests.request( url=request.url, data=request.data, headers=request.headers, method=request.method) return response.content def generate_session(): payload_string = json.dumps(data).encode() signed_request = ( SignedRequest .builder() .with_pem_file("<YOTI_KEY_FILE_PATH>") .with_base_url("https://api.yoti.com/api/v1/age-verification") .with_endpoint("/checks") .with_http_method("POST") .with_header("X-Yoti-Auth-Id", "<YOTI_CLIENT_SDK_ID>") .with_payload(payload_string) .build() ) # get Yoti response response = signed_request.execute() response_payload = json.loads(response.text)
byte[] payload = ... try { SignedRequest signedRequest = SignedRequestBuilder.newInstance() .withKeyPair(<YOTI_KEY_FILE_PATH>) .withBaseUrl("https://api.yoti.com/api/v1/age-verification") .withEndpoint("/checks") .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(); }
import ( "io/ioutil" "net/http" "github.com/getyoti/yoti-go-sdk/v2/requests" ) key, _ := ioutil.ReadFile("<YOTI_KEY_FILE_PATH>") // Create session request, _ := requests.SignedRequest{ HTTPMethod: http.MethodPost, BaseURL: "https://api.yoti.com/api/v1/age-verification", Endpoint: "/checks", Headers: map[string][]string{ "Content-Type": {"application/json"}, "Accept": {"application/json"}, "X-Yoti-Auth-Id":{"<YOTI_CLIENT_SDK_ID>"}, }, Body: func(data []byte, _ error) []byte { return data }(json.Marshal(jsonobj{ data }, })), }.WithPemFile(key).Request() //get Yoti response response, _ := http.DefaultClient.Do(request)
// COMING SOON
// Coming Soon

The request payload should be in the following format: This JSON string will be the data parameter in the withPayload above code snippet.

{ "data": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wAcHNXCKigjEaYH51Me1Zy1Za0P/Z....", }
API Link
Jump straight to our API references with code snippets if you prefer.

Example responses

The response received from the API will be below:

The uncertainty value is a confidence score. Yoti recommends rejecting any response with an uncertainty greater than 6.0. Typically this indicates a problem with image capture.

{ "pred_age": 29.7475, "uncertainty": 2.04677 }