BasePage Class — anthropic-sdk-python Architecture
Architecture documentation for the BasePage class in _base_client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 3543329f_b8e7_6257_bf27_c9c0879f8b2b["BasePage"] db838942_a85e_3ae9_fc7c_64a1ebba9727["GenericModel"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|extends| db838942_a85e_3ae9_fc7c_64a1ebba9727 f30eca5a_2fa0_68c1_64aa_b52331a2dcc8["NotGiven"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|extends| f30eca5a_2fa0_68c1_64aa_b52331a2dcc8 31e60ad8_cac8_652d_176d_4f7cf7dda1ad["_base_client.py"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|defined in| 31e60ad8_cac8_652d_176d_4f7cf7dda1ad c2d68dcc_755d_a64a_1980_a7bccf454598["has_next_page()"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|method| c2d68dcc_755d_a64a_1980_a7bccf454598 9848b028_9275_79a1_d720_3c9c5ece84b0["next_page_info()"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|method| 9848b028_9275_79a1_d720_3c9c5ece84b0 c223a180_1617_5ff7_0542_455d551fef40["_get_page_items()"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|method| c223a180_1617_5ff7_0542_455d551fef40 b381ee1f_de5b_9018_ba09_d5c61a85a361["_params_from_url()"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|method| b381ee1f_de5b_9018_ba09_d5c61a85a361 8431fb55_0370_3fd9_40c1_7e9f3735691f["_info_to_options()"] 3543329f_b8e7_6257_bf27_c9c0879f8b2b -->|method| 8431fb55_0370_3fd9_40c1_7e9f3735691f
Relationship Graph
Source Code
src/anthropic/_base_client.py lines 174–232
class BasePage(GenericModel, Generic[_T]):
"""
Defines the core interface for pagination.
Type Args:
ModelT: The pydantic model that represents an item in the response.
Methods:
has_next_page(): Check if there is another page available
next_page_info(): Get the necessary information to make a request for the next page
"""
_options: FinalRequestOptions = PrivateAttr()
_model: Type[_T] = PrivateAttr()
def has_next_page(self) -> bool:
items = self._get_page_items()
if not items:
return False
return self.next_page_info() is not None
def next_page_info(self) -> Optional[PageInfo]: ...
def _get_page_items(self) -> Iterable[_T]: # type: ignore[empty-body]
...
def _params_from_url(self, url: URL) -> httpx.QueryParams:
# TODO: do we have to preprocess params here?
return httpx.QueryParams(cast(Any, self._options.params)).merge(url.params)
def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
options = model_copy(self._options)
options._strip_raw_response_header()
if not isinstance(info.params, NotGiven):
options.params = {**options.params, **info.params}
return options
if not isinstance(info.url, NotGiven):
params = self._params_from_url(info.url)
url = info.url.copy_with(params=params)
options.params = dict(url.params)
options.url = str(url)
return options
if not isinstance(info.json, NotGiven):
if not is_mapping(info.json):
raise TypeError("Pagination is only supported with mappings")
if not options.json_data:
options.json_data = {**info.json}
else:
if not is_mapping(options.json_data):
raise TypeError("Pagination is only supported with mappings")
options.json_data = {**options.json_data, **info.json}
return options
raise ValueError("Unexpected PageInfo state")
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the BasePage class?
BasePage is a class in the anthropic-sdk-python codebase, defined in src/anthropic/_base_client.py.
Where is BasePage defined?
BasePage is defined in src/anthropic/_base_client.py at line 174.
What does BasePage extend?
BasePage extends GenericModel, NotGiven.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free