1212 COLLABORATORS_PATH ,
1313 COMMENTS_PATH ,
1414 LABELS_PATH ,
15+ LABELS_SEARCH_PATH_SUFFIX ,
1516 PROJECT_ARCHIVE_PATH_SUFFIX ,
1617 PROJECT_UNARCHIVE_PATH_SUFFIX ,
1718 PROJECTS_PATH ,
@@ -1330,7 +1331,7 @@ def get_labels(
13301331 Be aware that each iteration fires off a network request to the Todoist API,
13311332 and may result in rate limiting or other API restrictions.
13321333
1333- :param limit: ` number of labels per page.
1334+ :param limit: Maximum number of labels per page.
13341335 :return: An iterable of lists of personal labels.
13351336 :raises requests.exceptions.HTTPError: If the API request fails.
13361337 :raises TypeError: If the API response structure is unexpected.
@@ -1351,6 +1352,41 @@ def get_labels(
13511352 params ,
13521353 )
13531354
1355+ def search_labels (
1356+ self ,
1357+ query : Annotated [str , MinLen (1 ), MaxLen (1024 )],
1358+ * ,
1359+ limit : Annotated [int , Ge (1 ), Le (200 )] | None = None ,
1360+ ) -> Iterator [list [Label ]]:
1361+ """
1362+ Search personal labels by name.
1363+
1364+ The response is an iterable of lists of labels matching the query.
1365+ Be aware that each iteration fires off a network request to the Todoist API,
1366+ and may result in rate limiting or other API restrictions.
1367+
1368+ :param query: Query string for label names.
1369+ :param limit: Maximum number of labels per page.
1370+ :return: An iterable of lists of labels.
1371+ :raises requests.exceptions.HTTPError: If the API request fails.
1372+ :raises TypeError: If the API response structure is unexpected.
1373+ """
1374+ endpoint = get_api_url (f"{ LABELS_PATH } /{ LABELS_SEARCH_PATH_SUFFIX } " )
1375+
1376+ params : dict [str , Any ] = {"query" : query }
1377+ if limit is not None :
1378+ params ["limit" ] = limit
1379+
1380+ return ResultsPaginator (
1381+ self ._session ,
1382+ endpoint ,
1383+ "results" ,
1384+ Label .from_dict ,
1385+ self ._token ,
1386+ self ._request_id_fn ,
1387+ params ,
1388+ )
1389+
13541390 def add_label (
13551391 self ,
13561392 name : Annotated [str , MinLen (1 ), MaxLen (60 )],
0 commit comments