Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to hit bitbucket API using Python requests module

Cody Childers June 26, 2015

Hi, I would like to know how to use bitbucket API using python requests. I love bitbucket, and using the API is very important to my main project. My attempts and failed tries are all at http://stackoverflow.com/questions/31061227/curl-vs-python-requests-when-hitting-apis which will give anyone answering a good starting point. Thank you,

 

Cody

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 26, 2015

Hello Cody,

Thank you for your question.

# ===============
# get user
# ===============
import requests
import json

# [BITBUCKET-BASE-URL], i.e.: https://bitbucket.org/
url = '[BITBUCKET-BASE-URL]/api/1.0/user/'
headers = {'Content-Type': 'application/json'}

# get user
# [USERNAME], i.e.: myuser
# [PASSWORD], i.e.: itspassword
r = requests.get(url, auth=('[USERNAME]', '[PASSWORD]'), headers=headers)
print(r.status_code)
print(r.text)
#print(r.content)

Please, refer to http://restbrowser.bitbucket.org/ for further API calls.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Tyson Dogerz January 12, 2018

The key word being api/1.0.  Deprecated in 2.0

0 votes
Cody Childers June 26, 2015

smile

TAGS
AUG Leaders

Atlassian Community Events