Using NPM Package

Now, you can use iApp AI API service with NPM (Node Package Manager). It is the api client library for iApp AI API service for Javascript and NodeJS.

Installation

$ npm install iapp_ai_api

Note: This environment is using node 12+ or node 17

Calling Thai National ID Card API

  • Front Part of ID Card

# ID Card Front Part required an image file path
api.idcardFront_Ocr("iapp_ai/media/id-card-front.jpg")
  • Back Part of ID Card

# ID Card Back Part required an image file path
api.idcardBack_Ocr("iapp_ai/media/id-card-back.jpg")

Example Usages

const iapp_ai = require("iapp_ai")
// ##### API KEY ####
const api = new iapp_ai("{Your API Key}");

async function test_front(){
    const ret = await api.idcardFront_Ocr("media/id-card-front.jpg");
    console.log(ret)
}
test_front()

// output:
// {
// address: '23/20 หมู่ที่ 6 ต.กะทู้ อ.กะทู้ จ.ภูเก็ต',
// detection_score: 0.9768817325433095,
// district: 'กะทู้',
// en_dob: '11 Mar 1965',
// en_expire: '10 Mar 2012',
// en_fname: 'Phensiri',
// en_init: 'Mrs.',
// en_issue: '10 Jan 2006',
// en_lname: 'Pitikorckul',
// en_name: 'Mrs Phensiri  Pitikorckul',
// error_message: '',
// ...
// }

async function test_back(){
    const ret = await api.idcardBack_Ocr("media/id-card-back.jpg");
    console.log(ret)
}
test_back()

// output:
// {
//  back_number: 'JT0-1740123-05',
//  back_number_status: 1,
//  detection_score: 0.9957805077234905,
//  error_message: '',
//  process_time: 2.406312942504883,
// request_id: '3a863a93-a5f5-4d1f-be7a-ebb1df2bf8f7#112392'
// }

Last updated