Skip to contents

Makes a direct API call to retrieve all courses for a specific department and academic year from Stanford's ExploreCourses system. Returns the raw XML response without processing.

Usage

fetch_department_courses_raw(name, year = NULL)

Arguments

name

Character string. Department code (e.g., "CS" for Computer Science). Must be a valid Stanford department code.

year

Character string or NULL. Academic year in format YYYYYYYY (e.g., "20232024"). If NULL, defaults to current academic year. Will be validated using validate_academic_year().

Value

An xml2::xml_document object containing the raw courses XML. The XML structure includes:

  • Root courses element containing multiple course elements

  • Each course element contains:

    • Basic course information (ID, title, description)

    • Units information

    • Section data

    • Schedule information

    • Instructor details

Details

This function:

  1. Validates the academic year format

  2. Constructs the API URL using COURSE_ENDPOINT template

  3. Makes the API request for course data

The API returns all active courses for the specified department, including detailed information about:

  • Course metadata (title, description, units)

  • Sections and components

  • Meeting schedules

  • Instructor information

API Endpoint

Uses the COURSE_ENDPOINT template, which expands to:

https://explorecourses.stanford.edu/search?view=xml-20140630
  &academicYear={year}
  &q={name}
  &filter-departmentcode-{name}=on
  &filter-coursestatus-Active=on

Filters

The API request automatically includes filters for:

  • Department code match

  • Active courses only

See also

Examples

if (FALSE) { # \dontrun{
# Get current year CS courses
cs_xml <- fetch_department_courses_raw("CS")

# Get specific year Math courses
math_xml <- fetch_department_courses_raw("MATH", "20232024")
} # }