Atlassian Python API Wrapper

4.0.7 · active · verified Wed Apr 08

The `atlassian-python-api` library provides a comprehensive and convenient Python wrapper for interacting with various Atlassian products, including Jira, Confluence, Bitbucket, Crowd, Service Desk, Xray, and Bamboo. It supports both Atlassian Cloud and Server/Data Center instances by leveraging their official REST APIs, along with some additional private methods and protocols. Currently at version 4.0.7, the library maintains an active development and release cadence, frequently adding new features, bug fixes, and adjustments for evolving Atlassian APIs.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to connect to Jira Cloud using an API token, which is the recommended authentication method for cloud instances. It then retrieves the current user's display name and lists the first five available projects to verify the connection and basic functionality. Environment variables are used for sensitive credentials.

import os
from atlassian import Jira

# For Jira Cloud, use API Token authentication.
# Generate an API token at: https://id.atlassian.com/manage-profile/security/api-tokens
JIRA_URL = os.environ.get('ATLASSIAN_JIRA_URL', 'https://your-domain.atlassian.net')
JIRA_EMAIL = os.environ.get('ATLASSIAN_JIRA_EMAIL', 'your_email@example.com')
JIRA_API_TOKEN = os.environ.get('ATLASSIAN_JIRA_API_TOKEN', 'YOUR_API_TOKEN')

if not all([JIRA_URL, JIRA_EMAIL, JIRA_API_TOKEN]):
    print("Please set ATLASSIAN_JIRA_URL, ATLASSIAN_JIRA_EMAIL, and ATLASSIAN_JIRA_API_TOKEN environment variables.")
else:
    try:
        jira = Jira(
            url=JIRA_URL,
            username=JIRA_EMAIL,
            password=JIRA_API_TOKEN, # API token for Cloud
            cloud=True # Important for Jira Cloud
        )

        # Test connection by getting current user
        current_user = jira.myself()
        print(f"Successfully connected to Jira. Current user: {current_user['displayName']}")

        # Example: Get all projects
        projects = jira.get_all_projects(start=0, limit=5)
        print(f"First 5 projects: {[p['name'] for p in projects]}")

    except Exception as e:
        print(f"Error connecting to Jira or fetching data: {e}")

view raw JSON →