@absolunet/bitbucket-api

Bitbucket API via OAuth2

Usage no npm install needed!

<script type="module">
  import absolunetBitbucketApi from 'https://cdn.skypack.dev/@absolunet/bitbucket-api';
</script>

README

@absolunet/bitbucket-api

npm npm dependencies npms Travis CI Code style ESLint

Bitbucket API wrapper via OAuth2

Authenticate to Bitbutcket APIv2 via OAuth2 then call API directly

Install

$ npm install @absolunet/bitbucket-api

Usage

const BitbucketAPI = require('@absolunet/bitbucket-api');

const CONSUMER_KEY    = 'zyxwvutsrqponmlkji';
const CONSUMER_SECRET = 'abcdefghijklmnopqrstuvwxyz012345';

const bitbucket      = new BitbucketAPI();
const authentication = await bitbucket.authenticate(CONSUMER_KEY, CONSUMER_SECRET);

if (authentication.success) {
    const { success, data } = bitbucket.get('/repositories/{uuid}/my-project');

    if (success) {
        console.log(data);
    }
}

API - Login

authenticate(consumerKey, consumerSecret)

Login to Bitbucket API
Promise returns an Object with a success property

consumerKey

Required
Type: String
OAuth consumer key

consumerSecret

Required
Type: String
OAuth consumer secret


user

Type: Object
Currently logged user data


API - Calls

All calls are Promises that returns an Object with success and data properties
url param replaces {uuid} token with current user's UUID

put(url [, data])

Calls API with PUT method
Promise returns an Object described above

url

Required
Type: String
Truncated url to call

data

Type: Object
Additional params to send in request body


post(url [, data])

Calls API with POST method
Promise returns an Object described above

url

Required
Type: String
Truncated url to call

data

Type: Object
Additional params to send in request body


get(url [, data])

Calls API with GET method
Promise returns an Object described above

url

Required
Type: String
Truncated url to call

data

Type: Object
Additional params to send in request body


delete(url [, data])

Calls API with DELETE method
Promise returns an Object described above

url

Required
Type: String
Truncated url to call

data

Type: Object
Additional params to send in request body



License

MIT © Absolunet