Function Reference

All methods live on the RMPClient class. They are async and return Promises (or async iterators). Always call close() when finished.

Schools #

searchSchools

searchSchools(query: string, options?): Promise<SchoolSearchResult>

Search schools by name. Returns a paginated list of matching schools.

ParameterTypeDefaultDescription
querystringSearch string (e.g. "Stanford")
options.page_sizenumber20Results per page
options.cursorstring | nullnullCursor from a previous result's next_cursor

Returns: SchoolSearchResult

const result = await client.searchSchools("Stanford");
for (const school of result.schools) {
  console.log(school.name, school.overall_quality);
}
if (result.has_next_page) {
  const page2 = await client.searchSchools("Stanford", { cursor: result.next_cursor });
}

getSchool

getSchool(schoolId: string): Promise<School>

Fetch a single school by its legacy numeric ID. Includes category summary ratings when available.

ParameterTypeDescription
schoolIdstringLegacy numeric school ID

Returns: School

Throws: ParsingError if the school is not found.

const school = await client.getSchool("1466");
console.log(school.name, school.reputation, school.safety);

getCompareSchools

getCompareSchools(schoolId1: string, schoolId2: string): Promise<CompareSchoolsResult>

Fetch two schools in parallel and return them as a pair.

ParameterTypeDescription
schoolId1stringFirst school's ID
schoolId2stringSecond school's ID

Returns: CompareSchoolsResult

const cmp = await client.getCompareSchools("1466", "1491");
console.log(cmp.school_1.name, "vs", cmp.school_2.name);

getSchoolRatingsPage

getSchoolRatingsPage(schoolId: string, options?): Promise<SchoolRatingsPage>

Fetch one page of ratings for a school. All ratings are pre-fetched and cached on first call.

ParameterTypeDefaultDescription
schoolIdstringLegacy numeric school ID
options.page_sizenumber20Ratings per page
options.cursorstring | nullnullCursor from previous page's next_cursor

Returns: SchoolRatingsPage

const page = await client.getSchoolRatingsPage("1466", { page_size: 5 });
console.log(page.school.name, page.ratings.length);

iterSchoolRatings

iterSchoolRatings(schoolId: string, options?): AsyncGenerator<SchoolRating>

Async iterator that yields every rating for a school. Handles pagination automatically.

ParameterTypeDefaultDescription
schoolIdstringLegacy numeric school ID
options.page_sizenumber20Internal page size
options.sinceDate | nullnullStop when a rating is older than this date

Yields: SchoolRating

for await (const rating of client.iterSchoolRatings("1466")) {
  console.log(rating.date, rating.comment, rating.overall);
}

Professors #

searchProfessors

searchProfessors(query: string, options?): Promise<ProfessorSearchResult>

Search professors by name. Optionally restrict to a specific school.

ParameterTypeDefaultDescription
querystringSearch string (e.g. "Smith")
options.school_idstring | nullnullRestrict results to this school
options.page_sizenumber20Results per page
options.cursorstring | nullnullCursor from a previous result

Returns: ProfessorSearchResult

const result = await client.searchProfessors("Smith");
for (const prof of result.professors) {
  console.log(prof.name, prof.department, prof.overall_rating);
}

listProfessorsForSchool

listProfessorsForSchool(school_id: number, options?): Promise<ProfessorSearchResult>

List professors at a specific school.

ParameterTypeDefaultDescription
school_idnumberLegacy numeric school ID
options.querystring | null""Optional name filter
options.page_sizenumber20Results per page
options.cursorstring | nullnullCursor from a previous result

Returns: ProfessorSearchResult

const result = await client.listProfessorsForSchool(1466, { page_size: 10 });
for (const prof of result.professors) {
  console.log(prof.name);
}

iterProfessorsForSchool

iterProfessorsForSchool(school_id: number, options?): AsyncGenerator<Professor>

Async iterator that yields every professor at a school.

ParameterTypeDefaultDescription
school_idnumberLegacy numeric school ID
options.querystring | nullnullOptional name filter
options.page_sizenumber20Internal page size

Yields: Professor

for await (const prof of client.iterProfessorsForSchool(1466)) {
  console.log(prof.name, prof.overall_rating);
}

getProfessor

getProfessor(professorId: string): Promise<Professor>

Fetch a single professor by their legacy numeric ID.

ParameterTypeDescription
professorIdstringLegacy numeric professor ID

Returns: Professor

Throws: ParsingError if the professor is not found.

const prof = await client.getProfessor("2823076");
console.log(prof.name, prof.department, prof.overall_rating);

getProfessorRatingsPage

getProfessorRatingsPage(professorId: string, options?): Promise<ProfessorRatingsPage>

Fetch one page of ratings for a professor. All ratings are pre-fetched and cached on first call.

ParameterTypeDefaultDescription
professorIdstringLegacy numeric professor ID
options.page_sizenumber20Ratings per page
options.cursorstring | nullnullCursor from previous page's next_cursor
options.course_filterstring | nullnullFilter ratings by course

Returns: ProfessorRatingsPage

const page = await client.getProfessorRatingsPage("2823076", { page_size: 5 });
console.log(page.professor.name, page.ratings.length);

iterProfessorRatings

iterProfessorRatings(professorId: string, options?): AsyncGenerator<Rating>

Async iterator that yields every rating for a professor.

ParameterTypeDefaultDescription
professorIdstringLegacy numeric professor ID
options.page_sizenumber20Internal page size
options.sinceDate | nullnullStop when a rating is older than this date
options.course_filterstring | nullnullFilter ratings by course

Yields: Rating

for await (const rating of client.iterProfessorRatings("2823076", {
  since: new Date("2024-01-01"),
})) {
  console.log(rating.date, rating.quality, rating.comment);
}

Low-level #

rawQuery

rawQuery(payload: Record<string, unknown>): Promise<Record<string, unknown>>

Send a raw JSON / GraphQL payload to the RMP endpoint.

ParameterTypeDescription
payloadRecord<string, unknown>Object with at least query and optionally operationName, variables

Returns: The full parsed response body.

const data = await client.rawQuery({ query: "{ viewer { id } }" });
console.log(data);

close

close(): Promise<void>

Close the HTTP client (aborts in-flight requests) and clear all rating caches.

await client.close();