Skip to content

Latest commit

 

History

History
270 lines (194 loc) · 19.7 KB

File metadata and controls

270 lines (194 loc) · 19.7 KB

ExtractTables

(files.extractTables)

Overview

Extract tables from files

Available Operations

  • sync - Extract Tables - Sync
  • start - Extract Tables - Async Start
  • result - Extract Tables - Async Result

sync

Extracts tables from a file. Supported file types are image, pdf (more coming soon!). It accepts the file.

Example Usage

import { IntunedClient } from "@intuned/client";

const intunedClient = new IntunedClient({
  apiKey: "<YOUR_API_KEY_HERE>",
  workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});

async function run() {
  const result = await intunedClient.files.extractTables.sync({
      type: "pdf",
    source:     {
          type: "url",
          data: "http://unconscious-margin.name",
        },
    });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { IntunedClientCore } from "@intuned/client/core.js";
import { filesExtractTablesSync } from "@intuned/client/funcs/filesExtractTablesSync.js";

// Use `IntunedClientCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const intunedClient = new IntunedClientCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});

async function run() {
  const res = await filesExtractTablesSync(intunedClient, {
      type: "image",
    source:     {
          type: "base64",
          data: "<value>",
        },
    });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
file components.FileT ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.TableExtractionSyncResponse>

Errors

Error Object Status Code Content Type
errors.ApiErrorInvalidInput 400 application/json
errors.ApiErrorUnauthorized 401 application/json
errors.SDKError 4xx-5xx /

start

Starts an asynchronous operation to extract tables from a file. Supported file types are image, pdf (more coming soon!). This methods accepts the file. The API responds with an ID to track the operation status and retrieve the result.

Example Usage

import { IntunedClient } from "@intuned/client";

const intunedClient = new IntunedClient({
  apiKey: "<YOUR_API_KEY_HERE>",
  workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});

async function run() {
  const result = await intunedClient.files.extractTables.start({
      type: "image",
    source:     {
          type: "base64",
          data: "<value>",
        },
    });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { IntunedClientCore } from "@intuned/client/core.js";
import { filesExtractTablesStart } from "@intuned/client/funcs/filesExtractTablesStart.js";

// Use `IntunedClientCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const intunedClient = new IntunedClientCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});

async function run() {
  const res = await filesExtractTablesStart(intunedClient, {
      type: "pdf",
    source:     {
          type: "base64",
          data: "<value>",
        },
    });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
file components.FileT ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AsyncFilePendingResponse>

Errors

Error Object Status Code Content Type
errors.ApiErrorInvalidInput 400 application/json
errors.ApiErrorUnauthorized 401 application/json
errors.SDKError 4xx-5xx /

result

Gets the result of the tables extraction operation using the operation ID.

Example Usage

import { IntunedClient } from "@intuned/client";

const intunedClient = new IntunedClient({
  apiKey: "<YOUR_API_KEY_HERE>",
  workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});

async function run() {
  const result = await intunedClient.files.extractTables.result("aaaabbbCCCCdddd");

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { IntunedClientCore } from "@intuned/client/core.js";
import { filesExtractTablesResult } from "@intuned/client/funcs/filesExtractTablesResult.js";

// Use `IntunedClientCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const intunedClient = new IntunedClientCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});

async function run() {
  const res = await filesExtractTablesResult(intunedClient, "aaaabbbCCCCdddd");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
operationId string ✔️ The ID for the requested file operation. This is obtained from the start request. [object Object]
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.TableExtractionAsyncResponse>

Errors

Error Object Status Code Content Type
errors.ApiErrorInvalidInput 400 application/json
errors.ApiErrorUnauthorized 401 application/json
errors.SDKError 4xx-5xx /