# ConfluenceLoader

> **Class** in `langchain_community`

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

Load `Confluence` pages.

Port of https://llamahub.ai/l/confluence
This currently supports username/api_key, Oauth2 login, personal access token
or cookies authentication.

Specify a list page_ids and/or space_key to load in the corresponding pages into
Document objects, if both are specified the union of both sets will be returned.

You can also specify a boolean `include_attachments` to include attachments, this
is set to False by default, if set to True all attachments will be downloaded and
ConfluenceLoader will extract the text from the attachments and add it to the
Document object. Currently supported attachment types are: PDF, PNG, JPEG/JPG,
SVG, Word and Excel.

Confluence API supports difference format of page content. The storage format is the
raw XML representation for storage. The view format is the HTML representation for
viewing with macros are rendered as though it is viewed by users. You can pass
a enum `content_format` argument to specify the content format, this is
set to `ContentFormat.STORAGE` by default, the supported values are:
`ContentFormat.EDITOR`, `ContentFormat.EXPORT_VIEW`,
`ContentFormat.ANONYMOUS_EXPORT_VIEW`, `ContentFormat.STORAGE`,
and `ContentFormat.VIEW`.

Hint: space_key and page_id can both be found in the URL of a page in Confluence
- https://yoursite.atlassian.com/wiki/spaces/<space_key>/pages/<page_id>

## Signature

```python
ConfluenceLoader(
    self,
    url: str,
    api_key: Optional[str] = None,
    username: Optional[str] = None,
    session: Optional[requests.Session] = None,
    oauth2: Optional[dict] = None,
    token: Optional[str] = None,
    cloud: Optional[bool] = True,
    number_of_retries: Optional[int] = 3,
    min_retry_seconds: Optional[int] = 2,
    max_retry_seconds: Optional[int] = 10,
    confluence_kwargs: Optional[dict] = None,
    *,
    cookies: Optional[dict] = None,
    space_key: Optional[str] = None,
    page_ids: Optional[List[str]] = None,
    label: Optional[str] = None,
    cql: Optional[str] = None,
    include_restricted_content: bool = False,
    include_archived_content: bool = False,
    include_attachments: bool = False,
    include_comments: bool = False,
    include_labels: bool = False,
    content_format: ContentFormat = ContentFormat.STORAGE,
    limit: Optional[int] = 50,
    max_pages: Optional[int] = 1000,
    ocr_languages: Optional[str] = None,
    keep_markdown_format: bool = False,
    keep_newlines: bool = False,
    attachment_filter_func: Optional[Callable[[dict], bool]] = None,
)
```

## Description

**Example:**

.. code-block:: python

from langchain_community.document_loaders import ConfluenceLoader

loader = ConfluenceLoader(
    url="https://yoursite.atlassian.com/wiki",
    username="me",
    api_key="12345",
    space_key="SPACE",
    limit=50,
)
documents = loader.load()

# Server on perm
loader = ConfluenceLoader(
    url="https://confluence.yoursite.com/",
    username="me",
    api_key="your_password",
    cloud=False,
    space_key="SPACE",
    limit=50,
)
documents = loader.load()

:param url: _description_
:type url: str
:param api_key: _description_, defaults to None
:type api_key: str, optional
:param username: _description_, defaults to None
:type username: str, optional
:param oauth2: _description_, defaults to {}
:type oauth2: dict, optional
:param token: _description_, defaults to None
:type token: str, optional
:param cloud: _description_, defaults to True
:type cloud: bool, optional
:param number_of_retries: How many times to retry, defaults to 3
:type number_of_retries: Optional[int], optional
:param min_retry_seconds: defaults to 2
:type min_retry_seconds: Optional[int], optional
:param max_retry_seconds:  defaults to 10
:type max_retry_seconds: Optional[int], optional
:param confluence_kwargs: additional kwargs to initialize confluence with
:type confluence_kwargs: dict, optional
:param cookies: _description_, defaults to {}
:type cookies: dict, optional
:param space_key: Space key retrieved from a confluence URL, defaults to None
:type space_key: Optional[str], optional
:param page_ids: List of specific page IDs to load, defaults to None
:type page_ids: Optional[List[str]], optional
:param label: Get all pages with this label, defaults to None
:type label: Optional[str], optional
:param cql: CQL Expression, defaults to None
:type cql: Optional[str], optional
:param include_restricted_content: defaults to False
:type include_restricted_content: bool, optional
:param include_archived_content: Whether to include archived content,
                                 defaults to False
:type include_archived_content: bool, optional
:param include_attachments: defaults to False
:type include_attachments: bool, optional
:param attachment_filter_func: A function that takes the attachment information
                               from Confluence and decides whether or not the
                               attachment is processed.
