npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rtu-schedule-unofficial-client

v1.0.13

Published

NPM package for scraping RTU schedule data from nodarbibas.rtu.lv

Downloads

1,074

Readme

Installation

npm install rtu-schedule-unofficial-client

Quick Start

import { RTUSchedule } from 'rtu-schedule-unofficial-client';

const rtu = new RTUSchedule();

// Get available periods, programs, courses, groups
const periods = await rtu.getPeriods();
const programs = await rtu.getPrograms('25/26-R');
const courses = await rtu.getCourses('25/26-R', 'RDBD0');
const groups = await rtu.getGroups('25/26-R', 'RDBD0', 1);

// Get schedule
const schedule = await rtu.getSchedule({
  period: '25/26-R',      // Autumn 2025/2026
  program: 'RDBD0',       // Computer Systems
  course: 1,              // 1st year
  group: 13               // Group 13 (optional)
});

// Work with results
console.log(schedule.count);                        // Entry count
const lectures = schedule.filterByType('lecture');  // Only lectures
const thisWeek = schedule.getThisWeek();            // This week's schedule
const byDay = schedule.groupByDate();               // Group by date

API Methods

Discovery

// All available semesters
const periods = await rtu.getPeriods();
// → [{ id, name, code, season, startDate, endDate, isSelected }, ...]

// Current semester
const current = await rtu.getCurrentPeriod();

// Programs for a semester (by ID, code, or name)
const programs = await rtu.getPrograms('25/26-R');
const programs = await rtu.getPrograms(45);
const programs = await rtu.getPrograms('Autumn 2025');

// Courses and groups
const courses = await rtu.getCourses('25/26-R', 'RDBD0');
const groups = await rtu.getGroups('25/26-R', 'RDBD0', 1);

Getting Schedule

const schedule = await rtu.getSchedule({
  // Period - code, name, or ID
  period: '25/26-R',        // or: 'Autumn 2025', periodId: 45

  // Program - code, name, or ID
  program: 'RDBD0',         // or: 'Computer Systems', programId: 123

  // Course (required)
  course: 1,

  // Group (optional - without it returns all groups)
  group: 13,

  // Date range (optional - defaults to semester dates)
  startDate: '2025-09-01',
  endDate: '2025-12-31'
});

Schedule Class

Filtering

All filters return a new Schedule object:

schedule.filter(e => e.durationMinutes > 60)    // Custom filter
schedule.filterByType('lecture')                 // By type
schedule.filterByType(['lecture', 'lab'])        // Multiple types
schedule.filterByDateRange(from, to)             // Date range
schedule.filterByDate(date)                      // Specific date
schedule.filterByLecturer('Smith')               // By lecturer
schedule.filterBySubject('Programming')          // By subject
schedule.filterByLocation('Building A')          // By location
schedule.filterByDayOfWeek(1)                    // By weekday (1=Monday)

Types: lecture | practical | lab | seminar | consultation | exam | test | other

Grouping

schedule.groupByWeek()       // Map<weekNumber, ScheduleEntry[]>
schedule.groupByDate()       // Map<'YYYY-MM-DD', ScheduleEntry[]>
schedule.groupByDayOfWeek()  // Map<1-7, ScheduleEntry[]>
schedule.groupBySubject()    // Map<subjectCode, ScheduleEntry[]>
schedule.groupByLecturer()   // Map<name, ScheduleEntry[]>
schedule.groupByType()       // Map<type, ScheduleEntry[]>

Convenience Methods

schedule.getToday()          // Today's entries
schedule.getTomorrow()       // Tomorrow's entries
schedule.getThisWeek()       // This week's entries
schedule.getNextWeek()       // Next week's entries
schedule.getUpcoming(7)      // Next N days
schedule.getWeek(36)         // Specific week

Aggregation

schedule.getLecturers()      // string[] - unique lecturers
schedule.getSubjects()       // {name, code}[] - unique subjects
schedule.getLocations()      // string[] - unique locations
schedule.getTypes()          // ScheduleEntryType[] - used types
schedule.getDateRange()      // {start, end} | null - date range

Properties

