|
1 | | -# Rate-My-Professors-API-Client |
| 1 | +# RateMyProfessors API Client |
| 2 | + |
| 3 | +Typed, retrying, rate-limited unofficial client for RateMyProfessors, with optional |
| 4 | +helpers for ingestion workflows (sentiment, dedupe, course-code normalization). |
| 5 | + |
| 6 | +> Note: This library is **unofficial** and may break if RMP changes their internal API. |
| 7 | +
|
| 8 | +## Installation |
| 9 | + |
| 10 | +```bash |
| 11 | +pip install ratemyprofessors-client |
| 12 | +``` |
| 13 | + |
| 14 | +With optional sentiment extras (TextBlob): |
| 15 | + |
| 16 | +```bash |
| 17 | +pip install 'ratemyprofessors-client[sentiment]' |
| 18 | +``` |
| 19 | + |
| 20 | +## Quickstart |
| 21 | + |
| 22 | +```python |
| 23 | +from rmp_client import RMPClient |
| 24 | + |
| 25 | +SCHOOL_ID = 1466 # example: Queen's University ID on RMP |
| 26 | + |
| 27 | +with RMPClient() as client: |
| 28 | + for prof in client.iter_professors_for_school(SCHOOL_ID, page_size=20): |
| 29 | + print(prof.name, prof.overall_rating, prof.num_ratings) |
| 30 | +``` |
| 31 | + |
| 32 | +Fetch details and iterate ratings incrementally: |
| 33 | + |
| 34 | +```python |
| 35 | +from datetime import date |
| 36 | +from rmp_client import RMPClient |
| 37 | + |
| 38 | +with RMPClient() as client: |
| 39 | + professor = client.get_professor("PROFESSOR_ID") |
| 40 | + |
| 41 | + for rating in client.iter_professor_ratings(professor.id, since=date(2024, 1, 1)): |
| 42 | + print(rating.date, rating.quality, rating.comment) |
| 43 | +``` |
| 44 | + |
| 45 | +## Extras |
| 46 | + |
| 47 | +Optional helpers live under `rmp_client.extras`: |
| 48 | + |
| 49 | +- `rmp_client.extras.sentiment.analyze_sentiment` |
| 50 | +- `rmp_client.extras.dedupe.normalize_comment` / `is_valid_comment` |
| 51 | +- `rmp_client.extras.course_codes.build_course_mapping` |
| 52 | + |
| 53 | +See `docs/` and `examples/` for more. This repo also includes an |
| 54 | +`examples/ingest_supabase.py` script that mirrors a Supabase-centric |
| 55 | +scraping pipeline using this client. |
| 56 | + |
| 57 | +## Publishing to PyPI |
| 58 | + |
| 59 | +This project follows the [Python Packaging User Guide](https://packaging.python.org/en/latest/overview/) and uses [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/) with GitHub Actions. |
| 60 | + |
| 61 | +1. **One-time setup**: On [pypi.org](https://pypi.org/manage/account/publishing/) add a trusted publisher for this repo (workflow `publish-to-pypi.yml`, environment `pypi`). Create a `pypi` environment in the repo and enable “Required reviewers” for production releases. |
| 62 | +2. **Release**: Create and push a tag (e.g. `v0.1.0`). The workflow builds both a [wheel and an sdist](https://packaging.python.org/en/latest/overview/#python-binary-distributions) and publishes to PyPI. Any push builds and publishes to TestPyPI (use the `testpypi` environment). |
| 63 | + |
| 64 | +Local build (no publish): |
| 65 | + |
| 66 | +```bash |
| 67 | +pip install build |
| 68 | +python -m build |
| 69 | +# Outputs in dist/: .whl (wheel) and .tar.gz (sdist) |
| 70 | +``` |
0 commit comments