Confluence
Confluence is a wiki collaboration platform designed to save and organize all project-related materials. As a knowledge base, Confluence primarily serves content management activities.
This loader allows you to fetch and process Confluence pages into Document
objects.
Authentication Methods
The following authentication methods are supported:
username/api_key
OAuth2 login
cookies
- On-premises installations:
token
authentication
Page Selection
You can specify which pages to load using:
-
page_ids (list):
A list ofpage_id
values to load the corresponding pages. -
space_key (string):
A string ofspace_key
value to load all pages within the specified confluence space.
If both page_ids
and space_key
are provided, the loader will return the union of pages from both lists.
Hint: Both space_key
and page_id
can be found in the URL of a Confluence page:
https://yoursite.atlassian.com/wiki/spaces/{space_key}/pages/{page_id}
Attachments
You may include attachments in the loaded Document
objects by setting the boolean parameter include_attachments to True
(default: False
). When enabled, all attachments are downloaded and their text content is extracted and added to the Document.
Currently supported attachment types:
- PDF (
.pdf
) - PNG (
.png
) - JPEG/JPG (
.jpeg
,.jpg
) - SVG (
.svg
) - Word (
.doc
,.docx
) - Excel (
.xls
,.xlsx
)
Before using ConfluenceLoader make sure you have the latest version of the atlassian-python-api package installed:
%pip install --upgrade --quiet atlassian-python-api
Examples
Username and Password or Username and API Token (Atlassian Cloud only)
This example authenticates using either a username and password or, if you're connecting to an Atlassian Cloud hosted version of Confluence, a username and an API Token. You can generate an API token at: https://id.atlassian.com/manage-profile/security/api-tokens.
The limit
parameter specifies how many documents will be retrieved in a single call, not how many documents will be retrieved in total.
By default the code will return up to 1000 documents in 50 documents batches. To control the total number of documents use the max_pages
parameter.
Plese note the maximum value for the limit
parameter in the atlassian-python-api package is currently 100.
from langchain_community.document_loaders import ConfluenceLoader
loader = ConfluenceLoader(
url="https://yoursite.atlassian.com/wiki",
username="<your-confluence-username>",
api_key="<your-api-token>",
space_key="<your-space-key>",
include_attachments=True,
limit=50,
)
documents = loader.load()
Personal Access Token (Server/On-Prem only)
This method is valid for the Data Center/Server on-prem edition only. For more information on how to generate a Personal Access Token (PAT) check the official Confluence documentation at: https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html. When using a PAT you provide only the token value, you cannot provide a username. Please note that ConfluenceLoader will run under the permissions of the user that generated the PAT and will only be able to load documents for which said user has access to.
from langchain_community.document_loaders import ConfluenceLoader
loader = ConfluenceLoader(
url="https://confluence.yoursite.com/",
token="<your-personal-access-token>",
space_key="<your-space-key>",
include_attachments=True,
limit=50,
max_pages=50,
)
documents = loader.load()
Related
- Document loader conceptual guide
- Document loader how-to guides