websoc-api
v3.0.0
Published
A small library to retrieve course data by scraping UCI's schedule of classes system
Downloads
36
Readme
Introduction
A nodejs module to access listings from UCI's schedule of classes, WebSoc. This API allows access to school, department, course, and section data in a hierarchical JSON format.
Installation
Requires NodeJS 12
$ npm install --save websoc-api
Documentation
Retrieving class listings
async callWebSocAPI(options)
To retrieve class listings, you just call the function you imported, callWebSocAPI
and pass in an object-literal
that configures what you're looking for, such as department, term, division etc.
options
Descriptions found here
| Name | Formatting | Notes | |------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------| | term | [Year] ['Fall'|'Winter'|'Spring'|'Summer1'|'Summer2'|'Summer10wk']Example: '2017 Fall' Default: ' ' | Required. Schedule for your selected term must be available on WebSoc. | | ge |['ANY'|'GE-1A'|'GE-1B'|'GE-2'|'GE-3'|'GE-4'|'GE-5A'|'GE-5B'|'GE-6'|'GE-7'|'GE-8']Example: 'GE-1B' Default: ' ' | Must specify at least one of department, GE, courseCodes, or instructorName | | department |List of available departments to search available in file depts.txtExample: 'I&C SCI' Default: ' ' | Must specify at least one of department, GE, courseCodes, or instructorName | | courseNumber |Any valid course number or rangeExample: '32A' OR '31-33' Default: ' ' | | | division |['ALL'|'LowerDiv'|'UpperDiv'|'Graduate']Example: 'LowerDiv' Default: 'ALL' | | | sectionCodes |Any valid 5-digit course code or rangeExample: "36531" OR "36520-36536" Default: ' ' | Must specify at least one of department, GE, courseCodes, or instructorName | | instructorName |Any valid instructor last name or part of last nameExample: 'Thornton' Default: ' ' | Enter last name only | | courseTitle |Any textExample: 'Intro' Default: ' ' | | | sectionType |['ALL'|'ACT'|'COL'|'DIS'|'FLD'|'LAB'|'LEC'|'QIZ'|'RES'|'SEM'|'STU'|'TAP'|'TUT']Example: 'LAB' Default: 'ALL' | | | units |Any integer or decimal with only tenths place precision, or 'VAR' to look for variable unit classes only.Example: '5' OR '1.3' Default: ' ' | | | days |['M'|'T'|'W'|'Th'|'F'] or a combination of these daysExample: 'T' OR 'MWF' Default: ' ' | | | startTime |Any time in 12 hour formatExample: '10:00AM' OR '5:00PM' Default: ' ' | Only enter sharp hours | | endTime |Any time in 12 hour formatExample: '12:00AM' OR '6:00PM' Default: ' ' | Only enter sharp hours | | maxCapacity |Exact number like '300' or modified with '<' or '>' to indicate less than specified or greater than specified.Example: '>256' OR '19' OR '<19' Default: ' ' | | | fullCourses |['ANY'|'SkipFullWaitlist'|'FullOnly'|'OverEnrolled'] 'SkipFullWaitlist' means that full courses will be included if there's space on the wait-list 'FullOnly' means only full courses will be retrieved 'OverEnrolled' means only over-enrolled courses will be retrievedExample:'SkipFullWaitlist' Default: 'ANY'| | | cancelledCourses |['Exclude'|'Include'|'Only']Example: 'Include' Default: 'EXCLUDE' | | | building |Any valid building codeExample: 'DBH' Default: ' ' | The value is a building code. Building codes found here: https://www.reg.uci.edu/addl/campus/ | | room |Any valid room numberExample: '223' Default: ' ' | You must specify a building code if you specify a room number |
Usage
// Import the module
import { callWebSocAPI } from 'websoc-api';
//Specify our search parameters
const opts = {
term: '2019 Fall',
GE: 'GE-2',
instructorName: 'Pattis'
}
// Call the module, and when the promise resolves, print out the JSON returned
const result = await callWebSocAPI(opts);
console.log(output);
Using retrieved data
The API serves its data in a hierarchical manner. The top level object is schools
.
Each school
in the array contains departments
, which contains courses
, which contain sections
.
School
| Field | Type | Notes | |-------------|-----------------------------|-------------------------------------------------------------------------------------------------------------| | schoolName | string | The name of the school like 'Donald Bren School of Information and Computer Science' | | schoolComment | string | | | departments | array of Department objects | |
Department
| Field | Type | Notes | |----------|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| | deptName | string | The name of the department like 'Informatics'. | | deptCode | string | The code of the department like 'IN4MATX'. | | deptComment | string | Comments that the department put on WebSoc. | | courses | array of Course objects | | | sectionCodeRangeComments | array | Comments associated with a range of sections. | | courseNumberRangeComments | array | Comments associated with a range of courses. |
Course
| Field | Type | Notes | |------------------|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| | courseNumber | string | Course number, like '33'.| | courseTitle | string | Course title, like 'INTERMEDIATE PRGRMG'.| | courseComment | string | | | prerequisiteLink | string | Link to the registrar's page where prerequistes are listed | | sections | array of Section objects | |
Section
| Field | Type | Notes | |----------------------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| | sectionCode | string | | | sectionType | string | | | sectionNum | string | | | units | string | | | instructors | array | | | meetings | array of objects with fields "days", "time" and "bldg" | If the meeting is "TBA", the field "days" will be "TBA" and the others will be empty strings. | | finalExam | string | | | maxCapacity | string | | | numCurrentlyEnrolled | object with fields "totalEnrolled" and "sectionEnrolled" | When a course is crosslisted, it will have both fields filled, otherwise, "sectionEnrolled" will be an empty string. | | numOnWaitlist | string | | | numRequested | string | | | numNewOnlyReserved | string | | | restrictions | string | The restriction code definitions can be found here | | status | string | | | sectionComment | string | |