Tool

Load Confluence Pages and Attachments

LlamaIndex reader that loads Confluence pages and attachments by ID, space, label, or CQL.

Works with confluence

73
Spark score
out of 100
Updated 2 days ago
Version 0.14.23

Add to Favorites

Why it matters

Ingest and process content from your Confluence instance, including pages and attachments, to make it searchable and usable for AI applications.

Outcomes

What it gets done

01

Load pages by ID, space key, label, or CQL query.

02

Optionally include and extract text from attachments (PDF, images, Office docs).

03

Authenticate using API tokens, OAuth 2.0, or username/password.

04

Configure custom parsers for advanced attachment handling.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-confluence | bash

Overview

Confluence Loader

The Confluence Loader pulls pages from a Confluence cloud instance into LlamaIndex, selectable by page IDs, space, label, or CQL query, with optional attachment download and text-extraction (PDF, images, Word, Excel) and custom per-file-type parsers. Use it when you need Confluence pages, and optionally their attachments, loaded into LlamaIndex. It authenticates via OAuth 2.0, an API token, or a username/password pair.

What it does

The Confluence Loader loads pages from a Confluence cloud instance into LlamaIndex documents. You initialize ConfluenceReader with a base URL (must end in /wiki), then choose one of four mutually exclusive ways to select which pages to load: page_ids (a list of specific page IDs, optionally with include_children set to also pull every descendant page beneath them), space_key (all pages in a space, filterable by page_status: None for all statuses, current, archived, or draft), label (all pages with a given label), or cql (a Confluence Query Language search, for selection criteria the other three options cannot express).

When to use - and when NOT to

Use it when you need Confluence content -- specific pages, a whole space, labeled pages, or a CQL search -- loaded into LlamaIndex, optionally including attachments (PDF, PNG, JPEG/JPG, SVG, Word, and Excel are supported, with text extracted automatically). It checks for credentials in a fixed order -- oauth2, then api_token, then cookies, then a user_name/password pair, then the CONFLUENCE_API_TOKEN environment variable, then the CONFLUENCE_USERNAME/CONFLUENCE_PASSWORD environment variables -- so it is not usable without at least one of those set, and CONFLUENCE_PASSWORD must actually be an API token obtained from Atlassian, not your real account password.

Inputs and outputs

Install with:

pip install llama-index-readers-confluence

Key parameters: max_num_results caps how many pages come back (requests are batched to reach it; the older limit parameter is deprecated in its favor); start sets a page offset (only with space_key); cursor is the CQL-query equivalent of start, retrievable via get_next_cursor() after a search; and include_attachments (default False) downloads and text-extracts attachments when set to True.

For advanced use, custom_parsers lets you override how specific attachment file types are parsed -- a custom parser must implement LlamaIndex's BaseReader interface, for example a DOCX parser built on MarkItDown:

from typing import List, Union
import pathlib
from llama_index.core.readers.base import BaseReader
from llama_index.core.schema import Document
from markitdown import MarkItDown


class DocxParser(BaseReader):
    """DOCX parser using MarkItDown for text extraction."""

    def __init__(self):
        self.markitdown = MarkItDown()

    def load_data(
        self, file_path: Union[str, pathlib.Path], **kwargs
    ) -> List[Document]:
        """Load and parse a DOCX file."""
        result = self.markitdown.convert(source=file_path)

        return [
            Document(
                text=result.markdown, metadata={"file_path": str(file_path)}
            )
        ]

Who it's for

Developers building LlamaIndex pipelines that need Confluence content -- pages and their attachments -- loaded with fine control over which pages, how many, and how each attachment type gets parsed.

Source README

Confluence Loader

pip install llama-index-readers-confluence

This loader loads pages from a given Confluence cloud instance. The user needs to specify the base URL for a Confluence
instance to initialize the ConfluenceReader - base URL needs to end with /wiki.

The user can optionally specify OAuth 2.0 credentials to authenticate with the Confluence instance. If no credentials are
specified, the loader will look for CONFLUENCE_API_TOKEN or CONFLUENCE_USERNAME/CONFLUENCE_PASSWORD environment variables
to proceed with basic authentication.

The following order is used for checking authentication credentials:

  1. oauth2
  2. api_token
  3. cookies
  4. user_name and password
  5. Environment variable CONFLUENCE_API_TOKEN
  6. Environment variable CONFLUENCE_USERNAME and CONFLUENCE_PASSWORD

For more on authenticating using OAuth 2.0, checkout:

Confluence pages are obtained through one of 4 four mutually exclusive ways:

  1. page_ids: Load all pages from a list of page ids
  2. space_key: Load all pages from a space
  3. label: Load all pages with a given label
  4. cql: Load all pages that match a given CQL query (Confluence Query Language https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/ ).

When page_ids is specified, include_children will cause the loader to also load all descendent pages.
When space_key is specified, page_status further specifies the status of pages to load: None, 'current', 'archived', 'draft'.

limit (int): Deprecated, use max_num_results instead.

max_num_results (int): Maximum number of results to return. If None, return all results. Requests are made in batches to achieve the desired number of results.

start(int): Which offset we should jump to when getting pages, only works with space_key

cursor(str): An alternative to start for cql queries, the cursor is a pointer to the next "page" when searching atlassian products. The current one after a search can be found with get_next_cursor()

User 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
ConfluenceReader 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.

Advanced Configuration

The ConfluenceReader supports several advanced configuration options for customizing the reading behavior:

Custom Parsers: You can provide custom parsers for specific file types using the custom_parsers parameter. This allows you to override the default parsing behavior for attachments of different types.

Custom parsers must implement the LlamaIndex BaseReader interface. Here's an example for DOCX files using MarkItDown:

from typing import List, Union
import pathlib
from llama_index.core.readers.base import BaseReader
from llama_index.core.schema import Document
from markitdown import MarkItDown


class DocxParser(BaseReader):
    """DOCX parser using MarkItDown for text extraction."""

    def __init__(self):
        self.markitdown = MarkItDown()

    def load_data(
        self, file_path: Union[str, pathlib.Path], **kwargs
    ) -> List[Document]:
        """Load and parse a DOCX file."""
        result = self.markitdown.convert(source=file_path)

        return [
            Document(
                text=result.markdown, metadata={"file_path": str(file_path)}
            )
        ]


#### Usage with ConfluenceReader - Multiple file type parsers
from parsers import DocxParser
from readers.confluence_reader import FileType as ConfluenceFileType

confluence_parsers = {

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.