Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pip install ratemyprofessors-client

## Available Functions

Create a client and call any of these methods. See the [full docs](docs/) for parameters, return types, and examples.
Create a client and call any of these methods. See the [full docs](https://amaanjaved1.github.io/Rate-My-Professors-API-Client-Python/) for parameters, return types, and examples.

```python
from rmp_client import RMPClient
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ build-backend = "hatchling.build"

[project]
name = "ratemyprofessors-client"
version = "0.1.0"
description = "A Python API Client for RateMyProfessors."
version = "2.0.0"
description = "Typed, retrying, rate-limited unofficial Python client for the RateMyProfessors GraphQL API."
readme = "README.md"
requires-python = ">=3.10"
license = { text = "MIT" }
authors = [
{ name = "Amaan", email = "amaanjaved2004@gmail.com" },
]
keywords = ["ratemyprofessors", "api-client", "scraping", "ratings"]
keywords = ["ratemyprofessors", "api-client", "graphql", "ratings"]
classifiers = [
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
Expand Down Expand Up @@ -42,7 +42,8 @@ dev = [
]

[project.urls]
Repository = "https://github.com/amaanjaved1/Rate-My-Professors-API-Client-Python"
Repository = "https://github.com/amaanjaved1/Rate-My-Professors-API-Client"
Documentation = "https://amaanjaved1.github.io/Rate-My-Professors-API-Client/"

[tool.hatch.build.targets.wheel]
packages = ["src/rmp_client"]
Expand Down
20 changes: 13 additions & 7 deletions src/rmp_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Any, Dict, Iterator, List, Mapping, Optional, Tuple

from .config import RMPClientConfig
from .errors import ParsingError
from .errors import HttpError, ParsingError, RetryError, RMPAPIError
from .http import HttpClient, HttpClientContext
from .models import (
CompareSchoolsResult,
Expand Down Expand Up @@ -197,7 +197,7 @@ def search_professors(
"""Search professors by name (TeacherSearchResultsPageQuery)."""
query_var: Dict[str, Any] = {"text": query}
if school_id is not None:
query_var["schoolID"] = school_id
query_var["schoolID"] = _school_node_id(school_id)

data = self.raw_query({
"operationName": "TeacherSearchResultsPageQuery",
Expand Down Expand Up @@ -250,7 +250,7 @@ def list_professors_for_school(
) -> ProfessorSearchResult:
"""List professors at a school. Wrapper around :meth:`search_professors`."""
return self.search_professors(
query=query or "",
query=query if query else " ",
school_id=str(school_id),
page_size=page_size,
cursor=cursor,
Expand Down Expand Up @@ -351,9 +351,12 @@ def get_professor_ratings_page(
after = first.next_cursor if first.has_next_page else None

while after is not None:
nxt = self._fetch_professor_ratings_page(
professor_id, after=after, first=100, course_filter=course_filter
)
try:
nxt = self._fetch_professor_ratings_page(
professor_id, after=after, first=100, course_filter=course_filter
)
except (RMPAPIError, HttpError, RetryError):
break
all_ratings.extend(nxt.ratings)
after = nxt.next_cursor if nxt.has_next_page else None

Expand Down Expand Up @@ -459,7 +462,10 @@ def get_school_ratings_page(
after = first.next_cursor if first.has_next_page else None

while after is not None:
nxt = self._fetch_school_ratings_page(school_id, after=after, first=100)
try:
nxt = self._fetch_school_ratings_page(school_id, after=after, first=100)
except (RMPAPIError, HttpError, RetryError):
break
all_ratings.extend(nxt.ratings)
after = nxt.next_cursor if nxt.has_next_page else None

Expand Down
1 change: 1 addition & 0 deletions src/rmp_client/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
node(id: $id) {
... on School {
id
legacyId
name
city
state
Expand Down
Loading
Loading