Skip to content

Instantly share code, notes, and snippets.

@pentagonal
Last active July 26, 2019 06:51
Show Gist options
  • Save pentagonal/3ae394220649f86244b846073ece2c41 to your computer and use it in GitHub Desktop.
Save pentagonal/3ae394220649f86244b846073ece2c41 to your computer and use it in GitHub Desktop.

DOCUMENT API (LAMBDA APP / ServerLess)

REQUEST

REQUEST TO DOCUMENT (KK/KTP/NPWP)

Required Headers

{
    "Content-Type" : "application/json",
    "X-Api-Key" : "(string:plain:required) Company Token Given By Provider",
    "X-Compress-Json": "(string|boolean:optional) true|false|yes if result compressed JSON"
}

Required Body (Format: json)

{
    "fileName" : "(string:plain:required) fileName.ext:fileName of image",
    "batchId"  : "(string:plain:required) batchId:determine by client",
    "image"    : "(string:base64:required) base64Image:binary image that encoded by client"
}

GLOBAL RESPONSE ERROR

ERROR

Error from server. This means there was an error with scripts

500

{
    "message": "Internal Server Error"
}

Or 502 status is error caused server.

RESPONSE FOR CLIENT

HEADER

Header Response

{
    "Content-Type"         : "(string:always) application/json; charset=utf8",
    "X-Token-Expired-After": "(string|number:optional) formatted date(Y-m-d\\TH:i:s\\.u\\Z, time) or 0 if could not detect or not exists if fail",
}

SUCCESS

Success 200

{
    "data": {
        "ThisExampleKey": "And All Result"
    }
}

ERROR

500

{
    "message": "Internal Server Error"
}

Forbidden : 403 (Need to valid API KEY)

{
    "message": "Forbidden"
}

Header Token Empty: 400

{
    "message": "Bad Request. Token Required"
}

Invalid Token: 401

{
    "message": "Request Unauthorized"
}

Token Expired : 401

{
    "message": "Request Unauthorized. Expired Token"
}

Route Does Not Exists : 404

{
    "message": "Not Found Module"
}

Sub Route Does Not Exists : 404

{
    "message": "Not Found"
}

Parameter FOR KK ERROR : 412 (Precondition failed : Header is Not application/json)

{
    "message": "No resource Image detect. POST method must be as json image data {\"fileName\":\"image.jpeg\", \"batchId\": \"string batchId\", \"image\": \"string base64\"}"
}

Parameter FOR KK ERROR : 412 (Precondition failed about sending data json key image is not present)

{
    "message": "No resource Image detect. Or params `image` must be as string encoded image file"
}

Parameter FOR KK ERROR : 412 (Precondition failed about sending data json key fileName is not present or invalid data type)

{
    "message": "Please insert parameter `fileName`. Parameter fileName must be as a string"
}

Parameter FOR KK ERROR : 412 (Precondition failed about sending data json key batchId is not present or invalid data type)

{
    "message": "Please insert parameter `batchId`. Parameter batchId must be as a string"
}

Parameter FOR KK ERROR : 412 (Precondition failed about sending data json key image is not valid base64 string)

{
    "message": "Unsupported / Invalid Image Format. Only base64 string allowed"
}

Parameter FOR KK ERROR : 412 (Precondition failed about sending data json key image is valid base64 but is not binary string image)

{
    "message": "Unsupported / Invalid Image Format. Supported jpeg or png only"
}

