https://github.com/evref-bl/bitbucketcloud-pharo-api
https://github.com/evref-bl/bitbucketcloud-pharo-api
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/evref-bl/bitbucketcloud-pharo-api
- Owner: Evref-BL
- Created: 2025-09-25T08:19:10.000Z (9 months ago)
- Default Branch: develop
- Last Pushed: 2025-10-07T11:40:11.000Z (8 months ago)
- Last Synced: 2025-10-07T13:28:23.518Z (8 months ago)
- Language: Smalltalk
- Size: 35.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BitbucketCloud-Pharo-Api
[](https://github.com/Evref-BL/BitbucketCloud-Pharo-API/actions/workflows/continuous.yml)
[](https://coveralls.io/github/Evref-BL/BitbucketCloud-Pharo-Api?branch=develop)
A Pharo client for the [Bitbucket Cloud REST API](https://developer.atlassian.com/cloud/bitbucket/rest/intro)
If you are looking for a client targeting Bitbucket Server instead, check out: [Bitbucket-Pharo-API](https://github.com/Evref-BL/Bitbucket-Pharo-API).
## Usage
### Installation
#### From playground
```st
Metacello new
githubUser: 'Evref-BL' project: 'BitbucketCloud-Pharo-API' commitish: 'main' path: 'src';
baseline: 'BitbucketCloudPharoAPI';
onConflict: [ :ex | ex useIncoming ];
load
```
#### Baseline dependency
```st
spec
baseline: 'BitbucketCloudPharoAPI' with: [
spec repository: 'github://Evref-BL/BitbucketCloud-Pharo-API:main'
]
```
### Client
To start using the API, create a BitbucketCloudApi client instance. The API supports two authentication methods: access token or API token (with username).
#### Using an Access Token
```st
bitbucketCloudApi := BitbucketCloudApi new
host: 'api.bitbucket.org';
accessToken: ''.
```
#### Using an API Token
```st
bitbucketCloudApi := BitbucketCloudApi new
host: 'api.bitbucket.org';
username: '';
apiToken: ''.
```
### Ressources
The API provides different resource classes to interact with different entities in Bitbucket. These resources include:
- pullRequests
- refs
- repositories
- source
Each resource provides methods for interacting with the corresponding Bitbucket resource. You can access them like this:
```st
bitbucketCloudApi repositories
```
### Example
Here are a few examples of how to interact with the API:
#### Retrieve a Pull Request
Fetch a pull request by ID within a repository and workspace:
```st
| pullRequest |
pullRequest := bitbucketCloudApi pullRequests get: inRepository: '' ofWorkspace: ''.
```
#### List Files and Directories in a Repository
Retrieve files/directories in a repository branch with parameters (e.g., depth):
```st
| commits params |
params := {
'max_depth' -> '10'
} asDictionary.
bitbucketCloudApi repositories getFileOrDirectory: '' fromCommit: '' inRepository: '' ofWorkspace: '' withParams: params.
```
#### Create a commit
Create a commit on a branch (only works with API token authentication):
```st
| commits params |
commit := BitbucketCloudSourceCommit new
message: 'Update README';
branch: 'dev';
addFile: 'README.md' withNewContent: 'This is my updated README content.'.
bitbucketCloudApi source createCommit: commit inRepository: '' ofWorkspace: ''.
```