0.10.6 • Published 2 months ago

unstructured-client v0.10.6

Weekly downloads
-
License
-
Repository
github
Last release
2 months ago

This is a Typescript client for the Unstructured API.

SDK Installation

NPM

npm install unstructured-client

Yarn

yarn add unstructured-client

SDK Example Usage

Only the files parameter is required. See the general partition page for all available parameters.

import { UnstructuredClient } from "unstructured-client";
import { PartitionResponse } from "unstructured-client/dist/sdk/models/operations";
import * as fs from "fs";

const key = "YOUR-API-KEY";

const client = new UnstructuredClient({
    security: {
        apiKeyAuth: key,
    },
});

const filename = "sample-docs/layout-parser-paper.pdf";
const data = fs.readFileSync(filename);

client.general.partition({
    // Note that this currently only supports a single file
    files: {
        content: data,
        fileName: filename,
    },
    // Other partition params
    strategy: "fast",
}).then((res: PartitionResponse) => {
    if (res.statusCode == 200) {
        console.log(res.elements);
    }
}).catch((e) => {
    console.log(e.statusCode);
    console.log(e.body);
});

Change the base URL

If you are self hosting the API, or developing locally, you can change the server URL when setting up the client.

const client = new UnstructuredClient({
    serverURL: "http://localhost:8000",
    security: {
        apiKeyAuth: key,
    },
});

// OR

const client = new UnstructuredClient({
    serverURL: "https://my-server-url",
    security: {
        apiKeyAuth: key,
    },
});

Custom HTTP Client

The Typescript SDK makes API calls using the axios HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom AxiosInstance object.

For example, you could specify a header for every request that your sdk makes as follows:

import { unstructured-client } from "UnstructuredClient";
import axios from "axios";

const httpClient = axios.create({
    headers: {'x-custom-header': 'someValue'}
})

const sdk = new UnstructuredClient({defaultClient: httpClient});

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy

0.10.6

2 months ago

0.10.5

2 months ago

0.10.4

3 months ago

0.10.2

4 months ago

0.10.0

5 months ago

0.9.4

5 months ago

0.9.0

6 months ago

0.8.1

6 months ago

0.8.0

7 months ago

0.9.2

6 months ago

0.9.1

6 months ago

0.8.2

6 months ago

0.7.0

7 months ago

0.6.0

7 months ago

0.5.1

7 months ago

0.4.1

7 months ago

0.4.0

7 months ago

0.3.3

7 months ago

0.3.2

7 months ago

0.3.1

7 months ago

0.3.0

7 months ago

0.2.0

8 months ago