extractia-sdk 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -21
- package/dist/extractia-sdk.browser.js +3 -2
- package/dist/extractia-sdk.browser.js.map +2 -2
- package/dist/extractia-sdk.cjs.js +18 -3
- package/dist/extractia-sdk.cjs.js.map +2 -2
- package/dist/extractia-sdk.esm.js +18 -3
- package/dist/extractia-sdk.esm.js.map +2 -2
- package/package.json +1 -1
- package/src/apiClient.js +3 -2
- package/src/index.js +5 -1
package/README.md
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
A JavaScript SDK for interacting with the Extractia API.
|
|
4
4
|
|
|
5
|
+
> **Note:** This SDK is designed for the implementation of the [extractia.info](https://extractia.info) public API.
|
|
6
|
+
> You must have an Extractia account and a valid API token to use it.
|
|
7
|
+
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
7
10
|
```sh
|
|
8
11
|
npm install extractia-sdk
|
|
12
|
+
```
|
|
9
13
|
|
|
10
|
-
Usage
|
|
14
|
+
## Usage
|
|
11
15
|
|
|
16
|
+
```js
|
|
12
17
|
import { setToken, getMyProfile, getTemplates, processImage } from 'extractia-sdk';
|
|
13
18
|
|
|
14
19
|
// Set your API token
|
|
@@ -22,32 +27,42 @@ const templates = await getTemplates();
|
|
|
22
27
|
|
|
23
28
|
// Process an image with a template
|
|
24
29
|
const result = await processImage(templateId, base64Image);
|
|
30
|
+
```
|
|
25
31
|
|
|
26
|
-
API Reference
|
|
32
|
+
## API Reference
|
|
27
33
|
|
|
28
|
-
Authentication
|
|
34
|
+
### Authentication
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
- `setToken(token)` – Set the API token for requests.
|
|
37
|
+
- `getMyProfile()` – Get the authenticated user's profile.
|
|
38
|
+
- `updateWebhook(url)` – Update the webhook URL for the user.
|
|
33
39
|
|
|
34
|
-
Templates
|
|
40
|
+
### Templates
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
- `getTemplates()` – Retrieve all templates.
|
|
43
|
+
- `getTemplateById(id)` – Get a template by its ID.
|
|
44
|
+
- `getTemplateByName(name)` – Get a template by its name.
|
|
45
|
+
- `createTemplate(template)` – Create a new template.
|
|
46
|
+
- `updateTemplate(id, template)` – Update an existing template.
|
|
47
|
+
- `deleteTemplate(id)` – Delete a template.
|
|
48
|
+
- `deleteAllTemplateDocuments(id)` – Delete all documents for a template.
|
|
43
49
|
|
|
44
|
-
Documents
|
|
50
|
+
### Documents
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
- `getDocumentsByTemplateId(templateId, options)` – Get documents for a template.
|
|
53
|
+
- `options`:
|
|
54
|
+
```js
|
|
55
|
+
{
|
|
56
|
+
preconformed?: boolean,
|
|
57
|
+
index?: number, // Paging index (each page contains 10 documents)
|
|
58
|
+
sort?: number, // 1 for ascending, -1 for descending
|
|
59
|
+
includeImage?: boolean
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
- `deleteDocument(documentId)` – Delete a document.
|
|
63
|
+
- `processImage(templateId, base64Image)` – Process a single image.
|
|
64
|
+
- `processImagesMultipage(templateId, base64ImagesArray)` – Process multiple images (multipage).
|
|
50
65
|
|
|
51
|
-
License
|
|
66
|
+
## License
|
|
52
67
|
|
|
53
|
-
|
|
68
|
+
ISC
|
|
@@ -2615,9 +2615,10 @@ var ExtractiaSDK = (() => {
|
|
|
2615
2615
|
timeout: 1e4
|
|
2616
2616
|
});
|
|
2617
2617
|
api.interceptors.request.use((config) => {
|
|
2618
|
-
if (token) {
|
|
2619
|
-
|
|
2618
|
+
if (!token) {
|
|
2619
|
+
throw new Error("API token is required");
|
|
2620
2620
|
}
|
|
2621
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
2621
2622
|
return config;
|
|
2622
2623
|
});
|
|
2623
2624
|
function setToken(newToken) {
|