You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
Pramodh M
Community LeaderDevSecOps Architect
Bengaluru
636 accepted answers
2 comments