schedule.count               // Entry count
schedule.isEmpty             // Is empty
schedule.first               // First entry
schedule.last                // Last entry
schedule.entries             // ScheduleEntry[] - all entries
schedule.sorted('asc')       // Sorted by date
schedule.toArray()           // Array copy

// Iterable
for (const entry of schedule) { ... }
[...schedule]

ScheduleEntry Structure

interface ScheduleEntry {
  id: number;
  subject: { name: string; code: string };

  // Time
  date: Date;
  startTime: string;         // "09:00"
  endTime: string;           // "10:30"
  startDateTime: Date;
  endDateTime: Date;
  durationMinutes: number;

  // Location
  location: string;          // "Building A-423"
  building?: string;         // "Building A"
  room?: string;             // "423"

  // People
  lecturer: string;
  lecturers: string[];       // If multiple

  // Classification
  type: ScheduleEntryType;
  typeRaw: string;           // Original type string

  // Group
  group: string;
  groups: string[];          // If multiple

  // Week
  weekNumber: number;
  dayOfWeek: number;         // 1-7 (Mon-Sun)
  dayName: string;           // "Monday"
}

Error Handling

import {
  PeriodNotFoundError,      // Period not found
  ProgramNotFoundError,     // Program not found
  CourseNotFoundError,      // Course not found
  GroupNotFoundError,       // Group not found
  InvalidOptionsError,      // Invalid options
  DiscoveryError            // Discovery error
} from 'rtu-schedule-unofficial-client';

try {
  const schedule = await rtu.getSchedule({ ... });
} catch (error) {
  if (error instanceof PeriodNotFoundError) {
    console.error(`Period not found: ${error.input}`);
  }
}

Configuration

const rtu = new RTUSchedule({
  timeout: 10000,                  // API timeout ms
  cacheTimeout: 300000,            // API cache 5 min
  discoveryCacheTimeout: 3600000   // Discovery cache 1h
});

// Cache
rtu.clearCache();    // Clear cache
await rtu.refresh(); // Refresh

Low-Level API

import { apiClient, htmlParser } from 'rtu-schedule-unofficial-client';

// Direct API calls
const events = await apiClient.fetchSemesterProgramEvents({
  semesterProgramId: 123, year: 2025, month: 9
});
const subjects = await apiClient.fetchSemesterProgramSubjects(123);
const isPublished = await apiClient.checkSemesterProgramPublished(123);
const groups = await apiClient.findGroupsByCourse({
  courseId: 1, semesterId: 45, programId: 123
});
const courses = await apiClient.findCoursesByProgram({
  semesterId: 45, programId: 123
});

// HTML parsing
const semesters = htmlParser.parseHtmlSemesters(html);
const programs = htmlParser.parseHtmlPrograms(html);

TypeScript Support

import type {
  // High-level
  StudyPeriod, StudyProgram, StudyCourse, StudyGroup,
  ScheduleEntry, ScheduleEntryType, GetScheduleOptions,

  // Low-level
  SemesterEvent, Subject, Group, Course, Faculty, Semester
} from 'rtu-schedule-unofficial-client';

Examples

Full Workflow

import { RTUSchedule } from 'rtu-schedule-unofficial-client';

async function getMySchedule() {
  const rtu = new RTUSchedule();

  // 1. Get available periods for UI dropdown
  const periods = await rtu.getPeriods();
  console.log('Periods:', periods.map(p => p.name));

  // 2. Get programs for selected period
  const programs = await rtu.getPrograms(periods[0].id);
  console.log('Programs:', programs.map(p => `${p.name} (${p.code})`));

  // 3. Get schedule
  const schedule = await rtu.getSchedule({
    period: '25/26-R',
    program: 'RDBD0',
    course: 1,
    group: 13
  });

  // 4. Analyze schedule
  console.log(`Total: ${schedule.count} entries`);
  console.log(`Lecturers: ${schedule.getLecturers().join(', ')}`);
  console.log(`Subjects: ${schedule.getSubjects().map(s => s.name).join(', ')}`);

  // 5. Filter and group
  const lectures = schedule.filterByType('lecture');
  const byWeek = schedule.groupByWeek();

  for (const [week, entries] of byWeek) {
    console.log(`Week ${week}: ${entries.length} entries`);
  }

  return schedule;
}