:param include_comments: defaults to False
:type include_comments: bool, optional
:param content_format: Specify content format, defaults to
                        ContentFormat.STORAGE, the supported values are:
                        `ContentFormat.EDITOR`, `ContentFormat.EXPORT_VIEW`,
                        `ContentFormat.ANONYMOUS_EXPORT_VIEW`,
                        `ContentFormat.STORAGE`, and `ContentFormat.VIEW`.
:type content_format: ContentFormat
:param limit: Maximum number of pages to retrieve per request, defaults to 50
:type limit: int, optional
:param max_pages: Maximum number of pages to retrieve in total, defaults 1000
:type max_pages: int, optional
:param ocr_languages: The languages to use for the Tesseract agent. To use a
                      language, you'll first need to install the appropriate
                      Tesseract language pack.
:type ocr_languages: str, optional
:param keep_markdown_format: Whether to keep the markdown format, defaults to
    False
:type keep_markdown_format: bool
:param keep_newlines: Whether to keep the newlines format, defaults to
    False
:type keep_newlines: bool
:raises ValueError: Errors while validating input
:raises ImportError: Required dependencies not installed.

## Extends

- `BaseLoader`

## Constructors

```python
__init__(
    self,
    url: str,
    api_key: Optional[str] = None,
    username: Optional[str] = None,
    session: Optional[requests.Session] = None,
    oauth2: Optional[dict] = None,
    token: Optional[str] = None,
    cloud: Optional[bool] = True,
    number_of_retries: Optional[int] = 3,
    min_retry_seconds: Optional[int] = 2,
    max_retry_seconds: Optional[int] = 10,
    confluence_kwargs: Optional[dict] = None,
    *,
    cookies: Optional[dict] = None,
    space_key: Optional[str] = None,
    page_ids: Optional[List[str]] = None,
    label: Optional[str] = None,
    cql: Optional[str] = None,
    include_restricted_content: bool = False,
    include_archived_content: bool = False,
    include_attachments: bool = False,
    include_comments: bool = False,
    include_labels: bool = False,
    content_format: ContentFormat = ContentFormat.STORAGE,
    limit: Optional[int] = 50,
    max_pages: Optional[int] = 1000,
    ocr_languages: Optional[str] = None,
    keep_markdown_format: bool = False,
    keep_newlines: bool = False,
    attachment_filter_func: Optional[Callable[[dict], bool]] = None,
)
```

| Name | Type |
|------|------|
| `url` | `str` |
| `api_key` | `Optional[str]` |
| `username` | `Optional[str]` |
| `session` | `Optional[requests.Session]` |
| `oauth2` | `Optional[dict]` |
| `token` | `Optional[str]` |
| `cloud` | `Optional[bool]` |
| `number_of_retries` | `Optional[int]` |
| `min_retry_seconds` | `Optional[int]` |
| `max_retry_seconds` | `Optional[int]` |
| `confluence_kwargs` | `Optional[dict]` |
| `cookies` | `Optional[dict]` |
| `space_key` | `Optional[str]` |
| `page_ids` | `Optional[List[str]]` |
| `label` | `Optional[str]` |
| `cql` | `Optional[str]` |
| `include_restricted_content` | `bool` |
| `include_archived_content` | `bool` |
| `include_attachments` | `bool` |
| `include_comments` | `bool` |
| `include_labels` | `bool` |
| `content_format` | `ContentFormat` |
| `limit` | `Optional[int]` |
| `max_pages` | `Optional[int]` |
| `ocr_languages` | `Optional[str]` |
| `keep_markdown_format` | `bool` |
| `keep_newlines` | `bool` |
| `attachment_filter_func` | `Optional[Callable[[dict], bool]]` |


## Properties

- `space_key`
- `page_ids`
- `label`
- `cql`
- `include_restricted_content`
- `include_archived_content`
- `include_attachments`
- `include_comments`
- `include_labels`
- `content_format`
- `limit`
- `max_pages`
- `ocr_languages`
- `keep_markdown_format`
- `keep_newlines`
- `attachment_filter_func`
- `base_url`
- `number_of_retries`
- `min_retry_seconds`
- `max_retry_seconds`
- `confluence`

## Methods

- [`validate_init_args()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/validate_init_args)
- [`load()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/load)
- [`lazy_load()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/lazy_load)
- [`paginate_request()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/paginate_request)
- [`is_public_page()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/is_public_page)
- [`process_pages()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_pages)
- [`process_page()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_page)
- [`process_attachment()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_attachment)
- [`process_pdf()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_pdf)
- [`process_image()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_image)
- [`process_doc()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_doc)
- [`process_xls()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_xls)
- [`process_svg()`](https://reference.langchain.com/python/langchain-community/document_loaders/confluence/ConfluenceLoader/process_svg)

---

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