LlamaIndex Confluence Reader

0.7.0 · active · verified Thu Apr 16

The `llama-index-readers-confluence` library provides a data loader for ingesting content from Confluence Cloud instances into LlamaIndex. It supports various authentication methods, including OAuth 2.0, API tokens, and basic authentication, and can retrieve pages by ID, space key, label, or Confluence Query Language (CQL). It also offers functionality to include and parse attachments from Confluence pages. This integration is part of the broader LlamaIndex ecosystem, known for its rapid development and frequent updates. The current version is 0.7.0 and requires Python versions >=3.10 and <4.0.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `ConfluenceReader` and load documents from a specified Confluence space using basic authentication with an API token. Environment variables are used for sensitive credentials.

import os
from llama_index.readers.confluence import ConfluenceReader

# Ensure CONFLUENCE_BASE_URL, CONFLUENCE_USERNAME, and CONFLUENCE_API_TOKEN are set as environment variables
# CONFLUENCE_BASE_URL should end with /wiki, e.g., 'https://your-domain.atlassian.net/wiki'
# CONFLUENCE_API_TOKEN is generated from your Atlassian profile security settings, not your password

base_url = os.environ.get('CONFLUENCE_BASE_URL', 'https://your-confluence-instance.atlassian.net/wiki')
username = os.environ.get('CONFLUENCE_USERNAME', 'your_email@example.com')
api_token = os.environ.get('CONFLUENCE_API_TOKEN', 'your_api_token')

# Initialize the reader with basic authentication (API token is preferred over password)
reader = ConfluenceReader(
    base_url=base_url,
    user_name=username,
    api_token=api_token # Use api_token for Confluence Cloud
)

# Load data from a specific space key
try:
    documents = reader.load_data(space_key='YOUR_SPACE_KEY', max_num_results=10, include_attachments=False)
    for doc in documents:
        print(f"Document ID: {doc.doc_id}")
        print(f"Content snippet: {doc.text[:200]}...")
except Exception as e:
    print(f"An error occurred: {e}")
    print("Please check your Confluence URL, credentials, and permissions.")

view raw JSON →