Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,36 @@ This submits a document for processing (3-5 seconds for a response)

```js
let veryfi_client = new Client(client_id, client_secret, username, api_key);
let response = veryfi_client.process_document(file_path, categories=categories).then(response => {
let response = veryfi_client.process_document(file_path, categories).then(response => {
console.log(response)
});
```

...or with a URL

```js
let response = veryfi_client.process_document_url(url, external_id=some_id).then(response => {
let response = veryfi_client.process_document_from_url(url, null, categories, false, false, some_id).then(response => {
console.log(response)
});
```

### Line items, tags, and other products

```js
const document_id = '123';
await veryfi_client.create_line_item(document_id, { description: 'Milk', total: 3.5 });
await veryfi_client.get_document_line_items(document_id);
await veryfi_client.add_tag(document_id, 'reviewed');
await veryfi_client.get_document_tags(document_id);

await veryfi_client.process_contract_from_url('https://cdn.example.com/contract.pdf');
await veryfi_client.process_markdown_document_from_url('https://cdn.example.com/invoice.pdf');
await veryfi_client.classify_document_from_url('https://cdn.example.com/receipt.jpg', null, {
document_types: ['receipt', 'invoice']
});
await veryfi_client.extract_document_from_url('https://cdn.example.com/receipt.jpg', null, ['receipt', 'invoice']);
```

### Response

