Bitbucket is a Git-based source code repository hosting service owned by Atlassian.
Bitbucket Server is a combination Git server and web interface product written in Java and built with Apache Maven.
It allows users to do basic Git operations while controlling read and write access to the code. It also provides integration with other Atlassian tools.
Now a days for reporting and for ETL operations, demand for python is increasing.
Using Python request library we can access bitbucket.
Below is sample code snippet.
import requests
import json
import pandas as pd
import io
url = 'https://api.bitbucket.org/2.0/repositories/Abcd'
headers = {'Content-Type': 'application/json'}
USERNAME = 'xxxxxx'
PASSWORD = 'yyyyyy'
response = requests.get(url, auth=(USERNAME, PASSWORD), headers=headers)
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers,
'Error Response:', response.json())
exit()
df = pd.read_json(io.StringIO(response.text))
# j = a.assigng().assigng()
dk = pd.json_normalize(df['values'])
dk.to_excel('Bitbucket_INC_Report.xlsx', sheet_name='SLA_Report', index='False')