### Get Job Status Go Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using the net/http package to perform a GET request. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/jobs/job_id" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Job Status Swift Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using URLSession to perform a GET request. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/jobs/job_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Submit Job SDK Example (Python) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using the requests library to submit a job. ```python import requests url = "https://api.example.com/jobs" response = requests.post(url) print(response.json()) ``` -------------------------------- ### Submit Job SDK Example (Go) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using the net/http package to submit a job. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/jobs" req, _ := http.NewRequest("POST", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Submit Job SDK Example (Swift) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using URLSession to submit a job. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/jobs")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Submit Job SDK Example (Ruby) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using the Net::HTTP library to submit a job. ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/jobs") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Submit Job SDK Example (Java) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using the Unirest library to submit a job. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/jobs") .asString(); ``` -------------------------------- ### Submit Job SDK Example (PHP) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using the GuzzleHttp client to submit a job. ```php request('POST', 'https://api.example.com/jobs'); echo $response->getBody(); ``` -------------------------------- ### Submit Job SDK Example (JavaScript) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using the fetch API to submit a job. ```javascript const url = 'https://api.example.com/jobs'; const options = {method: 'POST'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Submit Job SDK Example (C#) Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example using the RestSharp library to submit a job. ```csharp using RestSharp; var client = new RestClient("https://api.example.com/jobs"); var request = new RestRequest(Method.POST); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get Job Status PHP Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using GuzzleHttp to perform a GET request. ```php request('GET', 'https://api.example.com/jobs/job_id'); echo $response->getBody(); ``` -------------------------------- ### Get Job Status Java Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using the Unirest library to fetch job status. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.example.com/jobs/job_id") .asString(); ``` -------------------------------- ### Get Job Status Python Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using the requests library to fetch job status. ```python import requests url = "https://api.example.com/jobs/job_id" response = requests.get(url) print(response.json()) ``` -------------------------------- ### Get Job Status Ruby Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using Net::HTTP to retrieve job status. ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/jobs/job_id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Job Status JavaScript Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using the fetch API to retrieve job status. ```javascript const url = 'https://api.example.com/jobs/job_id'; const options = {method: 'GET'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Get Job Status C# Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Example using RestSharp to retrieve job status. ```csharp using RestSharp; var client = new RestClient("https://api.example.com/jobs/job_id"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Delete Job Go SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses the net/http package to execute a DELETE request. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/jobs/job_id" req, _ := http.NewRequest("DELETE", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Healthz Response Example Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get The expected successful response body for the /healthz endpoint. ```json {} ``` -------------------------------- ### Delete Job Java SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses the Unirest library to execute a DELETE request. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.delete("https://api.example.com/jobs/job_id") .asString(); ``` -------------------------------- ### Submit Job via cURL Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Example of submitting a file using the cURL command-line tool with the required X-Filename header. ```bash curl -X POST --data-binary @doc.pdf -H 'Content-Type: application/pdf' \ -H 'X-Filename: doc.pdf' http://host:8200/jobs ``` -------------------------------- ### Delete Job Swift SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses URLSession to perform a DELETE request. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/jobs/job_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "DELETE" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Delete Job Ruby SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses the Net::HTTP library to perform a DELETE request. ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/jobs/job_id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Delete Job PHP SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses the GuzzleHttp client to perform a DELETE request. ```php request('DELETE', 'https://api.example.com/jobs/job_id'); echo $response->getBody(); ``` -------------------------------- ### Fetch Job Result in Go Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses the net/http package to perform a GET request and read the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/jobs/job_id/result" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### GET /jobs Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieves a list of all OCR jobs currently in the system. ```APIDOC ## GET /jobs ### Description Retrieves a list of all OCR jobs currently in the system. ### Method GET ### Endpoint /jobs ### Response #### Success Response (200) - **list of object** - A list of job objects. - **job_id** (string) - Required - Unique identifier for the job. - **filename** (string) - Required - The name of the file being processed. - **state** (enum) - Required - The current status of the job (queued, rendering, ocr, done, failed). - **created_at** (string) - Required - Timestamp of when the job was created. - **mime_type** (enum) - Optional - The MIME type of the file (application/pdf, image/jpeg, image/png, image/tiff). #### Response Example [ { "job_id": "string", "filename": "string", "state": "queued", "created_at": "string", "mime_type": "application/pdf" } ] ``` -------------------------------- ### Delete Job C# SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses the RestSharp library to execute a DELETE request. ```csharp using RestSharp; var client = new RestClient("https://api.example.com/jobs/job_id"); var request = new RestRequest(Method.DELETE); IRestResponse response = client.Execute(request); ``` -------------------------------- ### GET /jobs/{job_id} Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Retrieves the status and metadata for a specific job. ```APIDOC ## GET /jobs/{job_id} ### Description Retrieves the current status, processing progress, and timing details for a specific OCR job. ### Method GET ### Endpoint /jobs/{job_id} ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the job. ### Response #### Success Response (200) - **job_id** (string) - The unique job identifier. - **filename** (string) - The name of the file being processed. - **state** (string) - The current state of the job (e.g., queued). - **created_at** (string) - Timestamp of job creation. - **updated_at** (string) - Timestamp of last update. - **render** (object) - Rendering progress details. - **ocr** (object) - OCR processing progress details. - **mime_type** (string) - The MIME type of the file. - **finished_at** (string) - Timestamp when the job finished. - **results_expire_at** (string) - Expiration timestamp for results. - **results_purged_at** (string) - Timestamp when results were purged. - **purge_reason** (string) - Reason for purging. - **purged_by** (string) - User or system that purged the job. - **error** (string) - Error message if the job failed. - **page_timings** (object) - Detailed timing metrics for rendering and OCR per page. - **result_available** (boolean) - Indicates if results are ready for retrieval. #### Response Example { "job_id": "string", "filename": "string", "state": "queued", "created_at": "string", "updated_at": "string", "render": { "total_pages": 1, "rendered": 0, "failed": 0, "loaded_from_log": 0, "in_flight_pages": 0 }, "ocr": { "submitted": 0, "completed": 0, "failed": 0, "in_flight": 0 }, "mime_type": "application/pdf", "finished_at": "string", "results_expire_at": "string", "results_purged_at": "string", "purge_reason": "expired", "purged_by": "string", "error": "string", "page_timings": { "render": { "count": 0, "total_ms": 0, "min_ms": 1.1, "max_ms": 1.1, "mean_ms": 1.1, "p50_ms": 1.1, "p95_ms": 1.1, "slowest_page": 1 }, "ocr": { "count": 0, "total_ms": 0, "min_ms": 1.1, "max_ms": 1.1, "mean_ms": 1.1, "p50_ms": 1.1, "p95_ms": 1.1, "slowest_page": 1 }, "span_ms": 1.1, "pages": [ { "page": 1, "render_start_ms": 1.1, "render_end_ms": 1.1, "render_ms": 1.1, "ocr_start_ms": 1.1, "ocr_end_ms": 1.1, "ocr_ms": 1.1 } ] }, "ocr_service": {}, "page_budget": {}, "render_pool": {}, "result_available": false } ``` -------------------------------- ### GET /healthz Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Retrieves the health status of the service. ```APIDOC ## GET /healthz ### Description Checks the health status of the service to ensure it is operational. ### Method GET ### Endpoint /healthz ### Response #### Success Response (200) - **body** (map from string to string) - Successful response indicating service health. #### Response Example {} ``` -------------------------------- ### Fetch Job Result in PHP Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses the GuzzleHttp client to perform a GET request. ```php request('GET', 'https://api.example.com/jobs/job_id/result'); echo $response->getBody(); ``` -------------------------------- ### Fetch Job Result in C# Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses the RestSharp library to execute a GET request. ```csharp using RestSharp; var client = new RestClient("https://api.example.com/jobs/job_id/result"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Delete Job JavaScript SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses the fetch API to perform a DELETE request asynchronously. ```javascript const url = 'https://api.example.com/jobs/job_id'; const options = {method: 'DELETE'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Fetch Job Result in Swift Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses URLSession to perform an asynchronous GET request. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/jobs/job_id/result")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Fetch Job Result in Ruby Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses the Net::HTTP library to perform a GET request over SSL. ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/jobs/job_id/result") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Delete Job Python SDK Example Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Uses the requests library to send a DELETE request to the job endpoint. ```python import requests url = "https://api.example.com/jobs/job_id" response = requests.delete(url) print(response.json()) ``` -------------------------------- ### Java Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using the Unirest library. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.example.com/healthz") .asString(); ``` -------------------------------- ### PHP Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using GuzzleHttp. ```php request('GET', 'https://api.example.com/healthz'); echo $response->getBody(); ``` -------------------------------- ### Go Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using the net/http package. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/healthz" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### C# Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using RestSharp. ```csharp using RestSharp; var client = new RestClient("https://api.example.com/healthz"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Swift Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using URLSession. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/healthz")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Response JSON Structure Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get The expected JSON response format for a successful GET /jobs request. ```json [ { "job_id": "string", "filename": "string", "state": "queued", "created_at": "string", "mime_type": "application/pdf" } ] ``` -------------------------------- ### Fetch Job Result in Java Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses the Unirest library to perform a GET request and retrieve the response as a string. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.example.com/jobs/job_id/result") .asString(); ``` -------------------------------- ### Python Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using the requests library. ```python import requests url = "https://api.example.com/healthz" response = requests.get(url) print(response.json()) ``` -------------------------------- ### JavaScript Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using the fetch API. ```javascript const url = 'https://api.example.com/healthz'; const options = {method: 'GET'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Fetch Job Result in Python Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses the requests library to perform a GET request to the job result endpoint. ```python import requests url = "https://api.example.com/jobs/job_id/result" response = requests.get(url) print(response.json()) ``` -------------------------------- ### Ruby Healthz Request Source: https://docs.emtelligent.com/ocr/api/healthz-healthz-get Perform a GET request to the healthz endpoint using Net::HTTP. ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/healthz") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### GET /jobs/{job_id}/result Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Fetches the result.json for a specific job. Returns 409 if the job is not yet done, and 410 if the results have been purged or passed their retention TTL. ```APIDOC ## GET /jobs/{job_id}/result ### Description Fetch the result.json file for a completed OCR job. The response returns 409 if the job state is not 'done', and 410 if the results are purged or past their retention TTL. ### Method GET ### Endpoint /jobs/{job_id}/result ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the job. #### Query Parameters - **timings** (boolean) - Optional - If set to true, folds the job's per-page render/OCR timings into the response under 'page_timings'. Defaults to false. ### Response #### Success Response (200) - **result** (any) - The content of the result.json file. ``` -------------------------------- ### GET /jobs/{job_id} Source: https://docs.emtelligent.com/ocr/api/job-status-jobs-job-id-get Retrieves the status of a specific OCR job by its ID. Optionally includes detailed page-level timing metrics. ```APIDOC ## GET /jobs/{job_id} ### Description Retrieves the pipeline status, counters, and service gauges for a specific OCR job. Use the `timings` query parameter to include detailed per-page timing statistics. ### Method GET ### Endpoint /jobs/{job_id} ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the job. #### Query Parameters - **timings** (boolean) - Optional - If true, includes `page_timings` in the response. Defaults to false. ### Response #### Success Response (200) - **job_id** (string) - The job identifier. - **filename** (string) - The name of the file being processed. - **state** (enum) - Current job state: queued, rendering, ocr, done, failed. - **created_at** (string) - Timestamp of job creation. - **updated_at** (string) - Timestamp of last update. - **render** (object) - Rendering progress metrics. - **ocr** (object) - OCR processing progress metrics. - **mime_type** (enum) - File type: application/pdf, image/jpeg, image/png, image/tiff. - **finished_at** (string) - Completion timestamp. - **results_expire_at** (string) - Expiration timestamp for results. - **results_purged_at** (string) - Purge timestamp. - **purge_reason** (enum) - Reason for artifact removal: expired, deleted. - **purged_by** (string) - User or system that purged the job. - **error** (string) - Error message if the job failed. - **page_timings** (object) - Detailed per-page timing metrics (if requested). - **ocr_service** (map) - OCR service metrics. - **page_budget** (map) - Page budget configuration. - **render_pool** (map) - Render pool metrics. - **result_available** (boolean) - Indicates if results are ready. ``` -------------------------------- ### List Jobs Request in Go Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using the net/http package. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/jobs" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Create a Session Source: https://docs.emtelligent.com/ocr/quickstart-code-example Initialize a requests session with the API key as a bearer token for authentication. ```python import os import requests BASE = "https://ocr.emtelligent.com" session = requests.Session() session.headers["Authorization"] = f"Bearer {os.environ['OCR_API_KEY']}" ``` -------------------------------- ### Submit a Document Source: https://docs.emtelligent.com/ocr/quickstart-code-example Post a file as the raw request body. The X-Filename header is optional and sets the job display name. ```python with open("report.pdf", "rb") as fp: response = session.post( f"{BASE}/jobs", data=fp, headers={"X-Filename": "report.pdf"}, ) response.raise_for_status() job_id = response.json()["job_id"] ``` -------------------------------- ### List Jobs Request in Ruby Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using Net::HTTP. ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/jobs") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Set OCR API Key Source: https://docs.emtelligent.com/ocr/quickstart-code-example Set the API key in your environment variable before running the client. ```bash export OCR_API_KEY='...' ``` -------------------------------- ### List Jobs Request in Java Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using the Unirest library. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.example.com/jobs") .asString(); ``` -------------------------------- ### List Jobs Request in Swift Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using URLSession. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/jobs")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### List Jobs Request in Python Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using the requests library. ```python import requests url = "https://api.example.com/jobs" response = requests.get(url) print(response.json()) ``` -------------------------------- ### Complete OCR Script Source: https://docs.emtelligent.com/ocr/quickstart-code-example A full implementation of the OCR workflow in a single script. ```python import os import time import requests BASE = "https://ocr.emtelligent.com" session = requests.Session() session.headers["Authorization"] = f"Bearer {os.environ['OCR_API_KEY']}" def ocr(path): """Submit one file and return its OCR result.""" with open(path, "rb") as fp: response = session.post( f"{BASE}/jobs", data=fp, headers={"X-Filename": os.path.basename(path)}, ) response.raise_for_status() job_id = response.json()["job_id"] while True: status = session.get(f"{BASE}/jobs/{job_id}").json() if status["state"] in ("done", "failed"): break time.sleep(2) if status["state"] == "failed": raise RuntimeError(status.get("error") or "OCR failed") return session.get(f"{BASE}/jobs/{job_id}/result").json() if __name__ == "__main__": print(ocr("report.pdf")) ``` -------------------------------- ### List Jobs Request in JavaScript Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using the fetch API. ```javascript const url = 'https://api.example.com/jobs'; const options = {method: 'GET'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### List Jobs Request in PHP Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using GuzzleHttp. ```php request('GET', 'https://api.example.com/jobs'); echo $response->getBody(); ``` -------------------------------- ### POST /jobs Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post Submits an input file as a raw request body for OCR processing. The file format is automatically detected from the file signature. ```APIDOC ## POST /jobs ### Description Submit an input file as a raw request body, streamed to disk. Accepted formats include PDF, PNG, JPEG, and TIFF. ### Method POST ### Endpoint /jobs ### Parameters #### Headers - **x-filename** (string) - Optional - Optional display name for the job, percent-encoded as UTF-8. ### Request Example curl -X POST --data-binary @doc.pdf -H 'Content-Type: application/pdf' -H 'X-Filename: doc.pdf' http://host:8200/jobs ### Response #### Success Response (201) - **job_id** (string) - Unique identifier for the job. - **filename** (string) - The display name of the job. - **mime_type** (enum) - The detected MIME type of the file (application/pdf, image/jpeg, image/png, image/tiff). - **state** (enum) - Current state of the job (queued, rendering, ocr, done, failed). - **bytes_received** (integer) - Total bytes received. - **status_url** (string) - URL to check job status. - **result_url** (string) - URL to retrieve job results. #### Response Example { "job_id": "string", "filename": "string", "mime_type": "application/pdf", "state": "queued", "bytes_received": 1, "status_url": "string", "result_url": "string" } ``` -------------------------------- ### List Jobs Request in C# Source: https://docs.emtelligent.com/ocr/api/list-jobs-jobs-get Retrieving the list of jobs using RestSharp. ```csharp using RestSharp; var client = new RestClient("https://api.example.com/jobs"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Delete Job Source: https://docs.emtelligent.com/ocr/quickstart-code-example Release the input file and rendered pages by deleting the job. ```python session.delete(f"{BASE}/jobs/{job_id}") ``` -------------------------------- ### Fetch Job Result in JavaScript Source: https://docs.emtelligent.com/ocr/api/job-result-jobs-job-id-result-get Uses the fetch API to retrieve the job result asynchronously. ```javascript const url = 'https://api.example.com/jobs/job_id/result'; const options = {method: 'GET'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### DELETE /jobs/{job_id} Source: https://docs.emtelligent.com/ocr/api/delete-job-jobs-job-id-delete Purge a job's content artifacts (result, input file, rendered pages). If the job is still running, it is cancelled first and recorded as failed. Deleting an already-purged job is a 204 no-op. ```APIDOC ## DELETE /jobs/{job_id} ### Description Purge a job's content artifacts (result, input file, rendered pages). The job's metadata remains queryable, and the operation is idempotent. ### Method DELETE ### Endpoint /jobs/{job_id} ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the job to delete. ### Response #### Success Response (204) - Successful Response ``` -------------------------------- ### Submit Job Response JSON Source: https://docs.emtelligent.com/ocr/api/submit-job-jobs-post The structure of the successful 201 response returned by the API. ```json { "job_id": "string", "filename": "string", "mime_type": "application/pdf", "state": "queued", "bytes_received": 1, "status_url": "string", "result_url": "string" } ``` -------------------------------- ### Wait for Job Completion Source: https://docs.emtelligent.com/ocr/quickstart-code-example Poll the status endpoint until the job reaches a terminal state of done or failed. ```python import time while True: status = session.get(f"{BASE}/jobs/{job_id}").json() if status["state"] in ("done", "failed"): break time.sleep(2) if status["state"] == "failed": raise RuntimeError(status.get("error") or "OCR failed") ``` -------------------------------- ### Read Result Source: https://docs.emtelligent.com/ocr/quickstart-code-example Retrieve the OCR result after the job is complete. ```python result = session.get(f"{BASE}/jobs/{job_id}/result").json() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.