API Reference

Client

class jp_diet_search.client.DietClient(*, base_url: str = 'https://kokkai.ndl.go.jp/api', user_agent: str = 'jp-diet-search', timeout: float = 20.0, sleep_seconds: float = 0.0, cache_dir: str | Path | None = None, session: Session | None = None)[source]

Bases: object

Object API client for the NDL Diet Records API.

search_meeting(limit_total: int | None = None, **params: Any) Dict[str, Any][source]
search_meeting_list(limit_total: int | None = None, **params: Any) Dict[str, Any][source]
search_speech(limit_total: int | None = None, **params: Any) Dict[str, Any][source]
jp_diet_search.client.DietSearchClient

alias of DietClient

Queries

class jp_diet_search.queries.BaseQuery(*, start_record: Annotated[int | None, Ge(ge=1)] = None, maximum_records: Annotated[int | None, Ge(ge=1)] = None, record_packing: Literal['json', 'xml'] | None = 'json', name_of_house: str | None = None, name_of_meeting: str | None = None, any: str | None = None, speaker: str | None = None, from_date: str | None = None, until: str | None = None, supplement_and_appendix: bool | None = None, contents_and_index: bool | None = None, search_range: str | None = None, closing: bool | None = None, speech_number: int | None = None, speaker_position: str | None = None, speaker_group: str | None = None, speaker_role: str | None = None, speech_id: str | None = None, issue_id: str | None = None, session_from: int | None = None, session_to: int | None = None, issue_from: int | None = None, issue_to: int | None = None)[source]

Bases: BaseModel

Base query object for the Diet Search API.

This class is intentionally strict (extra=”forbid”) so typos are caught early.

any: str | None
closing: bool | None
contents_and_index: bool | None
from_date: str | None
issue_from: int | None
issue_id: str | None
issue_to: int | None
maximum_records: int | None
model_config = {'extra': 'forbid', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name_of_house: str | None
name_of_meeting: str | None
record_packing: RecordPacking | None
require_some_condition()[source]
search_range: str | None
session_from: int | None
session_to: int | None
speaker: str | None
speaker_group: str | None
speaker_position: str | None
speaker_role: str | None
speech_id: str | None
speech_number: int | None
start_record: int | None
supplement_and_appendix: bool | None
to_params() Dict[str, Any][source]

Convert this query to Diet Search API parameter dict.

until_date: str | None
class jp_diet_search.queries.MeetingListQuery(*, start_record: Annotated[int | None, Ge(ge=1)] = None, maximum_records: Annotated[int | None, Ge(ge=1)] = None, record_packing: Literal['json', 'xml'] | None = 'json', name_of_house: str | None = None, name_of_meeting: str | None = None, any: str | None = None, speaker: str | None = None, from_date: str | None = None, until: str | None = None, supplement_and_appendix: bool | None = None, contents_and_index: bool | None = None, search_range: str | None = None, closing: bool | None = None, speech_number: int | None = None, speaker_position: str | None = None, speaker_group: str | None = None, speaker_role: str | None = None, speech_id: str | None = None, issue_id: str | None = None, session_from: int | None = None, session_to: int | None = None, issue_from: int | None = None, issue_to: int | None = None)[source]

Bases: BaseQuery

classmethod max_100(v)[source]
model_config = {'extra': 'forbid', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class jp_diet_search.queries.MeetingQuery(*, start_record: Annotated[int | None, Ge(ge=1)] = None, maximum_records: Annotated[int | None, Ge(ge=1)] = None, record_packing: Literal['json', 'xml'] | None = 'json', name_of_house: str | None = None, name_of_meeting: str | None = None, any: str | None = None, speaker: str | None = None, from_date: str | None = None, until: str | None = None, supplement_and_appendix: bool | None = None, contents_and_index: bool | None = None, search_range: str | None = None, closing: bool | None = None, speech_number: int | None = None, speaker_position: str | None = None, speaker_group: str | None = None, speaker_role: str | None = None, speech_id: str | None = None, issue_id: str | None = None, session_from: int | None = None, session_to: int | None = None, issue_from: int | None = None, issue_to: int | None = None)[source]

Bases: BaseQuery

classmethod max_10(v)[source]
model_config = {'extra': 'forbid', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class jp_diet_search.queries.SpeechQuery(*, start_record: Annotated[int | None, Ge(ge=1)] = None, maximum_records: Annotated[int | None, Ge(ge=1)] = None, record_packing: Literal['json', 'xml'] | None = 'json', name_of_house: str | None = None, name_of_meeting: str | None = None, any: str | None = None, speaker: str | None = None, from_date: str | None = None, until: str | None = None, supplement_and_appendix: bool | None = None, contents_and_index: bool | None = None, search_range: str | None = None, closing: bool | None = None, speech_number: int | None = None, speaker_position: str | None = None, speaker_group: str | None = None, speaker_role: str | None = None, speech_id: str | None = None, issue_id: str | None = None, session_from: int | None = None, session_to: int | None = None, issue_from: int | None = None, issue_to: int | None = None)[source]

Bases: BaseQuery

classmethod max_100(v)[source]
model_config = {'extra': 'forbid', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Endpoints

class jp_diet_search.endpoints.MeetingEndpoint(core: _DietCore)[source]

Bases: object

search(query: MeetingQuery, *, limit_total: int | None = None) Dict[str, Any][source]
search_any(text: str, *, maximum_records: int = 10, limit_total: int | None = None) Dict[str, Any][source]
class jp_diet_search.endpoints.MeetingListEndpoint(core: _DietCore)[source]

Bases: object

search(query: MeetingListQuery, *, limit_total: int | None = None) Dict[str, Any][source]
search_any(text: str, *, maximum_records: int = 100, limit_total: int | None = None) Dict[str, Any][source]
class jp_diet_search.endpoints.SpeechEndpoint(core: _DietCore)[source]

Bases: object

search(query: SpeechQuery, *, limit_total: int | None = None) Dict[str, Any][source]
search_any(text: str, *, maximum_records: int = 100, limit_total: int | None = None) Dict[str, Any][source]
search_by_speaker(speaker: str, *, from_date: str | None = None, until_date: str | None = None, maximum_records: int = 100, limit_total: int | None = None) Dict[str, Any][source]

Exceptions

exception jp_diet_search.exceptions.DietSearchAPIError(message: str, details: List[str] | None = None)[source]

Bases: DietSearchError

Server/API-side errors (HTTP errors, API error payloads).

exception jp_diet_search.exceptions.DietSearchError[source]

Bases: Exception

Base exception for jp-diet-search.

exception jp_diet_search.exceptions.DietSearchParseError[source]

Bases: DietSearchRequestError

Raised when API responses cannot be parsed or decoded.

exception jp_diet_search.exceptions.DietSearchRateLimitError(message: str, details: List[str] | None = None)[source]

Bases: DietSearchAPIError

Raised when the API signals rate limiting (e.g. HTTP 429).

exception jp_diet_search.exceptions.DietSearchRequestError[source]

Bases: DietSearchError

Client-side errors (invalid params, misuse, parse failures).