Welcome to Atlassian Python API’s documentation!

Build status PyPI version PyPI Downloads License Codacy Badge Documentation Status

Getting started

Install package using pip:

pip install atlassian-python-api

Add a connection:

from atlassian import Jira
from atlassian import Confluence
from atlassian import Bitbucket
from atlassian import ServiceDesk
from atlassian import Xray

jira = Jira(
    url='http://localhost:8080',
    username='admin',
    password='admin')

confluence = Confluence(
    url='http://localhost:8090',
    username='admin',
    password='admin')

bitbucket = Bitbucket(
    url='http://localhost:7990',
    username='admin',
    password='admin')

service_desk = ServiceDesk(
    url='http://localhost:8080',
    username='admin',
    password='admin')

xray = Xray(
    url='http://localhost:8080',
    username='admin',
    password='admin')

Key/Cert Based authentication

Add a connection using key/cert based authentication:

from atlassian import Jira
from atlassian import Confluence
from atlassian import Bitbucket
from atlassian import ServiceDesk
from atlassian import Xray

jira = Jira(
    url='http://localhost:8080',
    key='/path/to/key',
    cert='/path/to/cert')

confluence = Confluence(
    url='http://localhost:8090',
    key='/path/to/key',
    cert='/path/to/cert')

bitbucket = Bitbucket(
    url='http://localhost:7990',
    key='/path/to/key',
    cert='/path/to/cert')

service_desk = ServiceDesk(
    url='http://localhost:8080',
    key='/path/to/key',
    cert='/path/to/cert')

xray = Xray(
    url='http://localhost:8080',
    key='/path/to/key',
    cert='/path/to/cert')

Alternatively OAuth can be used:

oauth_dict = {
    'access_token': 'access_token',
    'access_token_secret': 'access_token_secret',
    'consumer_key': 'consumer_key',
    'key_cert': 'key_cert'}

jira = Jira(
    url='http://localhost:8080',
    oauth=oauth_dict)

confluence = Confluence(
    url='http://localhost:8090',
    oauth=oauth_dict)

bitbucket = Bitbucket(
    url='http://localhost:7990',
    oauth=oauth_dict)

service_desk = ServiceDesk(
    url='http://localhost:8080',
    oauth=oauth_dict)

xray = Xray(
    url='http://localhost:8080',
    oauth=oauth_dict)

OAuth 2.0 is also supported:

from atlassian.bitbucket.cloud import Cloud

# token is a dictionary and must at least contain "access_token"
# and "token_type".
oauth2_dict = {
    "client_id": client_id,
    "token": token}

bitbucket_cloud = Cloud(
    url='https://api.bitbucket.org/',
    oauth2=oauth2_dict)

# For a detailed example see bitbucket_oauth2.py in
# examples/bitbucket

Or Kerberos (installation with kerberos extra necessary):

kerberos_service = 'HTTP/jira.localhost@YOUR.DOMAIN.COM'

jira = Jira(
    url='http://localhost:8080',
    kerberos=kerberos_service)

confluence = Confluence(
    url='http://localhost:8090',
    kerberos=kerberos_service)

bitbucket = Bitbucket(
    url='http://localhost:7990',
    kerberos=kerberos_service)

service_desk = ServiceDesk(
    url='http://localhost:8080',
    kerberos=kerberos_service)

xray = Xray(
    url='http://localhost:8080',
    kerberos=kerberos_service)

Or reuse cookie file:

from atlassian import utils
cookie_dict = utils.parse_cookie_file("cookie.txt")

jira = Jira(
    url='http://localhost:8080',
    cookies=cookie_dict)

confluence = Confluence(
    url='http://localhost:8090',
    cookies=cookie_dict)

bitbucket = Bitbucket(
    url='http://localhost:7990',
    cookies=cookie_dict)

service_desk = ServiceDesk(
    url='http://localhost:8080',
    cookies=cookie_dict)

xray = Xray(
    url='http://localhost:8080',
    cookies=cookie_dict)

To authenticate to the Atlassian Cloud APIs Jira, Confluence, ServiceDesk:

# Obtain an API token from: https://id.atlassian.com/manage-profile/security/api-tokens
# You cannot log-in with your regular password to these services.

jira = Jira(
    url='https://your-domain.atlassian.net',
    username=jira_username,
    password=jira_api_token,
    cloud=True)

confluence = Confluence(
    url='https://your-domain.atlassian.net',
    username=jira_username,
    password=jira_api_token,
    cloud=True)

service_desk = ServiceDesk(
    url='https://your-domain.atlassian.net',
    username=jira_username,
    password=jira_api_token,
    cloud=True)

And to Bitbucket Cloud:

# Log-in with E-Mail / Username and regular password
# or with Username and App password.
# Get App password from https://bitbucket.org/account/settings/app-passwords/.
# Log-in with E-Mail and App password not possible.
# Username can be found here: https://bitbucket.org/account/settings/

from atlassian.bitbucket.cloud import Cloud

bitbucket = Cloud(
    url='https://api.bitbucket.org/',
    username=bitbucket_email,
    password=bitbucket_password,
    cloud=True)

bitbucket_app_pw = Cloud(
    url='https://api.bitbucket.org/',
    username=bitbucket_username,
    password=bitbucket_app_password,
    cloud=True)