This is a Pharo client for the Bitbucket Server REST API
Metacello new
githubUser: 'Evref-BL' project: 'Bitbucket-Pharo-API' commitish: 'main' path: 'src';
baseline: 'BitbucketPharoAPI';
onConflict: [ :ex | ex useIncoming ];
load
spec
baseline: 'BitbucketPharoAPI' with: [
spec repository: 'github://Evref-BL/Bitbucket-Pharo-API:main'
]
To start using the API, you need to create a client instance with your Bitbucket host and a Bearer token for authentication. Here’s an example:
bitbucketApi := BitbucketApi new
host: 'bitbucket.org';
bearerToken: '<your token>'.
Replace <your token>
with your actual Bitbucket token.
The API provides different resource classes to interact with different entities in Bitbucket. These resources include:
- branches
- commits
- projects
- pullRequests
- repositories
- users
Each resource provides methods for interacting with the corresponding Bitbucket resource. You can access them like this:
bitbucketApi projects <method>
Here are a few examples of how to interact with the API:
This example retrieves all projects from Bitbucket:
| projects |
projects := bitbucketApi projects all
This example demonstrates how to fetch all commits for the dev branch within a specific repository and project, using parameters:
| commits params |
params := {
#until -> 'dev'
} asDictionary.
commits := bitbucketApi commits allWithParams: params inRepository: '<repositorySlug>' ofProject: '<projectKey>'.
Replace <repositorySlug>
with the slug of the repository and <projectKey>
with the project key.