# NeedleLoader

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/document_loaders/needle/NeedleLoader)

NeedleLoader is a document loader for managing documents stored in a collection.

## Signature

```python
NeedleLoader(
    self,
    needle_api_key: Optional[str] = None,
    collection_id: Optional[str] = None,
)
```

## Description

**Setup:**

Install the `needle-python` library and set your Needle API key.

.. code-block:: bash

    pip install needle-python
    export NEEDLE_API_KEY="your-api-key"

**Key init args:**

- `needle_api_key` (Optional[str]): API key for authenticating with Needle.
- `collection_id` (str): Needle collection to load documents from.

**Usage:**

.. code-block:: python

from langchain_community.document_loaders.needle import NeedleLoader

loader = NeedleLoader(
    needle_api_key="your-api-key",
    collection_id="your-collection-id"
)

# Load documents
documents = loader.load()
for doc in documents:
    print(doc.metadata)

# Lazy load documents
for doc in loader.lazy_load():
    print(doc.metadata)

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `needle_api_key` | `Optional[str]` | No | API key for authenticating with Needle. (default: `None`) |
| `collection_id` | `Optional[str]` | No | Identifier for the Needle collection. (default: `None`) |

## Extends

- `BaseLoader`

## Constructors

```python
__init__(
    self,
    needle_api_key: Optional[str] = None,
    collection_id: Optional[str] = None,
) -> None
```

| Name | Type |
|------|------|
| `needle_api_key` | `Optional[str]` |
| `collection_id` | `Optional[str]` |


## Properties

- `needle_api_key`
- `collection_id`
- `client`

## Methods

- [`add_files()`](https://reference.langchain.com/python/langchain-community/document_loaders/needle/NeedleLoader/add_files)
- [`load()`](https://reference.langchain.com/python/langchain-community/document_loaders/needle/NeedleLoader/load)
- [`lazy_load()`](https://reference.langchain.com/python/langchain-community/document_loaders/needle/NeedleLoader/lazy_load)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/document_loaders/needle.py#L7)