ID Analyzer Developer ID Analyzer Developer
  • Home
  • Portal
  • Support
ID Analyzer Developer ID Analyzer Developer
ID Analyzer Developer
  • Home
  • Portal
  • Support
  • Home
  • Core API
    • Overview
    • Quick Start
    • API Reference
  • DocuPass API
    • Overview
    • Quick Start
    • API Reference
  • Vault API
    • Overview
    • Quick Start
    • API Reference
  • AML API
    • Overview
    • Quick Start
    • API Reference
  • Client Library
    • PHP
    • .NET
    • NodeJS
    • Python
  • Guide
    • Web-based ID Scanner
    • DocuPass Custom UI Design
  • Change Log
  • ID Fort On-Premise

Core API Quick Start Guide

This guide demonstrates the use of ID Analyzer client libraries, if you prefer to proceed without client library or if client library is not available for your language, please continue to Core API Reference.

Installing Client Library (SDK)

It is recommended to install ID Analyzer client library with package managers.

    composer require idanalyzer/id-analyzer-php-sdk
    Install-Package IDAnalyzer
    npm install idanalyzer
    pip install idanalyzer

    Alternatively, you may download the client library and include it in your project manually:

    Download PHP Client Library Repository
    Download .NET Client Library Repository
    Download NodeJS Client Library Repository
    Download Python Client Library Repository

    Start Coding

    Import ID Analyzer Client Library

    To start, import ID Analyzer client library into your project.

      // Use composer autoload
      require("vendor/autoload.php");
      
      // Or manually load CoreAPI class
      // require("../src/CoreAPI.php");
      
      use IDAnalyzer\CoreAPI; 
      using IDAnalyzer;
      const IDAnalyzer = require("idanalyzer");  
      import idanalyzer
      Prepare Documents

      Before continuing, you need to prepare some samples documents and selfie photo, or download a sample of California Driving License and photo of Lena to the same directory as your project.

      Initialize Core API

      The very first step is to initialize Core API object with your API Key, you can also set whether you want to use US or EU API server.

      $coreapi = new CoreAPI("Your API Key", "US");  
      CoreAPI coreapi = new CoreAPI("Your API Key", "US");
      let CoreAPI = new IDAnalyzer.CoreAPI("Your API Key","US");
      coreapi = idanalyzer.CoreAPI("Your API Key", "US")
      
      Configure Scan Options

      Core API by default only extract document and document holder information, you need to set additional options for Core API to perform extra validations and features.

      To check if a document is real and authentic, we will enable authentication module.

      $coreapi->enableAuthentication(true, '2');
      coreapi.EnableAuthentication(true, "2");
      CoreAPI.enableAuthentication(true, "2");
      coreapi.enable_authentication(True, '2')

      We will also check that the document has not expired.

      $coreapi->checkExpiry(true);
      coreapi.CheckExpiry(true);
      CoreAPI.checkExpiry(true);
      coreapi.check_expiry(True)

      If you are a financial institution, you may want perform AML/PEP compliance check.

      $coreapi->enableAMLCheck(true);
      coreapi.EnableAMLCheck(true);
      CoreAPI.enableAMLCheck(true);
      coreapi.enable_aml_check(True)

      If you want to use paperwork automation feature to automatically fill and generate a contract or any kind of printable document.

      $coreapi->generateContract("Template ID", "PDF");
      coreapi.GenerateContract("Template ID", "PDF");
      CoreAPI.generateContract("Template ID", "PDF");
      coreapi.generate_contract("Template ID", "PDF")
      Perform Scan

      We are now ready to send the document image and face image to Core API and get the results.

      $result = $coreapi->scan("sampleid1.jpg","","lena.jpg");
      JObject result = await coreapi.Scan("sampleid1.jpg", "", "lena.jpg");
      
      let response = await CoreAPI.scan({ document_primary: "sampleid1.jpg", biometric_photo: "lena.jpg" });
      response = coreapi.scan(document_primary="sampleid1.jpg", biometric_photo="lena.jpg")
      

      Core API returns result as an object/array, you can check the sample response structure in Core API Reference. Once you receive the result from Core API, you can further process it per your own requirements.

      The sample code below will print the document holder's name, authentication result and face verification result.

      // All information about this ID will be returned in an associative array
      $data_result = $result['result'];
      $authentication_result = $result['authentication'];
      $face_result = $result['face'];
      
      // Print document holder name
      echo("Hello your name is {$data_result['firstName']} {$data_result['lastName']}. ");
      
      // Parse document authentication results
      if($authentication_result){
          if($authentication_result['score'] > 0.5) {
              echo("The document uploaded is authentic. ");
          }else if($authentication_result['score'] > 0.3){
              echo("The document uploaded looks little bit suspicious. ");
          }else{
              echo("The document uploaded is fake. ");
          }
      }
      // Parse face verification results
      if($face_result){
          if($face_result['error']){
              // View complete error codes under API reference: https://developer.idanalyzer.com/coreapi.html
              echo("Face verification failed! Code: {$face_result['error']}, Reason: {$face_result['error_message']}. ");
          }else{
              if($face_result['isIdentical'] === true){
                  echo("Great! Your photo looks identical to the photo on document. ");
              }else{
                  echo("Oh no! Your photo looks different to the photo on document. ");
              }
              echo("Similarity score: {$face_result['confidence']}. ");
          }
      }
      // Print document holder name
      Console.WriteLine(String.Format("Hello your name is {0} {1}", (string)result.SelectToken("result.firstName"), (string)result.SelectToken("result.lastName")));
      
      // Parse document authentication results
      if (result.ContainsKey("authentication")){
          if ((double)result.SelectToken("authentication.score") > 0.5) {
              Console.WriteLine("The document uploaded is authentic");
          }else if ((double)result.SelectToken("authentication.score") > 0.3){
              Console.WriteLine("The document uploaded looks little bit suspicious");
          }else
          {
              Console.WriteLine("The document uploaded is fake");
          }
      }
      // Parse face verification results
      if (result.ContainsKey("face")){
          if (result.SelectToken("face.error") != null){
              // View complete error codes under API reference: https://developer.idanalyzer.com/coreapi.html
              Console.WriteLine(String.Format("Face verification failed! Code: {0}, Reason: {1}", (string)result.SelectToken("face.error"), (string)result.SelectToken("face.error_message")));
          }else
          {
              if ((bool)result.SelectToken("face.isIdentical") == true){
                  Console.WriteLine("Great! Your photo looks identical to the photo on document");
              }else
              {
                  Console.WriteLine("Oh no! Your photo looks different to the photo on document");
              }
              Console.WriteLine(String.Format("Similarity score: {0}", (string)result.SelectToken("face.confidence")));
          }
      }
      
       let data_result = response['result'];
      let authentication_result = response['authentication'];
      let face_result = response['face'];
      
      // Print document holder name
      console.log(`Hello your name is ${data_result['firstName']} ${data_result['lastName']}`);
      
      // Parse document authentication results
      if(authentication_result){
          if(authentication_result['score'] > 0.5) {
              console.log("The document uploaded is authentic");
          }else if(authentication_result['score'] > 0.3){
              console.log("The document uploaded looks little bit suspicious");
          }else{
              console.log("The document uploaded is fake");
          }
      }
      // Parse biometric verification results
      if(face_result){
          if(face_result['isIdentical']) {
              console.log("Biometric verification PASSED!");
          }else{
              console.log("Biometric verification FAILED!");
          }
          console.log("Confidence Score: "+face_result['confidence']);
      }  
      # Print document holder name
      if response.get('result'):
          data_result = response['result']
          print("Hello your name is {} {}".format(data_result['firstName'],data_result['lastName']))
      
      # Parse document authentication results
      if response.get('authentication'):
          authentication_result = response['authentication']
          if authentication_result['score'] > 0.5:
              print("The document uploaded is authentic")
          elif authentication_result['score'] > 0.3:
              print("The document uploaded looks little bit suspicious")
          else:
              print("The document uploaded is fake")
      
      # Parse biometric verification results
      if response.get('face'):
          face_result = response['face']
          if face_result['isIdentical']:
              print("Face verification PASSED!")
          else:
              print("Face verification FAILED!")
      
          print("Confidence Score: "+face_result['confidence'])
      
      Exception Handling

      The API will frequently return error code and error messages, for example, when your user uploads an unrecognized document. You can manually check the response for error object, alternatively, you can make Core API client library throw an exception by setting the following:

        $coreapi->throwAPIException(true);
        coreapi.ThrowAPIException(true);
        // Not Available For NodeJS
        // You should use try/catch block to catch network related errors
        // Use response['error'] to check for API errors
        coreapi.throw_api_exception(True)

        You can then use the following code to catch API related error:

        try{
        	//...
        }catch(\IDAnalyzer\APIException $ex){
            echo("Error Code: " . $ex->getCode() . ", Error Message: " . $ex->getMessage());
            // View complete list of error codes under API reference: https://developer.idanalyzer.com/
            switch($ex->getCode()){
                case 1:
                    // Invalid API Key
                    break;
                case 8:
                    // Out of API quota
                    break;
                case 9:
                    // Document not recognized
                    break;
                default:
                    // Other error
            }
        }catch(InvalidArgumentException $ex){
            echo("Argument Error! " . $ex->getMessage());
        }catch(Exception $ex){
            echo("Unexpected Error! " . $ex->getMessage());
        }
        try{
        	//...
        }catch (APIException e){
            Console.WriteLine("Error Code: " + e.ErrorCode);
            Console.WriteLine("Error Message: " + e.Message);
            // View complete list of error codes under API reference: https://developer.idanalyzer.com/
            switch(e.ErrorCode){
                case 1:
                    // Invalid API Key
                    break;
                case 8:
                    // Out of API quota
                    break;
                case 9:
                    // Document not recognized
                    break;
                default:
                    // Other error
            }
        }catch(ArgumentException e){
            Console.WriteLine("Argument Error! " + e.Message);
        }catch(Exception e){
            Console.WriteLine("Unexpected Error! " + e.Message);
        }
        // Not Available For NodeJS
        // You should use try/catch block to catch network related errors
        // Use response['error'] to check for API errors
        except idanalyzer.APIError as e:
            # If API returns an error, catch it
            details = e.args[0]
            print("API error code: {}, message: {}".format(details["code"], details["message"]))
        
        except Exception as e:
            print(e)

        Full Demo Code

        You may view or download full code examples from GitHub.

        You may view or download full code examples from GitHub.

        You may view or download full code examples from GitHub.

        You may view or download full code examples from GitHub.

        Client Library Reference

        To read the complete list of methods and parameters for ID Analyzer Client library, visit the link below:

        PHP Client Library Reference
        .NET Client Library Reference
        NodeJS Client Library Reference
        Python Client Library Reference
        On this page:
        Installation Start Coding Full Demo Code Client Library Reference

        © 2025 All Rights Reserved by ID Analyzer