Atlassian Page Client
A Python client library for interacting with Atlassian Confluence pages through the REST API.
Features
- Simple authentication using email and API token
- Read and modify Confluence page content
- Parse and manipulate HTML content with BeautifulSoup
- Update page versions automatically
- Easy-to-use API for common operations
Installation
pip install atlassian-page-client
Quick Start
from atlassian_page_client import AtlassianPageClient
# Initialize the client
client = AtlassianPageClient(
email="your.email@example.com",
token="your_api_token",
base_url="https://yourcompany.atlassian.net"
)
# Get a page
page = client.get("page_id_here")
# Get the page content for editing
content = page.get_working_page_content()
# Get root element
root = content.get_root()
root.append(content.new_tag('p', string='Hello root'))
# Or find elements by attribute
table = content.find_by_Attribute('ac:local-id', 'table-id')
# Create new elements
new_row = content.new_tag('tr')
cell = content.new_tag('td')
cell.append(content.new_tag('p', string='Hello World'))
new_row.append(cell)
# Add to existing content
table.append(new_row)
# Update the page
updated_page = client.put(page)
API Reference
AtlassianPageClient
The main client class for interacting with the Atlassian API.
client = AtlassianPageClient(email, token, base_url)
Methods
get(page_id: str) -> AtlassianPage: Retrieve a page by its IDput(page: AtlassianPage) -> AtlassianPage: Update a page with modifications
AtlassianPage
Represents a Confluence page with its content and metadata.
Methods
get_page_id() -> str: Get the page IDget_working_page_content() -> AtlassianPageContent: Get the editable contentprettify() -> str: Get a pretty-printed JSON representationincrease_version(): Increment the page version (called automatically by client.put())
AtlassianPageContent
Handles the HTML content of a page using BeautifulSoup for parsing and manipulation.
Methods
find_by_Attribute(attribute_name: str, value: str) -> bs4.element.Tag: Find element by attributenew_tag(tag_name: str, **kwargs) -> bs4.element.Tag: Create a new HTML tagget_root() -> bs4.element.Tag: Get the root BeautifulSoup elementprettify() -> str: Get pretty-printed HTML
Authentication
You'll need:
- Your Atlassian email address
- An API token (create one at https://id.atlassian.com/manage-profile/security/api-tokens)
- Your Atlassian base URL (e.g., https://yourcompany.atlassian.net)
Requirements
- Python 3.8+
- requests >= 2.25.0
- beautifulsoup4 >= 4.9.0
Development
To set up for development:
git clone https://github.com/yourusername/py-atlassian-page-client.git
cd py-atlassian-page-client
pip install -e .[dev]
Running Tests
The package includes a comprehensive test suite with unit tests, integration tests, and coverage reporting.
Quick test run:
pytest
Run with coverage:
pytest --cov=atlassian_page_client --cov-report=term-missing
Run specific test files:
pytest tests/test_client.py -v
pytest tests/test_integration.py -v
Use the test runner script:
python run_tests.py
Test structure:
tests/test_client.py- Tests for AtlassianPageClienttests/test_page.py- Tests for AtlassianPagetests/test_content.py- Tests for AtlassianPageContenttests/test_integration.py- Integration teststests/test_package_imports.py- Import and basic functionality teststests/conftest.py- Shared test fixtures
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Metadata
Release files for atlassian-page-client 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| atlassian_page_client-0.2.2.tar.gz | 15.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| atlassian_page_client-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.8 kB
Release files / atlassian_page_client-0.2.2.tar.gz
| Download URL | atlassian_page_client-0.2.2.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
513a4bd6a8cf7df1b6ea2139084378f7f78b6b0a64bbcce2057c73f933ec01ad
|
|
BLAKE2b-256 checksum How to use checksums |
1aba4735b66884e3a63c7b37c9ac69d45274f504e575796c614b7a7914960591
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / atlassian_page_client-0.2.2-py3-none-any.whl
| Download URL | atlassian_page_client-0.2.2-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee08fcdcea4b6c55f21141050642a45f0c295cb3b55f879080cf7d8057baa30f
|
|
BLAKE2b-256 checksum How to use checksums |
9068d2c7446b782b4e6ae05ea0ce446b5e56bde9b156631a8b6aef5f5936ae61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|