Hello Community,
I am on the way of creating Grafana Dashboards, I am trying to retrieve the commits for the repository only on a certain time range. May I please know if Bit Bucket cloud supports the since and until feature on the Api end points.
Hey Bharath,
Unfortunately - only some of what you are requesting is possible within our API at present.
Our /2.0/repositories endpoint does not support filtering by date for commits, however, you can use GIT commands to retrieve a list of commits since a certain date or before a certain date (you can add --count switch to just show the number):
git rev-list --all --since 2023-01-01
git rev-list --all --before 2023-01-01
As for pull requests, you can use filtering and sorting to pull this information - you will need to encode any query manually or using a tool to convert it to URL format, for example:
//This is the base query unencoded for > than a certain date and < than a certain date
https://api.bitbucket.org/2.0/repositories/{workspaceID}/{reposlug}/pullrequests?fields=values.id&q=updated_on<2023-01-01T00:00:00+00:00&state=ALL&pagelen=50
https://api.bitbucket.org/2.0/repositories/{workspaceID}/{reposlug}/pullrequests?fields=values.id&q=updated_on>2023-01-01T00:00:00+00:00&state=ALL&pagelen=50
//These are the same queries encoded in URL format
https://api.bitbucket.org/2.0/repositories/{workspaceID}/{reposlug}/pullrequests?fields=values.id&q=updated_on%3C2023-01-01T00%3A00%3A00%2B00%3A00&state=ALL&pagelen=50
https://api.bitbucket.org/2.0/repositories/{workspaceID}/{reposlug}/pullrequests?fields=values.id&q=updated_on%3D2023-01-01T00%3A00%3A00%2B00%3A00&state=ALL&pagelen=50
NOTE: You will need to remove the curly braces and replace these with actual values in your cURL command.
We have raised a feature request on your behalf to include date filtering in our commits endpoint:
Please feel free to "Watch" this request to receive updates related to it and "Vote" for it to improve its visibility with regard to customer demand, you can view our feature implementation policy below:
Hope this helps.
Cheers!
- Ben (Bitbucket Cloud Support)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.