Skip to main content

Typed, retrying, rate-limited unofficial Python client for the RateMyProfessors GraphQL API.

Project description

RateMyProfessors API Client (Python)

PyPI downloads docs

A typed, retrying, rate-limited unofficial client for RateMyProfessors.

Looking for TypeScript? Check out the TypeScript version.

Requirements

  • Python 3.10 or later
  • Works with type checkers (Pydantic models, fully typed API)

Installation

pip install ratemyprofessors-client

Available Functions

Create a client and call any of these methods. See the full docs for parameters, return types, and examples.

from rmp_client import RMPClient

with RMPClient() as client:
    ...

Schools

  • search_schools(query) — Search schools by name. Returns paginated results.
  • get_school(school_id) — Get a single school by its numeric ID.
  • get_compare_schools(school_id_1, school_id_2) — Fetch two schools side by side.
  • get_school_ratings_page(school_id) — Get one page of school ratings (cached after first fetch).
  • iter_school_ratings(school_id) — Iterator over all ratings for a school.

Professors

  • search_professors(query) — Search professors by name. Returns paginated results.
  • list_professors_for_school(school_id) — List professors at a given school.
  • iter_professors_for_school(school_id) — Iterator over all professors at a school.
  • get_professor(professor_id) — Get a single professor by their numeric ID.
  • get_professor_ratings_page(professor_id) — Get one page of professor ratings (cached after first fetch).
  • iter_professor_ratings(professor_id) — Iterator over all ratings for a professor.

Low-level

  • raw_query(payload) — Send a raw GraphQL payload to the RMP endpoint.

Lifecycle

  • close() — Close the client and clear caches. Safe to call multiple times.

Errors and What They Mean

All errors extend RMPError. Catch and narrow with isinstance:

  • HttpError — The server returned a non-2xx status code (e.g. 404, 500).
  • ParsingError — The response couldn't be parsed (e.g. professor/school not found).
  • RateLimitError — The client's local rate limiter blocked the request.
  • RetryError — The request failed after all retry attempts. Contains the last underlying error.
  • RMPAPIError — The GraphQL API returned an errors array in the response.
  • ConfigurationError — Invalid client configuration.
from rmp_client import RMPClient, HttpError, ParsingError

with RMPClient() as client:
    try:
        prof = client.get_professor("2823076")
    except ParsingError:
        print("Professor not found")
    except HttpError as e:
        print(f"HTTP error: {e.status_code}")

Types

All methods return Pydantic models. Import any of these:

from rmp_client.models import (
    School,
    Professor,
    Rating,
    SchoolRating,
    ProfessorSearchResult,
    SchoolSearchResult,
    ProfessorRatingsPage,
    SchoolRatingsPage,
    CompareSchoolsResult,
)
  • School — ID, name, location, overall quality, category ratings (reputation, safety, etc.)
  • Professor — ID, name, department, school, overall rating, difficulty, percent take again
  • Rating — Date, comment, quality, difficulty, tags, course, thumbs up/down
  • SchoolRating — Date, comment, overall score, category ratings, thumbs up/down
  • ProfessorSearchResult / SchoolSearchResult — Paginated list with has_next_page and next_cursor
  • ProfessorRatingsPage / SchoolRatingsPage — One page of ratings with cursor pagination
  • CompareSchoolsResult — A pair of schools

Extras

Optional helpers for data pipelines:

from rmp_client import (
    analyze_sentiment,
    normalize_comment,
    is_valid_comment,
    build_course_mapping,
    clean_course_label,
)
  • normalize_comment(text, *, strip_html=True, strip_punctuation=False) — Normalize text for deduplication (trim, strip HTML, lowercase, collapse whitespace; optionally strip punctuation)
  • is_valid_comment(text, *, min_len=10) — Validate a comment and return a ValidationResult with diagnostics (empty, too short, all caps, excessive repeats, no alpha)
  • clean_course_label(raw) — Clean scraped course labels (remove counts, normalize whitespace)
  • build_course_mapping(scraped, valid) — Map scraped labels to known course codes
  • analyze_sentiment(text) — Compute sentiment label from text (uses TextBlob)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ratemyprofessors_client-2.1.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ratemyprofessors_client-2.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file ratemyprofessors_client-2.1.0.tar.gz.

File metadata

  • Download URL: ratemyprofessors_client-2.1.0.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ratemyprofessors_client-2.1.0.tar.gz
Algorithm Hash digest
SHA256 c940f5fc27894b5487bf3cc34fa9998e0de9d54498462a5b5b3b42a06bbff7fb
MD5 ec4261e8e42d187a92a3c42aadf28133
BLAKE2b-256 80686eb7e445c615d67c61d6d8868a4818e50860a4dbc0230aab1a633ab56ada

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratemyprofessors_client-2.1.0.tar.gz:

Publisher: publish-to-pypi.yml on amaanjaved1/Rate-My-Professors-API-Client-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ratemyprofessors_client-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ratemyprofessors_client-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f68436e00e6d208176225439e5b8e58e303c4b1e576b462f6b6061397d5c073
MD5 69f181583bb05aaf67ab9754f6e47002
BLAKE2b-256 b1e0c9b17ea70e0e1aed01e77d3fe9375bbe09f1f5bec2b75e7164113f6c77fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratemyprofessors_client-2.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on amaanjaved1/Rate-My-Professors-API-Client-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page