OCR API
OCR API documentation for Python SDK
All URIs are relative to http://localhost:8080
| Method | HTTP request | Description |
|---|---|---|
| ocr_document | POST /v1/ocr:document | Run OCR on a document or image |
ocr_document
OcrDocumentResponse ocr_document(ocr_document_request)
Run OCR on a document or image
Runs layout-aware OCR on the provided document bytes and returns per-page results. When a page range is provided, only the inclusive subset is processed. Requires OCR_DOCUMENT permission.
Example
- Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.ocr_document_request import OcrDocumentRequest
from goodmem_client.models.ocr_document_response import OcrDocumentResponse
from goodmem_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
host = "http://localhost:8080/v1/default"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = goodmem_client.OCRApi(api_client)
ocr_document_request = {"content":"JVBERi0xLjQKJcTl8uXr...","format":"PDF","includeRawJson":"true","includeMarkdown":"true","startPage":"0","endPage":"4"} # OcrDocumentRequest | OCR request payload
try:
# Run OCR on a document or image
api_response = api_instance.ocr_document(ocr_document_request)
print("The response of OCRApi->ocr_document:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling OCRApi->ocr_document: %s\n" % e)Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ocr_document_request | OcrDocumentRequest | OCR request payload |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | OCR results by page | - |
| 400 | Invalid request or unsupported input | - |
| 401 | Unauthorized | - |
| 403 | Forbidden | - |
| 429 | Rate limit exceeded | - |
| 500 | Internal server error | - |