node package manager

uwsws

UW Student Web Service

This implements most of the v5 UW Student Webservice endpoints. Each endpoint is queried using convienent options to build the final request.

This module assumes you have gone through all the required steps to get access and verified that access as documented in the SWS wiki.

USE

Installation

npm install uwsws

Examples

Import the module and set it's configuration. You must set a cacheMode to tell the module to handle http request responses. Responses can be cached to the filesystem (useful for development). In development, set cacheMode to record. In production, set cacheMode to wild to force all requests to go over the internet.

import uwsws from 'uwsws';
 
// With x509 cert
let config = {
  baseUrl:   'https://ws.admin.washington.edu/student/v5/',
  cert:      '/path/to/your/x509.pem',
  key:       '/path/to/your/x509.key',
  cacheMode: 'record',
  cachePath: '/path/to/a/cache/directory/',
  logLevel:  process.env.LOG_LEVEL || 'info'
};
 
// or....with Authentication Token
let config = {
  baseUrl:   'https://ws.admin.washington.edu/student/v5/',
  cacheMode: 'record',
  cachePath: '/path/to/a/cache/directory/',
  logLevel:  process.env.LOG_LEVEL || 'info',
  token:     'Your Auth Token'
};
 
uwsws.initialize(config);
 
uwsws.term.current()
  .then((result) => {
    console.log(result.term)
  });

Using the same config, get the intro to programming course for winter 2015.

let options = {
  year: 2015,
  quarter: 'winter',
  curriculum: 'cse',
  course: '142'
};
 
uwsws.course.get(options)
  .then((result) => {
    expect(result.course.CourseNumber).to.equal('142');
  });

For more examples see test/unit/*. For a full list of all the options see src/modules/*. Right now there isn't 100% coverage of all the options, but, in theory, they should work in the context of the query string parameters described in the SWS documentation. If you find one that doesn't work please create an issue.

Using a local cache

The cacheMode can be set to any one of the following modes. This uses the micro-cache node module as a local file system cache.

  • wild: all requests go out to the internet, don't load anything from cache, doesn't save anything.
  • dryrun: Loads files from cache if exists, does http calls when cache doesn't exist, doesn't save to the cache.
  • record: Loads files from the cache and saves new ones to the cache.

Logging

This module uses winston for all logging. Set an environment variable to a valid log level such as LOG_LEVEL=debug node yourscript.js.

Endpoint Implementation

All links below go to the official service documentation. The code block refers to it's implementation in this module.

Fully Supported

All of the uwsws methods return a promise for a result object that contains the following elements:

Object Element Meaning
statusCode This element represents the HTTP statusCode of the API response.
data This element represents the data returned by the SWS API. This element is empty if the request HTTP response code was not 200.
message This element represents the message returned in the body of non-200 HTTP response codes. A message is not returned if the status code is 200.

In most methods, the response body is returned in data element. However, where it makes sense, some of the original body is removed to provide cleaner access to only the data you need.

All of the option parameters are outlined in sr/modules/[endpoint]

Endpoint Implementation
Campus uwsws.campus.all()
College Search uwsws.college.search(campusName)
Course uwsws.course.get(options)
Course Search uwsws.course.search(options)
Curriculumn Search uwsws.curriculum.search(options)
Department Search uwsws.department.search(options)
Enrollment uwsws.enrollment.get(options)
Enrollment Search uwsws.entrollment.search(options)
Person uwsws.person.get(regid)
Person Search uwsws.person.search(options)
Registration Search uwsws.registration.search(options)
Section uwsws.section.get(options)
Section Search uwsws.section.search(options)
Term uwsws.term.next() or .previous(), or .current() as well as uwsws.term.search(options)
Test Score uwsws.testScore(options)

Not Implemented

Most of these are not implemented due to additional security requirements beyond a simple 509 cert. Requirements such as permissions in ASTRA or x-uw-act-as permissions passed in the header. Feel free fork and make a pull request with working tests if you have those permissions. Others are simply planned for a future release.

extra security needed
not needed

Development

Copy test/setup/config-sample.js to test/setup/config.js and edit values as needed. Use the npm commands indicated in package.json.

npm build
npm test

To Do

  • Implement Test Score endpoint
  • Implement the endpoints that require more security
  • Permit the use of a token instead of a x509 cert where applicable