npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bitbar/cloud-api-client

v1.2.11

Published

Bitbar Cloud API Client for JavaScript

Downloads

1,994

Readme

Bitbar Cloud API Client for JavaScript

License: MIT Build Status

This repository contains official Bitbar Cloud API Client for JavaScript. Smartbear's Bitbar Cloud hosts hundreds of Android and iOS devices, enabling users to create and test high quality mobile apps and games.

Getting Started

Disclaimer

PLEASE NOTE, that project is under development (versions is below 1.0.0). Because of that not all resources are implemented and/or tested. List of working resources can be found here.

Prerequisites

This package is using UMD pattern, so it means that you can use it:

  • in Node.js project

  • browser running project

    • without AMD
    • with AMD

Concepts

The syntax of the library is heavily inspired by the Chai HTTP syntax. Understanding the following general concepts will allow you to quickly learn the syntax

1. Chaining

Most methods in library is chainable. That's means that you don't need to write long code like:

var meRef = apiClient.me();
var projectRef = me.project(1);
var runRef = project.run(2);

Rather it was designed to use it this way:

apiClient.me().project(1).run(2);

2. Every URL Part is a Method

Example: API resource to download list of device sessions of run with ID 10 in project with ID 20 will be:

GET https://cloud.bitbar.com/api/me/projects/20/runs/10/device-sessions

First part is /me (/api doesn't count because it's "directory" where API is stored). So:

apiClient.me();

Second is /projects, but next is the ID, so method will be in singular form:

apiClient.me().project(20);

Third is /runs, but again - there is the ID, so (again) singular form:

apiClient.me().project(20).run(10);

Last one is /device-dessions. Because it's kebab-case, we need to transform it to camelCase:

apiclient.me().project(20).runs(10).deviceSessions();

Now, because GET method is default one in axios, then we don't need to explicit set it (but you can if you want). So what's left is to send it:

apiclient.me().project(20).runs(10).deviceSessions().send();

3. Structure

Now that you know how to build a chaining call you probably will want to e.g. set params, or set data to send. All classes are documented so it should be easy to read docs from code.

If resource chain ends on method that is singular (so in Swagger it returns single object) then it's descendant of APIResource. It means that you can use all methods that are there.

If resource chain ends on method that is plural (so in Swagger it returns list) then it's descendant of APIList. It means that you can use all methods that are there.

Both APIResource and APIList are children of APIEntity.

4. HTTP Methods

HTTP methods are also methods.

  • If you want to send GET request then add to your chain .get().
  • If you want to send POST request then add to your chain .post().
  • If you want to send DELETE request then add to your chain .delete().

5. Send

Method .send() is sending request and returning Promise. With this kind of approach you can chain all you want. When you are ready, then just call .send().

Usage

CommonJS

npm install @bitbar/cloud-api-client --save
const CloudApiClient = require('@bitbar/cloud-api-client');

const apiClient = new CloudApiClient.API({
  cloudUrl: 'https://cloud.bitbar.com',
  apiKey: 'PASTE_HERE_YOUR_OWN_KEY'
});

apiClient.me().send().then( (resp) => {
  console.log(resp.data);
}).catch( (err) => {
  console.error(err);
});

AMD

requirejs(['cloud-api-client'], function (CloudApiClient) {
  var api = new CloudApiClient.API({
    cloudUrl: 'https://cloud.bitbar.com',
    apiKey: 'PASTE_HERE_YOUR_OWN_KEY'
  });
});

Old School

<!-- note that this is URL to version 0.8.0 -- please check which version is latest -->
<script src="https://github.com/bitbar/cloud-api-client-js/releases/download/v0.8.0/cloud-api-client.min.js"></script>
var api = new CloudApiClient.API({
  cloudUrl: 'https://cloud.bitbar.com',
  apiKey: 'PASTE_HERE_YOUR_OWN_KEY'
});

Examples

Simple examples are placed in examples directory

Documentation

https://bitbar.github.io/cloud-api-client-js/

Contribution

Checking code quality

npm run lint

Running tests

npm run test

Building

npm run build

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details