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
Search schools by name. Returns a paginated list of matching schools.
| Parameter | Type | Default | Description |
|---|---|---|---|
query | string | — | Search string (e.g. "Stanford") |
options.page_size | number | 20 | Results per page |
options.cursor | string | null | null | Cursor 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
Fetch a single school by its legacy numeric ID. Includes category summary ratings when available.
| Parameter | Type | Description |
|---|---|---|
schoolId | string | Legacy 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
Fetch two schools in parallel and return them as a pair.
| Parameter | Type | Description |
|---|---|---|
schoolId1 | string | First school's ID |
schoolId2 | string | Second school's ID |
Returns: CompareSchoolsResult
const cmp = await client.getCompareSchools("1466", "1491");
console.log(cmp.school_1.name, "vs", cmp.school_2.name);
getSchoolRatingsPage
Fetch one page of ratings for a school. All ratings are pre-fetched and cached on first call.
| Parameter | Type | Default | Description |
|---|---|---|---|
schoolId | string | — | Legacy numeric school ID |
options.page_size | number | 20 | Ratings per page |
options.cursor | string | null | null | Cursor 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
Async iterator that yields every rating for a school. Handles pagination automatically.
| Parameter | Type | Default | Description |
|---|---|---|---|
schoolId | string | — | Legacy numeric school ID |
options.page_size | number | 20 | Internal page size |
options.since | Date | null | null | Stop 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
Search professors by name. Optionally restrict to a specific school.
| Parameter | Type | Default | Description |
|---|---|---|---|
query | string | — | Search string (e.g. "Smith") |
options.school_id | string | null | null | Restrict results to this school |
options.page_size | number | 20 | Results per page |
options.cursor | string | null | null | Cursor 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
List professors at a specific school.
| Parameter | Type | Default | Description |
|---|---|---|---|
school_id | number | — | Legacy numeric school ID |
options.query | string | null | "" | Optional name filter |
options.page_size | number | 20 | Results per page |
options.cursor | string | null | null | Cursor 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
Async iterator that yields every professor at a school.
| Parameter | Type | Default | Description |
|---|---|---|---|
school_id | number | — | Legacy numeric school ID |
options.query | string | null | null | Optional name filter |
options.page_size | number | 20 | Internal page size |
Yields: Professor
for await (const prof of client.iterProfessorsForSchool(1466)) {
console.log(prof.name, prof.overall_rating);
}
getProfessor
Fetch a single professor by their legacy numeric ID.
| Parameter | Type | Description |
|---|---|---|
professorId | string | Legacy 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
Fetch one page of ratings for a professor. All ratings are pre-fetched and cached on first call.
| Parameter | Type | Default | Description |
|---|---|---|---|
professorId | string | — | Legacy numeric professor ID |
options.page_size | number | 20 | Ratings per page |
options.cursor | string | null | null | Cursor from previous page's next_cursor |
options.course_filter | string | null | null | Filter ratings by course |
Returns: ProfessorRatingsPage
const page = await client.getProfessorRatingsPage("2823076", { page_size: 5 });
console.log(page.professor.name, page.ratings.length);
iterProfessorRatings
Async iterator that yields every rating for a professor.
| Parameter | Type | Default | Description |
|---|---|---|---|
professorId | string | — | Legacy numeric professor ID |
options.page_size | number | 20 | Internal page size |
options.since | Date | null | null | Stop when a rating is older than this date |
options.course_filter | string | null | null | Filter 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
Send a raw JSON / GraphQL payload to the RMP endpoint.
| Parameter | Type | Description |
|---|---|---|
payload | Record<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 the HTTP client (aborts in-flight requests) and clear all rating caches.
await client.close();