Atlassian Python API's

Hi Community,

The article here explained how to create a token in your Atlassian Account

To get started on APIs - Here's the Guide -> Link

In this article let us look at the Atlassian API using Python and the various approaches to using Python Modules to authenticate with Atlassian Account and interact with the APIs

One of the Modules I occasionally use is the atlassian-python-api module

https://atlassian-python-api.readthedocs.io

Install the atlassian-python-api module

pip install atlassian-python-api

Below is the sample code to authenticate to Atlassian Account where we mention the site, email as username, password, and cloud option as 'True'

from atlassian import Jira

jira = Jira(

    url='https://your-site.atlassian.net',

    username='email',

    password='token',

    cloud=True)


jql_request ='project = WSP AND issuetype = Story'

# '"epic link" = WSP-144'

issues = jira.jql(jql_request)

print(issues)

The methods we extract the data from Cloud are extensive and methods are flexible

Below is another example of the abstract way to get the data

# This code sample uses the 'requests' library:

# http://docs.python-requests.org

import requests

from requests.auth import HTTPBasicAuth

import json

import base64

url = "https://your-site.atlassian.net/rest/api/3/issue/WSP-70"

credentials = "Basic " + base64.b64encode("email:token".encode("ascii")).decode("ascii")

headers = {

   "Accept": "application/json",

   "Authorization": credentials

}

response = requests.request(

   "GET",

   url,

   headers=headers

)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

There are other modules as well one such popular is https://jira.readthedocs.io/installation.html

Do let us know how you are using Jira modules or Atlassian Python Modules to Interact with Atlassian Sites

Thanks,
Pramodh

4 comments

Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 27, 2022

Have you seen any differences in using the various Python libraries to work with the Atlassian REST APIs, particularly for Jira?

Like William Kennedy likes this
Hari Suresh December 21, 2022

can you tell me how to add label for the jira ticket ? 

Like Gonchik Tsymzhitov likes this
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2023
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2023

@Matt Doar yeap :) 

sometimes I use non fully published methods or internals/experimental. 

Also, sometimes I like to use wrapped code, as it's easy to go 

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events