Want to get the all commits lists per user in bitbucket.
Asked by Yusuf Khan:

Hi,  

I am trying to get the list of commits and line of codes changed by per user in **bitbucket cloud.** I tried using api's  
step followed for API :  
- Generated Oauth token using endpoint  
<https://bitbucket.org/site/oauth2/access_token>  
- Used this access token to get repositories using endpoint  
<https://api.bitbucket.org/2.0>/repositories?access_token={access_token}\&role=member"  

It worked to list repositories but when I used the endpoint -  
<https://api.bitbucket.org/2.0/repositories/>\<workspace\>/\<repository\>/commits  

This is also not working.  

Then I followed this document : <https://atlassian-python-api.readthedocs.io/index.html>

In this the bitbucket cloud part is not much helping.  
How we can use this localhost parts in bitbucket cloud which will also be helpful.  
how we can create a bitbucket cloud client so we can use below method?

```
# Get pull request commitsbitbucket.get_pull_requests_commits(project, repository, pull_request_id)
```

Please help me here **how we can achive** this?

**Is there any bitbucket cloud app(marketplace) which can also help me here**.


Answers:
author: Patrik S
body: Hello [@Yusuf Khan](/t5/user/viewprofilepage/user-id/5260553) and welcome to the community!

In order to authenticate the API call using an access token, you will need to provide the access token in a Header named **Authorization** , where the value should be the word *Bearer*followed by the access token itself.

Below is an example of a request to List all the commits in a repository, including the access token in the request :

```
curl --request GET --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commits' --header 'Authorization: Bearer <access_token>' --header 'Accept: application/json'
```

To get the access token used in the authentication, you will first need to call the below endpoint, providing the Key (clientId) and Secret (clientSecret) of the bitbucket OAuth consumer :

```
curl -X POST -u "ClientID:ClientSecret" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials
```

The token is only valid for 2 hours, so after it expires you will need to get a new access token by calling the API endpoint above again.

As for your question about apps that can help build those reports, you can check the available Reports apps using the following link :

* [https://marketplace.atlassian.com/search?category=Reports\&hosting=cloud\&product=bitbucket](https://marketplace.atlassian.com/search?category=Reports&hosting=cloud&product=bitbucket)

Thank you, [@Yusuf Khan](/t5/user/viewprofilepage/user-id/5260553) !

Patrik S

comments: author: Yusuf Khan
body: Hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) ,

Thanks for your help about api.  

The reporting apps you suggested. In those, is there any way to export that data in CSV, particularly commits data.  
I have tried to use [awesome graphs](https://marketplace.atlassian.com/apps/1210934/awesome-graphs-for-bitbucket?hosting=cloud&tab=overview) app but bitbucket cloud version of this app does not have any option to export data.  

Please help me.


author: Patrik S
body: Hello [@Yusuf Khan](/t5/user/viewprofilepage/user-id/5260553) ,

Those apps are developed and maintained by third parties, so I would suggest reaching out to the app's vendor by opening the app on the marketplace and clicking on the **Support** option.

Thank you, [@Yusuf Khan](/t5/user/viewprofilepage/user-id/5260553) !

Patrik S


Tags: api

bitbucket-cloud

cloud

community

rest