> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-lsapi-1779323176-451247e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# UnstructuredLoader integration

> Integrate with the UnstructuredLoader document loader using LangChain JavaScript.

<Tip>
  **Compatibility**: Only available on Node.js.
</Tip>

This notebook provides a quick overview for getting started with `UnstructuredLoader` [document loaders](/oss/javascript/integrations/document_loaders). For detailed documentation of all `UnstructuredLoader` features and configurations head to the [API reference](https://reference.langchain.com/javascript/langchain-community/document_loaders/fs/unstructured/UnstructuredLoader).

## Overview

### Integration details

| Class                                                                                                                                      | Package                                                                      | Compatibility | Local | [PY support](https://python.langchain.com/docs/integrations/document_loaders/unstructured_file) |
| :----------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- | :-----------: | :---: | :---------------------------------------------------------------------------------------------: |
| [`UnstructuredLoader`](https://reference.langchain.com/javascript/langchain-community/document_loaders/fs/unstructured/UnstructuredLoader) | [`@langchain/community`](https://www.npmjs.com/package/@langchain/community) |   Node-only   |   ✅   |                                                ✅                                                |

## Setup

To access `UnstructuredLoader` document loader you'll need to install the `@langchain/community` integration package, and create an Unstructured account and get an API key.

### Local

You can run Unstructured locally in your computer using Docker. To do so, you need to have [Docker installed](https://docs.docker.com/get-docker/).

```bash theme={null}
docker run -p 8000:8000 -d --rm --name unstructured-api downloads.unstructured.io/unstructured-io/unstructured-api:latest --port 8000 --host 0.0.0.0
```

### Credentials

Head to [unstructured.io](https://unstructured.io/api-key-hosted) to sign up to Unstructured and generate an API key. Once you've done this set the `UNSTRUCTURED_API_KEY` environment variable:

```bash theme={null}
export UNSTRUCTURED_API_KEY="your-api-key"
```

### Installation

The LangChain UnstructuredLoader integration lives in the `@langchain/community` package:

<CodeGroup>
  ```bash npm theme={null}
  npm install @langchain/community @langchain/core
  ```

  ```bash yarn theme={null}
  yarn add @langchain/community @langchain/core
  ```

  ```bash pnpm theme={null}
  pnpm add @langchain/community @langchain/core
  ```
</CodeGroup>

## Instantiation

Now we can instantiate our model object and load documents:

```typescript theme={null}
import { UnstructuredLoader } from "@langchain/community/document_loaders/fs/unstructured"

const loader = new UnstructuredLoader("../../../../../../examples/src/document_loaders/example_data/notion.mdx")
```

## Load

```typescript theme={null}
const docs = await loader.load()
docs[0]
```

```javascript theme={null}
Document {
  pageContent: '# Testing the notion markdownloader',
  metadata: {
    filename: 'notion.mdx',
    languages: [ 'eng' ],
    filetype: 'text/plain',
    category: 'NarrativeText'
  },
  id: undefined
}
```

```typescript theme={null}
console.log(docs[0].metadata)
```

```javascript theme={null}
{
  filename: 'notion.mdx',
  languages: [ 'eng' ],
  filetype: 'text/plain',
  category: 'NarrativeText'
}
```

## Directories

You can also load all of the files in the directory using [`UnstructuredDirectoryLoader`](https://reference.langchain.com/javascript/langchain-community/document_loaders/fs/unstructured/UnstructuredDirectoryLoader), which inherits from [`DirectoryLoader`](/oss/javascript/integrations/document_loaders/file_loaders/directory):

```typescript theme={null}
import { UnstructuredDirectoryLoader } from "@langchain/community/document_loaders/fs/unstructured";

const directoryLoader = new UnstructuredDirectoryLoader(
  "../../../../../../examples/src/document_loaders/example_data/",
  {}
);
const directoryDocs = await directoryLoader.load();
console.log("directoryDocs.length: ", directoryDocs.length);
console.log(directoryDocs[0])

```

```text theme={null}
Unknown file type: Star_Wars_The_Clone_Wars_S06E07_Crisis_at_the_Heart.srt
Unknown file type: test.mp3
```

```javascript theme={null}
directoryDocs.length:  247
Document {
  pageContent: 'Bitcoin: A Peer-to-Peer Electronic Cash System',
  metadata: {
    filetype: 'application/pdf',
    languages: [ 'eng' ],
    page_number: 1,
    filename: 'bitcoin.pdf',
    category: 'Title'
  },
  id: undefined
}
```

***

## API reference

For detailed documentation of all `UnstructuredLoader` features and configurations head to the [API reference](https://reference.langchain.com/javascript/langchain-community/document_loaders/fs/unstructured/UnstructuredLoader).

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/document_loaders/file_loaders/unstructured.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