```json
Expand Down
384 changes: 191 additions & 193 deletions docs/api-coverage-analysis.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/anydocs/getAnyDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Client.prototype.get_any_document = async function (document_id,
confidence_details = false,
{...kwargs} = {}) {
let endpoint_name = `/any-documents/${document_id}/`;
let request_arguments = {
let query = Object.assign({
"bounding_boxes": bounding_boxes,
"confidence_details": confidence_details
};
let document = await this._request("GET", endpoint_name, request_arguments, kwargs, false);
}, kwargs);
let document = await this._request("GET", endpoint_name, {}, query, false);
return document['data'];
}
6 changes: 3 additions & 3 deletions lib/anydocs/getAnyDocuments.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Client.prototype.get_any_documents = async function (
confidence_details = false,
{...kwargs} = {}) {
let endpoint_name = "/any-documents/";
let request_arguments = {
let query = Object.assign({
"page": page,
"page_size": page_size,
"bounding_boxes": bounding_boxes,
"confidence_details": confidence_details
};
let documents = await this._request("GET", endpoint_name, request_arguments, kwargs, false);
}, kwargs);
let documents = await this._request("GET", endpoint_name, {}, query, false);
if ("data" in documents) {
documents = documents["data"];
}
Expand Down
17 changes: 17 additions & 0 deletions lib/anydocs/getBlueprints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const Client = require('../client/constructor');
/**
* Get Blueprints. https://docs.veryfi.com/api/get-blueprints/
*
* @memberof Client
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.get_blueprints = async function (
{...kwargs} = {}
) {
let endpoint_name = "/blueprints/";
let query = Object.assign({
}, kwargs);
let response = await this._request("GET", endpoint_name, {}, query, false);
return response['data'];
}
31 changes: 31 additions & 0 deletions lib/anydocs/processAnyDocumentAsync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const Client = require('../client/constructor');
const path = require('path');
const fs = require('fs');
/**
* Process a any document asynchronously. https://docs.veryfi.com/api/anydocs/process-a-A-doc-asynchronously/
* @example
* veryfi_client.process_any_document_async('file/path')
*
* @memberof Client
* @param {String} file_path Path on disk to a file to submit
* @param {String} blueprint_name The name of the extraction blueprints to use.
* @param {number} max_pages_to_process The number of pages to process for the document.
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.process_any_document_async = async function (
file_path,
blueprint_name = null,
max_pages_to_process = 20,
{...kwargs} = {}
) {
let file = fs.createReadStream(file_path);
let file_name = path.basename(file_path);
return this.process_any_document_async_from_stream(
file,
file_name,
blueprint_name,
max_pages_to_process,
kwargs
);
}
30 changes: 30 additions & 0 deletions lib/anydocs/processAnyDocumentAsyncBase64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const Client = require('../client/constructor');
/**
* Process a any document asynchronously from a base64 string. https://docs.veryfi.com/api/anydocs/process-a-A-doc-asynchronously/
*
* @memberof Client
* @param {String} file_name The file name including the extension
* @param {String} file_base64_string Base64-encoded file contents (raw or data URI)
* @param {String} blueprint_name The name of the extraction blueprints to use.
* @param {number} max_pages_to_process The number of pages to process for the document.
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.process_any_document_async_from_base64 = async function (
file_name,
file_base64_string,
blueprint_name = null,
max_pages_to_process = 20,
{...kwargs} = {}
) {
let endpoint_name = "/any-documents/async/";
let request_arguments = {
"file_name": file_name,
"file_data": file_base64_string,
"blueprint_name": blueprint_name,
"max_pages_to_process": max_pages_to_process,
};
request_arguments = Object.assign(request_arguments, kwargs);
let response = await this._request("POST", endpoint_name, request_arguments, null, false);
return response['data'];
}
30 changes: 30 additions & 0 deletions lib/anydocs/processAnyDocumentAsyncStream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const Client = require('../client/constructor');
/**
* Process a any document asynchronously from a file stream. https://docs.veryfi.com/api/anydocs/process-a-A-doc-asynchronously/
*
* @memberof Client
* @param {stream.Readable} file ReadStream of a file to submit
* @param {String} file_name The file name including the extension
* @param {String} blueprint_name The name of the extraction blueprints to use.
* @param {number} max_pages_to_process The number of pages to process for the document.
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.process_any_document_async_from_stream = async function (
file,
file_name,
blueprint_name = null,
max_pages_to_process = 20,
{...kwargs} = {}
) {
let endpoint_name = "/any-documents/async/";
let request_arguments = {
"file": file,
"file_name": file_name,
"blueprint_name": blueprint_name,
"max_pages_to_process": max_pages_to_process,
};
request_arguments = Object.assign(request_arguments, kwargs);
let response = await this._request("POST", endpoint_name, request_arguments, null, true);
return response['data'];
}
30 changes: 30 additions & 0 deletions lib/anydocs/processAnyDocumentAsyncUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const Client = require('../client/constructor');
/**
* Process a any document asynchronously from a URL. https://docs.veryfi.com/api/anydocs/process-a-A-doc-asynchronously/
*
* @memberof Client
* @param {string|null} file_url Required if file_urls isn't specified. Publicly accessible URL to a file.
* @param {string[]} file_urls Required if file_url isn't specified. List of publicly accessible URLs.
* @param {String} blueprint_name The name of the extraction blueprints to use.
* @param {number} max_pages_to_process The number of pages to process for the document.
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.process_any_document_async_from_url = async function (
file_url = null,
file_urls = null,
blueprint_name = null,
max_pages_to_process = 20,
{...kwargs} = {}
) {
let endpoint_name = "/any-documents/async/";
let request_arguments = {
"file_url": file_url,
"file_urls": file_urls,
"blueprint_name": blueprint_name,
"max_pages_to_process": max_pages_to_process,
};
request_arguments = Object.assign(request_arguments, kwargs);
let response = await this._request("POST", endpoint_name, request_arguments, null, false);
return response['data'];
}
15 changes: 15 additions & 0 deletions lib/anydocs/tags/addAnyDocumentTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Client = require('../../client/constructor');
/**
* Add a tag to a any document. https://docs.veryfi.com/api/anydocs/add-a-tag-to-a-A-doc/
*
* @memberof Client
* @param {string} document_id ID of the document
* @param {string} tag Tag name to add
* @returns {JSON} Tag response
*/
Client.prototype.add_any_document_tag = async function (document_id, tag) {
let endpoint_name = `/any-documents/${document_id}/tags/`;
let request_arguments = {"name": tag};
let response = await this._request("PUT", endpoint_name, request_arguments);
return response['data'];
}
15 changes: 15 additions & 0 deletions lib/anydocs/tags/addAnyDocumentTags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Client = require('../../client/constructor');
/**
* Add tags to a any document. https://docs.veryfi.com/api/anydocs/add-tags-to-a-A-doc/
*
* @memberof Client
* @param {string} document_id ID of the document
* @param {string[]} tags Tag names to add
* @returns {JSON} Tags response
*/
Client.prototype.add_any_document_tags = async function (document_id, tags) {
let endpoint_name = `/any-documents/${document_id}/tags/`;
let request_arguments = {"tags": tags};
let response = await this._request("POST", endpoint_name, request_arguments);
return response['data'];
}
12 changes: 12 additions & 0 deletions lib/anydocs/tags/deleteAnyDocumentTags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Client = require('../../client/constructor');
/**
* Unlink all tags from a any document. https://docs.veryfi.com/api/anydocs/unlink-all-tags-from-a-A-doc/
*
* @memberof Client
* @param {string} document_id ID of the document
* @returns {JSON} Delete response
*/
Client.prototype.delete_any_document_tags = async function (document_id) {
let endpoint_name = `/any-documents/${document_id}/tags/`;
return this._request("DELETE", endpoint_name, {});
}
14 changes: 14 additions & 0 deletions lib/anydocs/updateAnyDocument.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Client = require('../client/constructor');
/**
* Update a any document. https://docs.veryfi.com/api/anydocs/update-a-A-doc/
*
* @memberof Client
* @param {string} document_id ID of the resource
* @param {Object} kwargs Fields to update
* @returns {JSON} Updated resource
*/
Client.prototype.update_any_document = async function (document_id, {...kwargs} = {}) {
let endpoint_name = `/any-documents/${document_id}/`;
let response = await this._request("PUT", endpoint_name, kwargs);
return response['data'];
}
6 changes: 3 additions & 3 deletions lib/bankstatements/getBankStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Client.prototype.get_bank_statement = async function (
{...kwargs} = {}
) {
let endpoint_name = `/bank-statements/${document_id}/`;
let request_arguments = {
let query = Object.assign({
"bounding_boxes": bounding_boxes,
"confidence_details": confidence_details
};
let document = await this._request("GET", endpoint_name, request_arguments, kwargs, false);
}, kwargs);
let document = await this._request("GET", endpoint_name, {}, query, false);
return document['data'];
}
14 changes: 14 additions & 0 deletions lib/bankstatements/getBankStatementSet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Client = require('../client/constructor');
/**
* Get a Bank Statement set. https://docs.veryfi.com/api/get-a-bank-statement-set/
*
* @memberof Client
* @param {string} document_id ID of the resource
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.get_bank_statement_set = async function (document_id, {...kwargs} = {}) {
let endpoint_name = `/bank-statements-set/${document_id}/`;
let response = await this._request("GET", endpoint_name, {}, kwargs, false);
return response['data'];
}
23 changes: 23 additions & 0 deletions lib/bankstatements/getBankStatementSets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const Client = require('../client/constructor');
/**
* Get Bank Statement sets. https://docs.veryfi.com/api/get-bank-statement-sets/
*
* @memberof Client
* @param {number} page Page number
* @param {number} page_size Results per page
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.get_bank_statement_sets = async function (
page = 1,
page_size = 50,
{...kwargs} = {}
) {
let endpoint_name = "/bank-statements-set/";
let query = Object.assign({
"page": page,
"page_size": page_size,
}, kwargs);
let response = await this._request("GET", endpoint_name, {}, query, false);
return response['data'];
}
6 changes: 3 additions & 3 deletions lib/bankstatements/getBankStatements.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Client.prototype.get_bank_statements = async function (
{...kwargs} = {}
) {
let endpoint_name = `/bank-statements/`;
let request_arguments = {
let query = Object.assign({
"page": page,
"page_size": page_size,
"bounding_boxes": bounding_boxes,
"confidence_details": confidence_details
};
let document = await this._request("GET", endpoint_name, request_arguments, kwargs, false);
}, kwargs);
let document = await this._request("GET", endpoint_name, {}, query, false);
return document['data'];
}
31 changes: 31 additions & 0 deletions lib/bankstatements/processBankStatementAsync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const Client = require('../client/constructor');
const path = require('path');
const fs = require('fs');
/**
* Process a bank statement asynchronously. https://docs.veryfi.com/api/bank-statements/process-a-bank-statement-asynchronously/
* @example
* veryfi_client.process_bank_statement_async('file/path')
*
* @memberof Client
* @param {String} file_path Path on disk to a file to submit
* @param {boolean} bounding_boxes Return bounding_box and bounding_region for extracted fields.
* @param {boolean} confidence_details Return score and ocr_score fields.
* @param {Object} kwargs Additional request parameters
* @returns {JSON} API response data
*/
Client.prototype.process_bank_statement_async = async function (
file_path,
bounding_boxes = false,
confidence_details = false,
{...kwargs} = {}
) {
let file = fs.createReadStream(file_path);
let file_name = path.basename(file_path);
return this.process_bank_statement_async_from_stream(
file,
file_name,
bounding_boxes,
confidence_details,
kwargs
);
}
Loading
Loading