Parameter FOR KK ERROR : 409 (Precondition failed about sending data json key image is valid base64 but is not valid image

{
    "message": "Text Extraction Error : Request has unsupported document format"
}

Response 409 about text extraction: 409

{
    "message": "Text Extraction Error : (any information here)"
}

Response 417 invalid image to extract: 417

{
    "message": "Expectation Failed. Could not parse data from given image"
}

Response Does not meet Requirement By Company Confidence : 451

{
    "message": "Unavailable For Legal Reasons. Confidence is not meet requirement"
}

RESPONSE FOR PROVIDER NOTE

ERROR

This error also serve to client. As note for provider (serve to client)

Response 417 invalid hash : 417 (this system server error) - invalid code hash

{
    "message": "Expectation Failed. Invalid Hash Given By System"
}

Date Problem On Server Database (Invalid Date Expired) : 503

{
    "message": "Service Unavailable. Date Company Reason"
}

Date Problem On Server Database (Invalid To Save Transaction) : 503

{
    "message": "Service Unavailable. Reason is Data Invalid"
}
{
"fileName": "(string:plain:required:fileName.ext)",
"batchId": "(string:plain:required:batchId)",
"image": "(string:base64Encoded:required:binaryData)"
}
{
"uri": "(string:url:endpoint:follow the stage)",
"path": "/kk",
"method" : "POST",
"headers": {
"Content-Type": "application/json",
"X-Auth-Token" : "(string:plain:required) Company Token Given By Provider",
"X-Compress-Json": "(string|boolean:optional) true|false|yes if result compressed JSON"
},
"body": {
"fileName": "(string:plain:required:fileName.ext)",
"batchId": "(string:plain:required:batchId)",
"image": "(string:base64Encoded:required:binaryData)"
},
"note": [
"body is json_encoded() and require fileName & image key name"
]
}
{
"data": {
"Request": {
"FileName": "image.jpg",
"BatchId": "5d134849-3bf0-4cc2-b5cb-8e01a603f02b",
"TimestampUTCMilliSeconds": 1553609635000,
"TimestampUTC": 1553609635
},
"Response": {
"TrxId": "609d7eb5-de24-4d00-b8e9-0eaaf026eb0e",
"Hash": {
"Md5": "d41d8cd98f00b204e9800998ecf8427e",
"Sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"Info": {
"MessageCode": 1,
"Message": "Success",
"Confidence": 89.8363,
"AutoApprovalDateUTC": "2019-03-29T14:13:55.000Z",
"ApiKeyExpiredAt": "2020-12-30T17:00:00.000Z",
"MembersCount": 6,
"ReadAbleMembers": [
0,
1,
2,
3,
4,
5
],
"UnReadAbleMembers": []
},
"DocumentIdentities": {
"FamilyNumber": "32404290910000001",
"HeadOfHouseHold": "ILAHUDDIN",
"SubDistrict": "MALILI",
"Address": "JL. SEMANGKA",
"Regency": "LUWU TIMUR",
"Village": "PUNCAK INDAH",
"NeighbourhoodOrCommunityAssociation": "",
"Neighbourhood": "",
"CommunityAssociation": "",
"Province": "SULAWESI SELATAN",
"PostalCode": "",
"IssuedAt": "20-09-2011"
},
"Members": [
{
"FullName": "SILAHUDDIN",
"Nik": "7324041212680002",
"Gender": "LAKI-LAKI",
"BirthPlace": "TANRU TEDONG",
"BirthDate": "12-12-1968",
"Religion": "ISLAM",
"Education": "SLTA/SEDERAJAT",
"Job": "PETANI/PEKEBUN",
"MaritalStatus": "KAWIN",
"FamilyConnection": "KEPALA KELUARGA",
"Nationality": "WNI",
"Passport": null,
"PermitNumber": null,
"FatherName": "LABANDONG",
"MotherName": "NAIMA",
"IsReadAble": true,
"AdditionalData": {}
},
{
"FullName": "NURHAYATIH.",
"Nik": "7324046604730001",
"Gender": "PEREMPUAN",
"BirthPlace": "LANCIRANG",
"BirthDate": "26-04-1973",
"Religion": "ISLAM",
"Education": "SLTA/SEDERAJAT",
"Job": "MENGURUS RUMAH TANGGA",
"MaritalStatus": "KAWIN",
"FamilyConnection": "ISTRI",
"Nationality": "WNI",
"Passport": null,
"PermitNumber": null,
"FatherName": "HAFID",
"MotherName": "HADRA",
"IsReadAble": true,
"AdditionalData": {}
},
{
"FullName": "SUCIFATMAWATI",
"Nik": "7324045009960001",
"Gender": "PEREMPUAN",
"BirthPlace": "MALILI",
"BirthDate": "10-09-1896",
"Religion": "ISLAM",
"Education": "TAMAT SD/SEDERAJAT",
"Job": "BELUM/TIDAK BEKERJA",
"MaritalStatus": "BELUM KAWIN",
"FamilyConnection": "ANAK",
"Nationality": "WNI",
"Passport": null,
"PermitNumber": null,
"FatherName": "LAHUDDIN",
"MotherName": "NURHAYATI. H",
"IsReadAble": true,
"AdditionalData": {}
},
{
"FullName": "SHUVI NURUL ISNANI",
"Nik": "7324046501",
"Gender": "PEREMPUAN",
"BirthPlace": "LANCIRANG",
"BirthDate": "25-01-1999",
"Religion": "ISLAM",
"Education": "BELUM TAMAT SD/SEDERAJAT",
"Job": "BELUM/TIDAK BEKERJA",
"MaritalStatus": "BELUM KAWIN",
"FamilyConnection": "ANAK",
"Nationality": "WNI",
"Passport": null,
"PermitNumber": null,
"FatherName": "SILAHUDDIN",
"MotherName": "NURHAYATI.H",
"IsReadAble": true,
"AdditionalData": {}
},
{
"FullName": "TAUFIQ BAMBANG SAPUTRA",
"Nik": "7324042710060003",
"Gender": "LAKI-LAKI",
"BirthPlace": "LANCIRANG",
"BirthDate": "27-10-2006",
"Religion": "ISLAM",
"Education": "TIDAK/BELUM SEKOLAH",
"Job": "BELUM/TIDAK BEKERJA",
"MaritalStatus": "BELUM KAWIN",
"FamilyConnection": "ANAK",
"Nationality": "WNI",
"Passport": null,
"PermitNumber": null,
"FatherName": "SILAHUDDIN",
"MotherName": "NURHAYATI.",
"IsReadAble": true,
"AdditionalData": {}
},
{
"FullName": "TSAQIF RAMADHAN",
"Nik": "732404040811000",
"Gender": "LAKI-LAKI",
"BirthPlace": "PUNCAK INDAH",
"BirthDate": "04-08-2011",
"Religion": "ISLAM",
"Education": "TIDAK/BELUM SEKOLAH",
"Job": "BELUM/TIDAK BEKERJA",
"MaritalStatus": "BELUM KAWIN",
"FamilyConnection": "ANAK",
"Nationality": "WNI",
"Passport": null,
"PermitNumber": null,
"FatherName": "SILAHUDDIN",
"MotherName": "NURHAYATIH",
"IsReadAble": true,
"AdditionalData": {}
}
]
}
}
}
{
"Request": {
"FileName": "xxxx.jpg",
"BatchId": "StringUniqueBatchId",
"TimestampUTCMilliSeconds": 1563928149000,
"TimestampUTC": 1563928149
},
"Response": {
"TrxId": "b6081ccc-b77d-4e49-a24c-18567a0dfbfd",
"Hash": {
"Md5": "0483d73e0d1f9e60e4488fb108a461dc",
"Sha1": "05a7b451ae3caa4a1f3207eadfda51c04de0ef47"
},
"Info": {
"MessageCode": 1,
"Message": "Success",
"Confidence": 100,
"AutoApprovalDateUTC": "2019-07-27T00:29:09.000Z",
"ApiKeyExpiredAt": "2019-07-24T00:33:28.200Z"
},
"Result": {
"Nik": "3324171310xxxxxx",
"Name": "XXXXX ROCHMAN",
"Gender": "LAKI-LAKI",
"Blood": "-",
"Religion": "ISLAM",
"MaritalStatus": "BELUM KAWIN",
"BirthDate": "1x-xx-19xx",
"BirthPlace": "KENDAL",
"Job": "PELAJAR/MAHASISWA",
"Address": {
"Street": "SENDANG KIDUL",
"Neighbourhood": "003",
"CommunityAssociation": "002",
"Village": "SENDANG KULON",
"SubDistrict": "KANGKUNG",
"City": "KENDAL"
},
"Province": "JAWA TENGAH",
"City": "KENDAL",
"Nationality": "WNI",
"AppliesTo": "13-10-2017",
"IssuedAt": "18-09-2012"
}
}
}
{
"Request": {
"FileName": "xxxxx.jpg",
"BatchId": "StringUniqueBatchId",
"TimestampUTCMilliSeconds": 1563928248000,
"TimestampUTC": 1563928248
},
"Response": {
"TrxId": "9828d582-4a21-4686-9d93-5e14c7533815",
"Hash": {
"Md5": "cba7802113c1cb7e038dbb0bc765cf80",
"Sha1": "b8646e958d4473516b75bd1b58020d56f05dfb35"
},
"Info": {
"MessageCode": 1,
"Message": "Success",
"Confidence": 100,
"AutoApprovalDateUTC": "2019-07-27T00:30:48.000Z",
"ApiKeyExpiredAt": "2019-07-24T00:35:07.200Z"
},
"Result": {
"No": "12.345.678.9-101.000",
"Name": "PT. XXXX XXXX",
"Address": "JL. XXXXXX NO XX KOTA XXXXXX",
"IssuedAt": "12-12-2012"
}
}
}
{
"Request": {
"FileName": "xxxxxx.jpg",
"BatchId": "1",
"TimestampUTCMilliSeconds": 1564123788000,
"TimestampUTC": 1564123788
},
"Response": {
"TrxId": "9c6abce5-af9f-49af-a520-d0640e3eefad",
"Hash": {
"Md5": "6ed2bacff2e461e7cc6c08f2884324c7",
"Sha1": "0df69ecf5da7db169a95867a53e29f37b0392374"
},
"Info": {
"MessageCode": 1,
"Message": "Success",
"Confidence": 100,
"AutoApprovalDateUTC": "2019-07-29T06:49:48.000Z",
"ApiKeyExpiredAt": "2019-07-26T06:54:07.200Z"
},
"Result": {
"No": "123456789012",
"Type": "C",
"Name": "NAME",
"Gender": "LAKI-LAKI",
"BirthDate": "20-08-1988",
"BirthPlace": "BIRTH PLACE",
"Job": "JOB",
"Address": "KEC. XXXXX DESA XXXX",
"City": "KOTA",
"AppliesTo": "20-08-2019",
"IssuedAt": "15-12-2014"
}
}
}
@pentagonal
Copy link
Author

AutoApprovalDateUTC is 3 days after current time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment