With my latest update of CodeTrack (1.2) I implemented BitBucket as a provider, so you can watch repositories from there now as well. On the app itself there are a few search functions using the BitBucket API, this post will provide some insight and example code for doing this.
So basically I wanted to go from having nothing at all (no BitBucket user, no username, no repo slug/id) to being able to search for repositories by either their name or their owners username.
Note: The BitBucket API has recently changed to allow you to do this by giving the repository responses the Onwer property.
As always, RestSharp was used in the making of this code sample.
The 2 requests share the same response class BitBucketRepoList, this class is pretty simple because we are calling the API anonymously where using a BitBucket username/password would return a more detailed response.
Searching by Repo Name
This request is pretty straight forward, RestClient with the base url for the API, RestRequest with the Resource “repositories” then add a get parameter of "name” with the search term. (API Doco)
Searching by Repo Owner
Now for this request, BitBucket API doesnt actually support searching on usernames so these must be exact matches on the username.
And there you have it, BitBucket API from Windows Phone 7. (The above code will also work in Silverlight/WPF as well as Win forms or ASP.NET depending on the version of RestSharp used.)