Skip to content

ianwremmel/spark-js-sdk

 
 

Repository files navigation

spark-js-sdk

npm license

The Cisco Spark JavaScript SDK

This is a monorepo containing all officially maintained Cisco Spark JavaScript SDK modules in the same repo.

ciscospark is a collection of node modules targeting our external APIs.

Table of Contents

Install

We test against the current LTS version of Node.js (6.10) but the SDK should work with any supported version of Node.js.

To install the latest stable version from NPM:

npm install --save ciscospark

Usage

To use the SDK, you will need Cisco Spark credentials. If you do not already have a Cisco Spark account, visit Spark for Developers to create your account and retrieve your access token.

See the detailed docs for more usage examples.

Node.js

You will need to set the following environment variable:

  • CISCOSPARK_ACCESS_TOKEN
const assert = require(`assert`);
assert(process.env.CISCOSPARK_ACCESS_TOKEN, 'This example assumes you have set your access token as an environment variable');
const ciscospark = require(`ciscospark`);
ciscospark.rooms.create({title: `My First Room`})
  .then((room) => {
    return Promise.all([
      ciscospark.memberships.create({
        roomId: room.id,
        personEmail: `alice@example.com`
      }),
      ciscospark.memberships.create({
        roomId: room.id,
        personEmail: `bob@example.com`
      }),
    ])
      .then(() => ciscospark.messages.create({
        markdown: `**Hi Everyone**`,
        roomId: room.id
      }));
  });

Browsers

We do not provide a pre-built version of ciscospark.

If you've already got a commonjs or es6 build process in place, you can simply use const ciscospark = require('ciscospark').

If you need to load ciscospark via a script tag, you will need to build it first:

npm install ciscospark
npm install -g browserify
echo "window.ciscospark = require('ciscospark')" > ./index.js
browserify index.js > bundle.js

In-browser usage is pretty much the same as Node.js usage, with the addition of handling the user authentication flow for you. See the guide on the docs site for more information.

Contribute

Pull requests welcome. Please see CONTRIBUTING.md for more details about building the packages and submitting pull requests for suggested changes.

License

© 2016-2017 Cisco Systems, Inc. and/or its affiliates. All Rights Reserved.

See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.3%
  • Shell 1.7%