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 🙏

© 2026 – Pkg Stats / Ryan Hefner

watson-workspace

v1.0.3

Published

Module for interacting with Watson Workspace

Downloads

19

Readme

WatsonWorkspace

Module for working with Watson Workspace spaces.

Quick start

  1. Require the watson-workspace module:

    const ww = require('watson-workspace');
  2. Invoke the API functions. See the Examples section for details.

Authentication API

  • auth.getToken: Get a token to use for Watson Workspace interactions.

    On success: Returns a JSON object representing a valid token.

    On failure: Throws HTTP StatusCodeError.

    Example

      const ww = require('@ics/watson-workspace');
      const appId = process.env.APP_ID;
      const appSecret = process.env.APP_SECRET;
    
      var token;
    
      Promise.resolve()
      .then(() => ww.auth.getToken(token, appId, appSecret))
      .then((returnToken) => {
          console.log('Token: ' + JSON.stringify(returnToken));
          token = returnToken;
      })
      .catch((err) => console.error(err));
    Token: {"access_token":"eyJh...","token_type":"bearer","expires_in":43199,"scope":"read write","id":"3908d0cd-6df2-497d-a683-45a8616f8e85","jti":"ca7f671d-392a-4fca-a0b4-6842f8b9d8a9"}
  • auth.verifyWebhook: Verifies the challenge sent by Watson Workspace when enabling a webhook.

    On success: Returns a JSON object indicating success.

    On failure: Throws WebhookVerificationError or HTTP StatusCodeError.

    Example

    const ww = require('@ics/watson-workspace');
      
    return Promise.resolve()
    .then( () => ww.auth.verifyWebhook(req, res, webhookSecret) )
    .then( (result) => console.log('Result: ' + JSON.stringify(result)) )
    .catch( (err) => console.error(err) );

Spaces API

  • spaces.getSpaceByName: Gets information about the specified Watson Workspace space.

    On success: Returns a JSON object representing a Watson Workspace space.

    On failure: Throws NoSuchSpaceError or HTTP StatusCodeError.

    Example

      const ww = require('@ics/watson-workspace');
      const appId = process.env.APP_ID;
      const appSecret = process.env.APP_SECRET;
      const spaceName = "Chad's Sandbox";
    
      var token;
    
      Promise.resolve()
      .then( () => ww.auth.getToken(token, appId, appSecret) )
      .then( (returnToken) => token = returnToken )
      .then( () => ww.spaces.getSpaceByName(spaceName, token.access_token) )
      .then( (space) => console.log('Space: ' + JSON.stringify(space)) )
      .catch( (err) => console.error(err) );
    Space: {"id":"58d0f0e6e4b014d4036ee597","title":"Chad's Sandbox","description":null,"created":"2017-03-21T09:22:46.689+0000","updated":"2017-06-09T18:08:31.102+0000","membersUpdated":"2017-06-05T17:13:16.956+0000","createdBy":{"id":"48125740-8f0b-1028-92c4-db07163b51b2","email":"[email protected]"},"updatedBy":{"id":"48125740-8f0b-1028-92c4-db07163b51b2","email":"[email protected]"},"members":{"items":[{"email":"[email protected]","displayName":"Chad Scott"},{"email":null,"displayName":"WWModuleTester"}]}}
  • spaces.getSpaceById: Gets information about the specified Watson Workspace space.

    On success: Returns a JSON object representing a Watson Workspace space.

    On failure: Throws NoSuchSpaceError or HTTP StatusCodeError.

    Example

      const ww = require('@ics/watson-workspace');
      const appId = process.env.APP_ID;
      const appSecret = process.env.APP_SECRET;
      const spaceId = '58d0f0e6e4b014d4036ee597';
    
      var token;
    
      Promise.resolve()
      .then( () => ww.auth.getToken(token, appId, appSecret) )
      .then( (returnToken) => token = returnToken )
      .then( () => ww.spaces.getSpaceById(spaceId, token.access_token) )
      .then( (space) => console.log('Space: ' + JSON.stringify(space)) )
      .catch( (err) => console.error(err) );
    Space: {"id":"58d0f0e6e4b014d4036ee597","title":"Chad's Sandbox","description":null,"created":"2017-03-21T09:22:46.689+0000","updated":"2017-06-09T18:08:31.102+0000","membersUpdated":"2017-06-05T17:13:16.956+0000","createdBy":{"id":"48125740-8f0b-1028-92c4-db07163b51b2","email":"[email protected]"},"updatedBy":{"id":"48125740-8f0b-1028-92c4-db07163b51b2","email":"[email protected]"},"members":{"items":[{"email":"[email protected]","displayName":"Chad Scott"},{"email":null,"displayName":"WWModuleTester"}]}}

Messages API

  • messages.sendMessageToSpace: Sends a message to a Watson Workspace space.

    On success: Returns a JSON object indicating success.

    On failure: Throws HTTP StatusCodeError.

    Example

    This example uses the message template defined by the module in messages.messageTemplate.

      const ww = require('@ics/watson-workspace');
      const appId = process.env.APP_ID;
      const appSecret = process.env.APP_SECRET;
      const space = "Chad's Sandbox";
      var message = ww.messages.messageTemplate;
      message.annotations[0].text = 'Hello world!';
    
      var token;
    
      Promise.resolve()
      .then( () => ww.auth.getToken(token, appId, appSecret) )
      .then( (returnToken) => token = returnToken )
      .then( () => ww.spaces.getSpace(space, token.access_token) )
      .then( (space) => ww.messages.sendMessageToSpace(message, space.id, token.access_token) )
      .then( (result) => console.log('Result: ' + JSON.stringify(result)) )
      .catch( (err) => console.error(err) );
    Result: {"result":"success"}

Users API

  • users.getUserById: Gets information about the specified user.

    On success: Returns a JSON object representing the user.

    On failure: Throws NoSuchUserError or HTTP StatusCodeError.

    Example

      const ww = require('@ics/watson-workspace');
      const appId = process.env.APP_ID;
      const appSecret = process.env.APP_SECRET;
      const userId = '48125740-8f0b-1028-92c4-db07163b51b2';
    
      var token;
    
      Promise.resolve()
      .then( () => ww.auth.getToken(token, appId, appSecret) )
      .then( (returnToken) => token = returnToken )
      .then( () => ww.users.getUserById(userId, token.access_token) )
      .then( (user) => console.log('User: ' + JSON.stringify(user)) )
      .catch( (err) => console.error(err) );
    User: {"id":"48125740-8f0b-1028-92c4-db07163b51b2","displayName":"Chad Scott","email":"[email protected]"}
  • users.getUserByEmail: Gets information about the specified user.

    On success: Returns a JSON object representing the user.

    On failure: Throws NoSuchUserError or HTTP StatusCodeError.

    Example

      const ww = require('@ics/watson-workspace');
      const appId = process.env.APP_ID;
      const appSecret = process.env.APP_SECRET;
      const userEmail = '[email protected]';
    
      var token;
    
      Promise.resolve()
      .then( () => ww.auth.getToken(token, appId, appSecret) )
      .then( (returnToken) => token = returnToken )
      .then( () => ww.users.getUserByEmail(userEmail, token.access_token) )
      .then( (user) => console.log('User: ' + JSON.stringify(user)) )
      .catch( (err) => console.error(err) );
    User: {"id":"48125740-8f0b-1028-92c4-db07163b51b2","displayName":"Chad Scott","email":"[email protected]"}