# node-saucelabs [](http://travis-ci.org/danjenkins/node-saucelabs)[](https://www.codeship.io/projects/83c9b290-21de-0131-e459-3688c4e23c72/status) Wrapper around the Sauce Labs REST API for [Node.js](http://nodejs.org/). ## Install ```shell npm install saucelabs ``` ## Test To run the test suite, first invoke the following command within the repo, installing the development dependencies: ```shell npm install ``` Then run the tests: ```shell npm test ``` ## Authors - Dan Jenkins ([danjenkins](https://github.com/danjenkins)) - Mathieu Sabourin ([OniOni](https://github.com/OniOni)) - Daniel Perez Alvarez ([unindented](https://github.com/unindented)) ## Writing a script ```javascript var SauceLabs = require('saucelabs'); var myAccount = new SauceLabs({ username: "your-sauce-username", password: "your-sauce-api-key" }); myAccount.getAccountDetails(function (err, res) { console.log(res); myAccount.getServiceStatus(function (err, res) { // Status of the Sauce Labs services console.log(res); myAccount.getAllBrowsers(function (err, res) { // List of all browser/os combinations currently supported on Sauce Labs console.log(res); myAccount.getJobs(function (err, jobs) { // Get a list of all your jobs for (var k in jobs) { if ( jobs.hasOwnProperty( k )) { myAccount.showJob(jobs[k].id, function (err, res) { var str = res.id + ": Status: " + res.status; if (res.error) { str += "\033[31m Error: " + res.error + " \033[0m"; } console.log(str); }); } } }); }); }); }); ``` ## Using a proxy If you're behind a corporate firewall or would like to utilize a proxy, define it in the constructor like this: ```javascript var sauce = new SauceLabs({ username: "your-sauce-username", password: "your-sauce-api-key", proxy: "https://your-proxy.com:8000" }); ``` ## Supported Methods
REST | Node Wrapper |
---|---|
GET /users/:username Access account details. |
getAccountDetails(cb) -> cb(err, res) |
GET /:username/limits Access current account limits. |
getAccountLimits(cb) -> cb(err, res) |
GET /:username/activity Access current account activity. |
getUserActivity(start, end, cb) -> cb(err, res) getUserActivity(start, cb) -> cb(err, res) getUserActivity(cb) -> cb(err, res) |
GET /users/:username/concurrency Get currently running job counts broken down by account and job status |
getUserConcurrency(cb) -> cb(err, res) |
GET /users/:username/usage Access historical account usage data. |
getAccountUsage(cb) -> cb(err, res) |
GET /:username/jobs List all job IDs belonging to a given user. |
getJobs(cb) -> cb(err, res) |
GET /:username/jobs/:id Show the full information for a job given its ID. |
showJob(id, cb) -> cb(err, res) |
PUT /:username/jobs/:id Changes a pre-existing job. |
updateJob(id, data, cb) -> cb(err, res) |
DELETE /:username/jobs/:id Removes the job from the system with all the linked assets. |
deleteJob(id, cb) -> cb(err, res) |
PUT /:username/jobs/:id/stop Terminates a running job. |
stopJob(id, data, cb) -> cb(err, res) |
GET /:username/tunnels Retrieves all running tunnels for a given user. |
getActiveTunnels(cb) -> cb(err, res) |
GET /:username/tunnels/:id Show the full information for a tunnel given its ID. |
getTunnel(id, cb) -> cb(err, res) |
DELETE /:username/tunnels/:id Shuts down a tunnel given its ID. |
deleteTunnel(id, cb) -> cb(err, res) |
GET /info/status Returns the current status of Sauce Labs' services. |
getServiceStatus(cb) -> cb(err, res) |
GET /info/browsers/all Returns an array of strings corresponding to all the browsers currently supported on Sauce Labs. |
getAllBrowsers(cb) -> cb(err, res) |
GET /info/browsers/selenium-rc Returns an array of strings corresponding to all the browsers currently supported under Selenium on Sauce Labs. |
getSeleniumBrowsers(cb) -> cb(err, res) |
GET /info/browsers/webdriver Returns an array of strings corresponding to all the browsers currently supported under WebDriver on Sauce Labs. |
getWebDriverBrowsers(cb) -> cb(err, res) |
GET /info/counter Returns the number of test executed so far on Sauce Labs. |
getTestCounter(cb) -> cb(err, res) |
POST /users/:username Create a new subaccount. |
createSubAccount(data, cb) -> cb(err, res) |
POST /users/:username/subscription Update a subaccount Sauce Labs service plan. |
updateSubAccount(data, cb) -> cb(err, res) |
DELETE /users/:username/subscription Unsubscribe a subaccount from its Sauce Labs service plan. |
deleteSubAccount(cb) -> cb(err, res) |
Make a public link to a private job, without needing to login. |
createPublicLink(job_id, datetime, use_hour, cb) -> cb(err, url) createPublicLink(job_id, datetime, cb) -> cb(err, url) createPublicLink(job_id, cb) -> cb(err, url) |
GET /users/:username/list-subaccounts Access list of subaccounts |
getSubAccountList(cb) -> cb(err, res) |
GET /users/:username/subaccounts Get information about a sub accounts |
getSubAccounts(cb) -> cb(err, res) |