# AstraDBLoader

> **Class** in `langchain_community`

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

## Signature

```python
AstraDBLoader(
    self,
    collection_name: str,
    *,
    token: Optional[str] = None,
    api_endpoint: Optional[str] = None,
    astra_db_client: Optional[AstraDB] = None,
    async_astra_db_client: Optional[AsyncAstraDB] = None,
    namespace: Optional[str] = None,
    filter_criteria: Optional[Dict[str, Any]] = None,
    projection: Optional[Dict[str, Any]] = None,
    find_options: Optional[Dict[str, Any]] = None,
    nb_prefetched: int = 1000,
    extraction_function: Callable[[Dict], str] = json.dumps,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection_name` | `str` | Yes | name of the Astra DB collection to use. |
| `token` | `Optional[str]` | No | API token for Astra DB usage. (default: `None`) |
| `api_endpoint` | `Optional[str]` | No | full URL to the API endpoint, such as `https://<DB-ID>-us-east1.apps.astra.datastax.com`. (default: `None`) |
| `astra_db_client` | `Optional[AstraDB]` | No | *alternative to token+api_endpoint*, you can pass an already-created 'astrapy.db.AstraDB' instance. (default: `None`) |
| `async_astra_db_client` | `Optional[AsyncAstraDB]` | No | *alternative to token+api_endpoint*, you can pass an already-created 'astrapy.db.AsyncAstraDB' instance. (default: `None`) |
| `namespace` | `Optional[str]` | No | namespace (aka keyspace) where the collection is. Defaults to the database's "default namespace". (default: `None`) |
| `filter_criteria` | `Optional[Dict[str, Any]]` | No | Criteria to filter documents. (default: `None`) |
| `projection` | `Optional[Dict[str, Any]]` | No | Specifies the fields to return. (default: `None`) |
| `find_options` | `Optional[Dict[str, Any]]` | No | Additional options for the query. (default: `None`) |
| `nb_prefetched` | `int` | No | Max number of documents to pre-fetch. Defaults to 1000. (default: `1000`) |
| `extraction_function` | `Callable[[Dict], str]` | No | Function applied to collection documents to create the `page_content` of the LangChain Document. Defaults to `json.dumps`. (default: `json.dumps`) |

## Extends

- `BaseLoader`

## Constructors

```python
__init__(
    self,
    collection_name: str,
    *,
    token: Optional[str] = None,
    api_endpoint: Optional[str] = None,
    astra_db_client: Optional[AstraDB] = None,
    async_astra_db_client: Optional[AsyncAstraDB] = None,
    namespace: Optional[str] = None,
    filter_criteria: Optional[Dict[str, Any]] = None,
    projection: Optional[Dict[str, Any]] = None,
    find_options: Optional[Dict[str, Any]] = None,
    nb_prefetched: int = 1000,
    extraction_function: Callable[[Dict], str] = json.dumps,
) -> None
```

| Name | Type |
|------|------|
| `collection_name` | `str` |
| `token` | `Optional[str]` |
| `api_endpoint` | `Optional[str]` |
| `astra_db_client` | `Optional[AstraDB]` |
| `async_astra_db_client` | `Optional[AsyncAstraDB]` |
| `namespace` | `Optional[str]` |
| `filter_criteria` | `Optional[Dict[str, Any]]` |
| `projection` | `Optional[Dict[str, Any]]` |
| `find_options` | `Optional[Dict[str, Any]]` |
| `nb_prefetched` | `int` |
| `extraction_function` | `Callable[[Dict], str]` |


## Properties

- `astra_env`
- `collection`
- `collection_name`
- `filter`
- `projection`
- `find_options`
- `nb_prefetched`
- `extraction_function`

## Methods

- [`lazy_load()`](https://reference.langchain.com/python/langchain-community/document_loaders/astradb/AstraDBLoader/lazy_load)
- [`aload()`](https://reference.langchain.com/python/langchain-community/document_loaders/astradb/AstraDBLoader/aload)
- [`alazy_load()`](https://reference.langchain.com/python/langchain-community/document_loaders/astradb/AstraDBLoader/alazy_load)

## ⚠️ Deprecated

Deprecated since version 0.0.29.

---

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