# API Reference

### get\_deviceid <a href="#get_device_id" id="get_device_id"></a>

```python
def get_deviceid() -> str:
```

<table data-header-hidden><thead><tr><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_device_id</td></tr><tr><td><strong>Description</strong></td><td>Retrieves the Hardware ID from a library.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>The Hardware ID is returned as a standard Python string.</td></tr></tbody></table>

### set\_activation

{% code overflow="wrap" %}

```python
def set_activation(license_key: str) -> str:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>set_activation</td></tr><tr><td><strong>Description</strong></td><td>Activates the OCR engine using the provided license key.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license_key</strong> (str): License key string, this should be encoded as UTF-8.</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>A JSON-formatted string containing the result of the activation</p><p>Typically includes an "errorCode" field indicating the status of the activation. </p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk(dict_path: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the OCR engine with the required dictionary files.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>dict_path</strong> (str): Path to the engine binary files directory, This path must be provided as a UTF-8 encoded string.</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>A JSON-formatted string containing the result of the initialization. Typically includes an "errorCode" field indicating the status of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### ocr\_id\_card

{% code overflow="wrap" %}

```python
def ocr_id_card(file_path1: str, file_path2: str) -> str
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>ocr_id_card</td></tr><tr><td><strong>Description</strong></td><td>Extracts data from ID card</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>file_path1</strong> (str): The path to the front image file.</li><li><strong>file_path2</strong> (str): The path to the back image file.</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A JSON-formatted string containing the OCR results.</td></tr></tbody></table>

#### Example of ID OCR results

<div><figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FElJZqcawcM5wMVkl1hxI%2F2_f.png?alt=media&#x26;token=a04ccd84-37e9-4591-826f-19c03f677381" alt=""><figcaption></figcaption></figure> <figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FYF1JFrKt70QqOnCqNnQn%2F2_b.png?alt=media&#x26;token=986ee6c1-d902-457e-a474-649589e1c3a4" alt=""><figcaption></figcaption></figure></div>

```json
{
	"mrz":	{
		"givenNames":"JOHN",
		"name":"DOE JOHN",
		"dateOfExpiry":"2028-12-07",
		"documentClassCode":"ID",
		"nationality":"Ukraine",
		"surname":"DOE",
		"sex":"M",
		"dateOfBirth":"1964-09-02",
		"mrzCode":"IDUKR00235423491964090245614<<^6409029M2812070UKR<<<<<<<<<<<5^DOE<<JOHN<<<<<<<<<<<<<<<<<<<<<",
		"documentNumber":"002354234",
		"issuingStateCode":"UKR",
		"validState":1
	},
	"ocr":{
		"givenNames":"IOHN",
		"name":"DOE IOHN",
		"dateOfExpiry":"2028-12-27",
		"nationality":"Ukraine",
		"surname":"DOE",
		"sex":"M",
		"dateOfBirth":"1964-09-02",
		"documentNumber":"002354234",
		"personalNumber":"1964090245614",
		"dateOfIssue":"2018-12-27",
		"authority":"7110",
		"regCertRegNumber":"3449913065",
		"placeOfBirth":"Y HRYA",
		"validState":1
	},
	"nation":{
		"name":"\xd0\x94\xd0\x9e\xd0\xa3 \xd0\x94\xd0\x96\xd0\x9e\xd0\x9d \xd0\x99\xd0\x9e\xd0\x92\xd0\x90\xd0\x9d\xd0\x9e\xd0\x92\xd0\x98\xd0\xa7",
		"surname":"\xd0\x94\xd0\x9e\xd0\xa3",
		"givenNames":"\xd0\x94\xd0\x96\xd0\x9e\xd0\x9d",
		"fathersName":"\xd0\x99\xd0\x9e\xd0\x92\xd0\x90\xd0\x9d\xd0\x9e\xd0\x92\xd0\x98\xd0\xa7",
		"nationality":"\xd0\xa3\xd0\x9a\xd0\xa0\xd0\x90\xd0\x87\xd0\x9d\xd0\x90",
		"sex":"\xd0\xa7",
		"placeOfBirth":"\xd0\xa1.\xd0\x9f\xd0\x98\xd0\x90\xd0\x93 \xd0\x92\xd0\x90\xd0\x9b"
	},
	"score":0.934643983840942,
	"position":{
		"left":0,
		"top":0,
		"right":601,
		"bottom":384
	},
	"portrait_rect":{
		"bottom":398,
		"left":21,
		"right":255,
		"top":90
	},
	"errorCode":0,
	"documentName":"Id Card",
	"countryName":"Ukraine",
	"image":{
		"ghostPortrait":"/9j/4AAQSkZJRgABAQEAxw...T680Af/9k=",
		"portrait":"/9j/4AAQSkZJRgABAQEAxwDHA...de9P70f8A8RRRTQj/2Q==",
		"signature":"/9j/4AAQSkZJRgABAQEAxwDH...AAD/2wBDAKKEJH/2Q==",
		"documentFrontSide":"/9j/4AAQSkZJRgAB...D/2wKKKKACiiigD/2Q=="
	}
}

```

### ocr\_credit\_card

```python
def ocr_credit_card(file_path: str) -> str:
```

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>ocr_credit_card</td></tr><tr><td><strong>Description</strong></td><td>Etracts data from credit card</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>file_path</strong> (str): The path to the credit card image file.</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A JSON-formatted string containing the OCR results.</td></tr></tbody></table>

### ocr\_barcode

```
def ocr_barcode(file_path: str) -> str:
```

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>ocr_barcode</td></tr><tr><td><strong>Description</strong></td><td>Etracts data from barcode</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>file_path</strong> (str): The path to the barcode image file.</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A JSON-formatted string containing the OCR results.</td></tr></tbody></table>
