The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

5 comments

Comments for this post are closed

Community moderators have prevented the ability to post new comments.

Matt Doar
Community Champion
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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 21, 2022

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

Like Gonchik Tsymzhitov likes this
Like # people like this
Gonchik Tsymzhitov
Community Champion
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 

Like Evgeniy Lepilin likes this
Nivaldo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 4, 2024

With this app you can code python directly from Jira cloud
https://marketplace.atlassian.com/apps/1232671/easy-for-jira?hosting=cloud&tab=overview

The docs are on confluence and accessible from the app itself:
https://easyforjira.atlassian.net/wiki/spaces/Documentation/overview

Like Gonchik Tsymzhitov likes this

Comments for this post are closed

Community moderators have prevented the ability to post new comments.

TAGS
AUG Leaders

Atlassian Community Events