Background supergraphic

KTP Sessions

A session is required when you want integrate our Prebuilt Web Pages into your product/platform. It contains the unique URL for your user to access the prebuilt web pages.

KTP Sessions Object

  • Name
    status
    Type
    string
    Description

    The status of the session. Possible values are:

    1. PENDING when the user has not finished the session.
    2. FINISHED when the user has finished the session.
  • Name
    expired
    Type
    number
    Description

    Number (in milliseconds since epoch) indicating the session expiration.

  • Name
    url
    Type
    string
    Description

    The URL to access the session.

  • Name
    success_url
    Type
    string
    Description

    The URL the user will be directed to after the session is successful.

  • Name
    cancel_url
    Type
    string
    Description

    If set, the prebuilt web pages will show a back button and users will be directed to this URL if they decide to cancel.

  • Name
    qualities_detector
    Type
    boolean
    Description

    If set to true, the image will be checked for quality. The default value is false.

  • Name
    result
    Type
    string
    Description

    Contains the result. When the session has not been finished. The result will be null.


POST/ocr/v1/ktp-sessions

Create a KTP Session

Create a KTP session. By default, a session will automatically expire after 24 hours.

Required parameter

  • Name
    success_url
    Type
    string
    Description

    When the session is successful, GLAIR will redirect to this URL. When GLAIR redirects your user to success_url, GLAIR will append sid to the query parameter. Use this sid to retrieve the result if necessary.

Optional parameter

  • Name
    cancel_url
    Type
    string
    Description

    If set, GLAIR will show a back button on the prebuilt-UI and your user will be directed to this URL when the button is clicked.

  • Name
    qualities_detector
    Type
    boolean
    Description

    If set to true, the image will be checked for quality. The default value is false.

Sample Request

POST
/ocr/v1/ktp-sessions
1
2
3
4
5
6
7
8
import { Vision } from '@glair/vision'; const vision = new Vision({ apiKey: 'api-key', username: 'username', password: 'password' }); await vision.ocr.ktpSessions.create({ success_url: `SUCCESS_URL`, cancel_url: `CANCEL_URL` });

Sample Response

1
2
3
4
5
6
7
{ "status": "PENDING", "success_url": "https://yourdomain.com?success=true", "cancel_url": "https://yourdomain.com?cancel=true", "qualities_detector": true, "url": "https://vision.glair.ai/ktp/eyJhbgc9asdalkja" }

GET/ocr/v1/ktp-sessions/:sid

Retrieve a KTP Session

Create a ktp session. By default, a session will automatically expire after 24 hours.

Required parameter

  • Name
    sid
    Type
    string
    Description

    The session ID you want to retrieve.

Sample Request

GET
/ocr/v1/ktp-sessions/:sid
1
2
3
4
5
6
7
8
9
import { Vision } from '@glair/vision'; const vision = new Vision({ apiKey: 'api-key', username: 'username', password: 'password', }); await vision.ocr.ktpSessions.retrieve({ sid: 'SID' });

Sample Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{ "status": "FINISHED", "expired": 1678247333160, "url": "https://vision.glair.ai/ktp/eyJhbgc9asdalkja", "success_url": "https://yourdomain.com?success=true", "cancel_url": "https://yourdomain.com?cancel=true", "qualities_detector": true, "result": { "images": { "photo": "/9j/4AAQSkZJRgABAQAAAQABAAD/...", "sign": "/9j/4AAQSkZJRgABAQAAAQABAAD/...", "captured": "/9j/4AAQSkZJRgABAQAAAQABAAD/..." }, "read": { "agama": { "confidence": 98, "value": "ISLAM" }, "alamat": { "confidence": 87, "value": "JUS AGUNG WAY HALIM" }, "berlakuHingga": { "confidence": 97, "value": "SEUMUR HIDUP" }, "golonganDarah": { "confidence": 90, "value": "-" }, "jenisKelamin": { "confidence": 93, "value": "LAKI-LAKI" }, "kecamatan": { "confidence": 99, "value": "KEDATON" }, "kelurahanDesa": { "confidence": 99, "value": "KEDATON" }, "kewarganegaraan": { "confidence": 99, "value": "WNI" }, "kotaKabupaten": { "confidence": 97, "value": "BANDAR LAMPUNG" }, "nama": { "confidence": 97, "value": "NICOJULIAN" }, "nik": { "confidence": 99, "value": "1871010907930009" }, "pekerjaan": { "confidence": 95, "value": "PELAJAR / MAHASISWA" }, "provinsi": { "confidence": 99, "value": "LAMPUNG" }, "rtRw": { "confidence": 88, "value": "014/000" }, "statusPerkawinan": { "confidence": 98, "value": "BELUM KAWIN" }, "tanggalLahir": { "confidence": 97, "value": "09-07-1993" }, "tempatLahir": { "confidence": 97, "value": "BANDAR LAMPUNG" } }, "form": { "agama": "ISLAM", "alamat": "JUS AGUNG WAY HALIM", "berlakuHingga": "SEUMUR HIDUP", "golonganDarah": "-", "jenisKelamin": "LAKI-LAKI", "kecamatan": "KEDATON", "kelurahanDesa": "KEDATON", "kewarganegaraan": "WNI", "kotaKabupaten": "BANDAR LAMPUNG", "nama": "NICOJULIAN", "nik": "1871010907930009", "pekerjaan": "PELAJAR / MAHASISWA", "provinsi": "LAMPUNG", "rtRw": "014/000", "statusPerkawinan": "BELUM KAWIN", "tanggalLahir": "09-07-1993", "tempatLahir": "BANDAR LAMPUNG", "namaIbuKandung": "YULIANA", }, "reason": "File Successfully Read", "status": "SUCCESS" } }