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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get the date of the first commit from a branch using API REST V2

I need to know the date of the first commit for a branch in multiple repos to know the creation time of the repo, I'm using the REST API V2.

i need something like :

curl -D- -X GET  ""

But i need to sort the answer from the last page, since some repos have more than 100 pages of commits but i don't know the total amount of pages, and i need the first historical commit in a master branch for each one.

1 answer

0 votes

Hello @Maximiliano Venesio,

I'm afraid this is not easily possible. There's no direct link to the very first commit, and to find it the whole commit tree traversal is required. This is why Bitbucket doesn't have this option in the commit list API.

You can get repo creation date by hitting repository endpoint, potentially narrowing it down to just the created_on attribute (I also included slug in this example):,created_on

However this will show when the repo has been created in Bitbucket which doesn't necessarily mean when the first commit was pushed to it or when that commit was created. The latter can be both before and after the repo creation date.

If you really need to find the date of the first commit, the only way to do that without cloning every repository is to traverse commit list till the end – until there's no next attribute in the response:

# Pseudocode

page = fetch(',')

while( {
page = fetch(

first_commit_date = page.values.last().date

If cloning the repo is an option, you can run this command locally (assuming your repo is under Git):

git rev-list --max-parents=0 HEAD | xargs git log --pretty=format:'%ad'

Hope this helps. Let me know if you have any questions.


Hi Daniil, thanks for your quick answer.

In my case, this call does not bring any data,created_on

 Do you know if  i have to add something else in my call ?

the creation date should be enough in this case.



I guess the problem is that you need to authenticate the request. That particular repository in my example is public, so you can just paste the URL into the browser, and it'll work (even in incognito mode). But for a private repository you need to authenticate the request ( doesn't allow session auth).

If that's not the issue, can you elaborate what do you actually get back?


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,826 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you