|
3 | 3 | # Mindee API Helper Library for PHP |
4 | 4 | Quickly and easily connect to Mindee's API services using PHP. |
5 | 5 |
|
6 | | -## Quick Start |
7 | | -Here's the TL;DR of getting started. |
| 6 | +## Mindee API Versions |
| 7 | +This client library has support for both Mindee platform versions. |
8 | 8 |
|
9 | | -First, get an [API Key](https://developers.mindee.com/docs/create-api-key) |
| 9 | +### Latest - V2 |
| 10 | +This is the new platform located here: |
10 | 11 |
|
11 | | -If you do not have them, you'll need the following packages on your system: |
12 | | -* [php-curl](https://www.php.net/manual/en/curl.installation.php) |
13 | | -* [php-json](https://www.php.net/manual/en/json.installation.php) (not necessary for versions >= 8.0.0) |
14 | | -* [php-fileinfo](https://www.php.net/manual/en/fileinfo.installation.php) |
| 12 | +https://app.mindee.com |
15 | 13 |
|
16 | | -Then, install this library: |
17 | | -```shell |
18 | | -composer require mindee/mindee |
19 | | -``` |
| 14 | +It uses **API version 2**. |
20 | 15 |
|
21 | | -Finally, PHP away! |
| 16 | +Consult the |
| 17 | +**[Latest Documentation](https://docs.mindee.com/integrations/client-libraries-sdk)** |
22 | 18 |
|
23 | | -### Loading a File and Parsing It |
24 | 19 |
|
25 | | -#### Global Documents |
26 | | -```php |
27 | | -<?php |
| 20 | +### Legacy - V1 |
| 21 | +This is the legacy platform located here: |
28 | 22 |
|
29 | | -use Mindee\Client; |
30 | | -use Mindee\Product\Invoice\InvoiceV4; |
| 23 | +https://platform.mindee.com/ |
31 | 24 |
|
32 | | -// Init a new client |
33 | | -$mindeeClient = new Client("my-api-key"); |
| 25 | +It uses **API version 1**. |
34 | 26 |
|
35 | | -// Load a file from disk |
36 | | -$inputSource = $mindeeClient->sourceFromPath("/path/to/the/file.ext"); |
| 27 | +Consult the |
| 28 | +**[Legacy Documentation](https://developers.mindee.com/docs/php-getting-started)** |
37 | 29 |
|
38 | | -// Parse the file |
39 | | -$apiResponse = $mindeeClient->parse(InvoiceV4::class, $inputSource); |
| 30 | +## Additional Information |
40 | 31 |
|
41 | | -// Print a brief summary of the parsed data |
42 | | -echo strval($apiResponse->document); |
43 | | -``` |
| 32 | +**[Source Code](https://github.com/mindee/mindee-api-php)** |
44 | 33 |
|
45 | | -**Note:** Files can also be loaded from: |
| 34 | +**[Reference Documentation](https://mindee.github.io/mindee-api-php/)** |
46 | 35 |
|
47 | | -A PHP `File` compatible file: |
48 | | -```php |
49 | | -$inputDoc = $mindeeClient->sourceFromFile($myFile); |
50 | | -``` |
51 | | - |
52 | | -A URL (`HTTPS` only): |
53 | | -```php |
54 | | -$inputDoc = $mindeeClient->sourceFromUrl("https://files.readme.io/a74eaa5-c8e283b-sample_invoice.jpeg"); |
55 | | -``` |
56 | | - |
57 | | -A base64-encoded string, making sure to specify the extension of the file name: |
58 | | -```php |
59 | | -$inputDoc = $mindeeClient->sourceFromB64($myInputString, "my-file-name.ext"); |
60 | | -``` |
61 | | - |
62 | | -Raw bytes, making sure to specify the extension of the file name: |
63 | | -```php |
64 | | -$inputDoc = $mindeeClient->sourceFromBytes($myRawBytesSequence, "my-file-name.ext"); |
65 | | -``` |
66 | | - |
67 | | -#### Region-Specific Documents |
68 | | -```php |
69 | | -use Mindee\Client; |
70 | | -use Mindee\Product\Us\BankCheck\BankCheckV1; |
71 | | - |
72 | | -// Init a new client |
73 | | -$mindeeClient = new Client("my-api-key"); |
74 | | - |
75 | | -// Load a file from disk |
76 | | -$inputSource = $mindeeClient->sourceFromPath("/path/to/the/file.ext"); |
77 | | - |
78 | | -// Parse the file |
79 | | -$apiResponse = $mindeeClient->parse(BankCheckV1::class, $inputSource); |
80 | | - |
81 | | -// Print a brief summary of the parsed data |
82 | | -echo strval($apiResponse->document); |
83 | | -``` |
84 | | - |
85 | | -#### Custom Documents (docTI & Custom APIs) |
86 | | - |
87 | | -```php |
88 | | -use Mindee\Client; |
89 | | -use Mindee\Product\Generated\GeneratedV1; |
90 | | - |
91 | | -// Init a new client |
92 | | -$mindeeClient = new Client("my-api-key"); |
93 | | - |
94 | | -// Load a file from disk |
95 | | -$inputSource = $mindeeClient->sourceFromPath("/path/to/the/file.ext"); |
96 | | - |
97 | | -// Parse the file |
98 | | -$apiResponse = $mindeeClient->parse(GeneratedV1::class, $inputSource); |
99 | | - |
100 | | -// Print a brief summary of the parsed data |
101 | | -echo strval($apiResponse->document); |
102 | | -``` |
103 | | - |
104 | | -## Full PDF support |
105 | | - |
106 | | -Some features such as Invoice Splitter auto-extraction & Multi Receipts auto-extraction require the [ImageMagick](https://www.php.net/manual/en/imagick.setup.php) library, which in turn requires [GhostScript](https://www.ghostscript.com/). |
107 | | - |
108 | | -### Unix |
109 | | - |
110 | | -ImageMagick is usually bundled with most installations. If not, you can install it using your distribution's package manager. |
111 | | - |
112 | | -More details [here](https://imagemagick.org/script/advanced-linux-installation.php). |
113 | | - |
114 | | -Ghostscript can be installed from the [website download page](https://ghostscript.com/releases/gsdnld.html), or if using an apt compatible distribution: |
115 | | -```bash |
116 | | -sudo apt-get update |
117 | | -sudo apt-get install -y ghostscript |
118 | | -``` |
119 | | - |
120 | | -In some cases, you might also want to authorize the ImageMagick policy to edit PDF files: |
121 | | - |
122 | | -```bash |
123 | | -DQT='"' |
124 | | -SRC="rights=${DQT}none${DQT} pattern=${DQT}PDF${DQT}" |
125 | | -RPL="rights=${DQT}read|write${DQT} pattern=${DQT}PDF${DQT}" |
126 | | -sudo sed -i "s/$SRC/$RPL/" /etc/ImageMagick-6/policy.xml |
127 | | -``` |
128 | | - |
129 | | -### MacOS |
130 | | - |
131 | | -Brew will be required for this install. |
132 | | - |
133 | | -```bash |
134 | | -brew update |
135 | | -brew install imagemagick |
136 | | -pecl install imagick # Might not be needed in some instances. Do not try to install before installing PHP & Pecl. |
137 | | -``` |
138 | | - |
139 | | -### Windows |
140 | | -You can install [Ghostscript](https://ghostscript.com/releases/gsdnld.html) by downloading it, or simply by using [Chocolatey](https://chocolatey.org/). |
141 | | - |
142 | | -``` |
143 | | -choco install ghostscript --version 10.03.1 -y |
144 | | -``` |
145 | | - |
146 | | -**⚠️ Important note if you are using Windows** |
147 | | -The `gs` alias might not be available by default, but it is possible to bind it fairly simply by either adding `gswin32c.exe` or `gswin64c.exe` to your `$PATH` and then adding a symlink in powershell using: |
148 | | - |
149 | | -``` |
150 | | -New-Item -ItemType SymbolicLink -Path "C:\Windows\gs.exe" -Target "C:\Program Files\gs\gs10.03.1\bin\gswin64c.exe" |
151 | | -New-Item -ItemType SymbolicLink -Path "C:\Windows\gs" -Target "C:\Program Files\gs\gs10.03.1\bin\gswin64c.exe" |
152 | | -``` |
153 | | -## Further Reading |
154 | | -Complete details on the working of the library are available in the following guides: |
155 | | - |
156 | | -* [Getting started](https://developers.mindee.com/docs/php-getting-started) |
157 | | -* [PHP Command Line Interface (CLI)](https://developers.mindee.com/docs/php-cli) |
158 | | -* [PHP Generated APIs](https://developers.mindee.com/docs/php-generated-api) |
159 | | -* [PHP Custom APIs (API Builder - Deprecated)](https://developers.mindee.com/docs/php-api-builder) |
160 | | -* [PHP Invoice OCR](https://developers.mindee.com/docs/php-invoice-ocr) |
161 | | -* [PHP Receipt OCR](https://developers.mindee.com/docs/php-receipt-ocr) |
162 | | -* [PHP Financial Document OCR](https://developers.mindee.com/docs/php-financial-document-ocr) |
163 | | -* [PHP Passport OCR](https://developers.mindee.com/docs/php-passport-ocr) |
164 | | -* [PHP Resume OCR](https://developers.mindee.com/docs/php-resume-ocr) |
165 | | -* [PHP International Id OCR](https://developers.mindee.com/docs/php-international-id-ocr) |
166 | | -* [PHP FR Bank Account Detail OCR](https://developers.mindee.com/docs/php-fr-bank-account-details-ocr) |
167 | | -* [PHP FR Carte Grise OCR](https://developers.mindee.com/docs/php-fr-carte-grise-ocr) |
168 | | -* [PHP FR Health Card OCR](https://developers.mindee.com/docs/php-fr-health-card-ocr) |
169 | | -* [PHP FR ID Card OCR](https://developers.mindee.com/docs/php-fr-carte-nationale-didentite-ocr) |
170 | | -* [PHP US Bank Check OCR](https://developers.mindee.com/docs/php-us-bank-check-ocr) |
171 | | -* [PHP Barcode Reader API](https://developers.mindee.com/docs/php-barcode-reader-ocr) |
172 | | -* [PHP Cropper API](https://developers.mindee.com/docs/php-cropper-ocr) |
173 | | -* [PHP Invoice Splitter API](https://developers.mindee.com/docs/php-invoice-splitter-ocr) |
174 | | -* [PHP Multi Receipts Detector API](https://developers.mindee.com/docs/php-multi-receipts-detector-ocr) |
175 | | - |
176 | | -You can view the source code on [GitHub](https://github.com/mindee/mindee-api-php). |
177 | | - |
178 | | -You can also take a look at the |
179 | | -**[Reference Documentation](https://mindee.github.io/mindee-api-php)**. |
| 36 | +**[Feedback](https://feedback.mindee.com/)** |
180 | 37 |
|
181 | 38 | ## License |
182 | 39 | Copyright © Mindee |
|
0 commit comments