Screenbot Javascript SDK
JavaScript HTML
Permalink
Failed to load latest commit information.
distrib
example
src
.gitignore
Gruntfile.js Update bower version Feb 3, 2016
README.md Add error explanation to README Apr 14, 2016
bower.json
package.json Release v0.1.1 Apr 14, 2016

README.md

Screenbot

Official Javacript SDK for Screenbot. Requires a Screenbot account and the Screenbot client.

http://screenbot.io

Installation

Requires bower

bower install --save screenbot

Notable files are distrib/screenbot.js or distrib/screenbot.min.js.

Usage

Initialize the client

// Init with Screenbot SDK token
var sb = new Screenbot("pk_test_sdk_token_value");

You can manage your SDK keys on your developer dashboard.

Run a command:

// Check whether the Screenbot client is running and connected
sb.ping(function(err, result){
  // err has properties for the error's code and message
  if(err) return console.log('Error! Code: ' + err.code + ' Message: ' + err.message);

  // result has a connected property that's either true or false
  console.log(result.connected);
  // true
});

// Show the Screenbot menu for all connected clients
sb.activate(function(err, result){
  // err has properties for the error's code and message
  if(err) return console.log('Error! Code: ' + err.code + ' Message: ' + err.message);

  // result has a url property that points to the uploaded drop
  console.log(result.url);
  // http://d.pr/i/zJSD
});

// Run the screenshot command for all connected clients. Same as /sb shot
sb.shot(function(err, result){
  // err has properties for the error's code and message
  if(err) return console.log('Error! Code: ' + err.code + ' Message: ' + err.message);

  // result has a url property that points to a screenshot
  console.log(result.url);
  // http://d.pr/i/1kA2M
});

// Activate the screencast command for all connected clients. Same as /sb cast
sb.cast(function(err, result){
  // err has properties for the error's code and message
  if(err) return console.log('Error! Code: ' + err.code + ' Message: ' + err.message);

  // result has a url property that points to a screencast
  console.log(result.url);
  // http://d.pr/i/12A5W
});

// Upload whatever is in the client clipboard. Same as /sb clip
sb.clip(function(err, result){
  // err has properties for the error's code and message
  if(err) return console.log('Error! Code: ' + err.code + ' Message: ' + err.message);

  // result has a url property that points to the uploaded drop
  console.log(result.url);
  // http://d.pr/f/1iTCo
});

To see a working example, clone the repo and open example/index.html in your browser.

Error Codes

Code Message Resolution
1 CLIENT_UNAVAILABLE This error occurs when the library can't connect to the Screenbot desktop app. Make sure that you're initializing the client with a valid API token. You can manage your tokens on your developer dashboard.

Also, make sure the app is running and connected. If have multiple accounts, check in the app under "Preferences" that Screenbot is signed in to the account that's associated with your API token.
2 NO_DATA_RECEIVED This error occurs when there is no response from the Screenbot desktop app after a command is sent. Make sure your API tokens are valid. The app itself should display a more specific error as well.
3 PARSE_ERROR This error occurs when the response from the API or Screenbot app cannot be parsed. This could mean the API server is down.

License

Apache-2.0