Client Library for University of Washington's Student Web Service


Keywords
uw, student, web, service, sws
License
MIT
Install
npm install uwsws@10.0.1

Documentation

UW Student Web Service

This implements most of the v5 UW Student Webservice endpoints. Each endpoint is queried using convenient 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.

Note: Version 9.0.0 and later require Node 16 and only support ES6 modules at this time. CommonJS may be supported in the future.

USE

Installation

npm i uwsws

Configuration

Configuration options are passed as an object to the constructor.

organizationName

The organization name is a string that identifies your organization and will appear in the headers of requests to the UW SWS API. This helps when working with UW IT to debug your application.

baseUrl

The URL of the SWS server. You can use the test or production server.

auth: { cert: 'cert data', key: 'key data' }

The Graduate Applicant Web Service requires that you pass a valid UW x509 client certificate with all requests. The data returned from the request is restricted to what is authorized for your cert.

You can use the included certificate fetcher helpers to get cert and key data from local files, from an AWS S3 bucket, or you can create a custom fetcher.

uwSwsLogLevel

To enable logging, you must install the log4js-node package. You don't need to import or configure log4js for it to work unless you want to handle log messages in some other way than sending them to stdout.

You can set the log level to trace, debug, info, warn, error, fatal, or off. If nothing is specified, the default level is off. When set to off log messages (even errors) will not display.

import UwSws from 'uwsws';

const config = {
  organizationName: 'YOUR ORGANIZATION NAME',

  baseUrl: 'https://ws.admin.washington.edu/student/v5/',

  //uwSwsLogLevel: 'debug',

  // Change 'certData' property to the return value of the
  // 'readCertificate()' method if using a certFetcher helper.
  certData: {
    cert: 'PASS CERT STRING OR BUFFER HERE',
    key: 'PASS CERT STRING OR BUFFER HERE',
  },
};


const uwSws = new UwSws(config);

const termData = await uwSws.term.current();

console.log(termData);

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

let options = {
  year: 2015,
  quarter: 'winter',
  curriculum: 'cse',
  course: '142'
};

const courseData = await uwSws.course.get(options);

console.log(courseData);

For more use examples see the unit tests in __tests__/*.

For a full list of all the supported endpoints and options see src/endpoints/*.

If you find one that doesn't work or if an endpoint or option isn't supported, please create an issue.

Certificate Fetchers

This package includes a helper module to fetch client certificates using different methods. The built-in fetcgers includes support for AWS S3 and the local file system. You can also create custom certificate fetchers. See the ./__tests__/certFetcher-test.ts file for a custom certFetcher example.

import { CertFetcherManager } from '../src/index';

// AWS S3 fetcher configuration options
const s3Config = {
  region: 'YOUR S3 REGION',
  certBucket: 'CERTIFICATE BUCKET NAME',
  certKey: 'CERTIFICATE KEY',
  keyBucket: 'KEY BUCKET NAME',
  keyKey: 'KEY KEY',
}

// Local file fetcher configuration options
const localConfig = {
      cert: 'PATH TO CERTIFICATE FILE',
      key: 'PATH TO KEY FILE',
    }

const certFetcherManager = new CertFetcherManager();

const s3Fetcher = certFetcherManager.getFetcher('s3');
const s3CertData = await s3Fetcher.readCertificate(s3Config);

const fileFetcher = certFetcherManager.getFetcher('file');
const fileCertData = await fileFetcher.readCertificate(localConfig);

// ... pass s3CertData or fileCertData to UwSws configuration object.

Endpoint Implementation

All of the UwSws methods return a promise for a result.

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

All of the option parameters are outlined in src/endpoint/* modules.

Endpoint Implementation
Campus UwSws.campus.all()
College Search UwSws.college.search(options)
Course UwSws.course.get(options)
Course Search UwSws.course.search(options)
Curriculum Search UwSws.curriculum.search(options)
Department Search UwSws.department.search(options)
Enrollment UwSws.enrollment.getRegistrations(options)
Enrollment Search UwSws.enrollment.getEnrolledTerms(options)
Major UwSws.major.search(options)
Person UwSws.person.get(regId)
Person Search UwSws.person.search(options)
Program UwSws.program.get(options)
Program Search UwSws.program.search(options)
Registration Search UwSws.registration.search(options)
Section UwSws.section.get(options)
Section Search UwSws.section.search(options)
Term UwSws.term.next(), .previous(), .current(), currentAndNext(number?), and get(options)
Test Score UwSws.testScore.get(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 __tests__/setup/config-sample.ts to __tests__/setup/config.ts and edit values as needed. Use the npm commands indicated in package.json.

npm test