From 8695cfa185e52046c985980b8ca8d79e6f6ec43a Mon Sep 17 00:00:00 2001 From: BastienGimbert Date: Wed, 29 Oct 2025 18:43:59 +0100 Subject: [PATCH 1/5] feat: add list_daily_papers method to fetch daily papers by date --- src/huggingface_hub/hf_api.py | 36 +++++++++++++++++++++++++++++++++++ tests/test_hf_api.py | 11 +++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py index 17b55ce3a5..bca395e6a5 100644 --- a/src/huggingface_hub/hf_api.py +++ b/src/huggingface_hub/hf_api.py @@ -9702,6 +9702,41 @@ def paper_info(self, id: str) -> PaperInfo: hf_raise_for_status(r) return PaperInfo(**r.json()) + def list_daily_papers( + self, + *, + date: str, + token: Union[bool, str, None] = None, + ) -> Iterable[PaperInfo]: + """ + List the daily papers published on a given date on the Hugging Face Hub. + + Args: + date (`str`): + Date in ISO format (YYYY-MM-DD) for which to fetch daily papers. + token (Union[bool, str, None], *optional*): + A valid user access token (string). Defaults to the locally saved + token. To disable authentication, pass `False`. + + Returns: + `Iterable[PaperInfo]`: an iterable of [`huggingface_hub.hf_api.PaperInfo`] objects. + + Example: + + ```python + >>> from huggingface_hub import HfApi + + >>> api = HfApi() + >>> list(api.list_daily_papers(date="2025-10-29")) + ``` + """ + path = f"{self.endpoint}/api/daily_papers" + params = {"date": date} + r = get_session().get(path, params=params, headers=self._build_hf_headers(token=token)) + hf_raise_for_status(r) + for paper in r.json(): + yield PaperInfo(**paper) + def auth_check( self, repo_id: str, *, repo_type: Optional[str] = None, token: Union[bool, str, None] = None ) -> None: @@ -10723,6 +10758,7 @@ def _parse_revision_from_pr_url(pr_url: str) -> str: list_papers = api.list_papers paper_info = api.paper_info +list_daily_papers = api.list_daily_papers repo_exists = api.repo_exists revision_exists = api.revision_exists diff --git a/tests/test_hf_api.py b/tests/test_hf_api.py index e700dde3b0..014928101c 100644 --- a/tests/test_hf_api.py +++ b/tests/test_hf_api.py @@ -64,6 +64,7 @@ SpaceInfo, SpaceRuntime, User, + PaperInfo, WebhookInfo, WebhookWatchedItem, repo_type_and_id_from_hf_id, @@ -4228,6 +4229,16 @@ def test_get_paper_by_id_not_found(self) -> None: self.api.paper_info("1234.56789") assert context.exception.response.status_code == 404 + def test_list_daily_papers_by_date(self) -> None: + papers = list(self.api.list_daily_papers(date="2025-10-29")) + assert len(papers) > 0 + assert hasattr(papers[0], "id") + assert hasattr(papers[0], "title") + + def test_list_daily_papers_by_date_invalid_date(self) -> None: + with self.assertRaises(ValueError): + list(self.api.list_daily_papers(date="2025-13-40")) + class WebhookApiTest(HfApiCommonTest): def setUp(self) -> None: From 4ee570a9f9dae4b520b74f87fdb8d317a527c6e6 Mon Sep 17 00:00:00 2001 From: Bastien GIMBERT Date: Fri, 28 Nov 2025 11:47:54 +0100 Subject: [PATCH 2/5] feat: update list_daily_papers method to support optional date parameter and add tests for default behavior ( After Wauplin review ) --- src/huggingface_hub/__init__.py | 3 +++ src/huggingface_hub/hf_api.py | 5 +++-- tests/test_hf_api.py | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/huggingface_hub/__init__.py b/src/huggingface_hub/__init__.py index 2ecd93513e..73b2c2f8b6 100644 --- a/src/huggingface_hub/__init__.py +++ b/src/huggingface_hub/__init__.py @@ -231,6 +231,7 @@ "list_accepted_access_requests", "list_collections", "list_datasets", + "list_daily_papers", "list_inference_catalog", "list_inference_endpoints", "list_jobs", @@ -888,6 +889,7 @@ "list_accepted_access_requests", "list_collections", "list_datasets", + "list_daily_papers", "list_inference_catalog", "list_inference_endpoints", "list_jobs", @@ -1245,6 +1247,7 @@ def __dir__(): list_accepted_access_requests, # noqa: F401 list_collections, # noqa: F401 list_datasets, # noqa: F401 + list_daily_papers, # noqa: F401 list_inference_catalog, # noqa: F401 list_inference_endpoints, # noqa: F401 list_jobs, # noqa: F401 diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py index bca395e6a5..bca08ddaa1 100644 --- a/src/huggingface_hub/hf_api.py +++ b/src/huggingface_hub/hf_api.py @@ -9705,7 +9705,7 @@ def paper_info(self, id: str) -> PaperInfo: def list_daily_papers( self, *, - date: str, + date: Optional[str] = None, token: Union[bool, str, None] = None, ) -> Iterable[PaperInfo]: """ @@ -9714,6 +9714,7 @@ def list_daily_papers( Args: date (`str`): Date in ISO format (YYYY-MM-DD) for which to fetch daily papers. + Defaults to most recent ones. token (Union[bool, str, None], *optional*): A valid user access token (string). Defaults to the locally saved token. To disable authentication, pass `False`. @@ -9731,7 +9732,7 @@ def list_daily_papers( ``` """ path = f"{self.endpoint}/api/daily_papers" - params = {"date": date} + params = {"date": date} if date is not None else {} r = get_session().get(path, params=params, headers=self._build_hf_headers(token=token)) hf_raise_for_status(r) for paper in r.json(): diff --git a/tests/test_hf_api.py b/tests/test_hf_api.py index 014928101c..f9e2bac8f7 100644 --- a/tests/test_hf_api.py +++ b/tests/test_hf_api.py @@ -4236,9 +4236,15 @@ def test_list_daily_papers_by_date(self) -> None: assert hasattr(papers[0], "title") def test_list_daily_papers_by_date_invalid_date(self) -> None: - with self.assertRaises(ValueError): + with self.assertRaises(BadRequestError): list(self.api.list_daily_papers(date="2025-13-40")) + def test_list_daily_papers_default_date(self) -> None: + papers = list(self.api.list_daily_papers()) + assert len(papers) > 0 + assert hasattr(papers[0], "id") + assert hasattr(papers[0], "title") + class WebhookApiTest(HfApiCommonTest): def setUp(self) -> None: From 07c2bf04a02b1fa336edcbf1c58a736ca3b6c744 Mon Sep 17 00:00:00 2001 From: Lucain Date: Fri, 28 Nov 2025 12:02:43 +0100 Subject: [PATCH 3/5] Apply suggestion from @Wauplin --- tests/test_hf_api.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_hf_api.py b/tests/test_hf_api.py index f9e2bac8f7..0274168868 100644 --- a/tests/test_hf_api.py +++ b/tests/test_hf_api.py @@ -64,7 +64,6 @@ SpaceInfo, SpaceRuntime, User, - PaperInfo, WebhookInfo, WebhookWatchedItem, repo_type_and_id_from_hf_id, From 208ffdd605aba319430b89a2a3b2880dfb780234 Mon Sep 17 00:00:00 2001 From: Bastien GIMBERT <134143391+BastienGimbert@users.noreply.github.com> Date: Fri, 28 Nov 2025 12:23:37 +0100 Subject: [PATCH 4/5] Update src/huggingface_hub/hf_api.py Co-authored-by: Roman Solomatin --- src/huggingface_hub/hf_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py index bca08ddaa1..2bfde71d6d 100644 --- a/src/huggingface_hub/hf_api.py +++ b/src/huggingface_hub/hf_api.py @@ -9712,7 +9712,7 @@ def list_daily_papers( List the daily papers published on a given date on the Hugging Face Hub. Args: - date (`str`): + date (`str`, *optional*): Date in ISO format (YYYY-MM-DD) for which to fetch daily papers. Defaults to most recent ones. token (Union[bool, str, None], *optional*): From 0faffddead5b922b563ede1c26be2c6c318cdee2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 28 Nov 2025 11:33:12 +0000 Subject: [PATCH 5/5] Apply style fixes --- src/huggingface_hub/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/huggingface_hub/__init__.py b/src/huggingface_hub/__init__.py index 73b2c2f8b6..9d1d025ef1 100644 --- a/src/huggingface_hub/__init__.py +++ b/src/huggingface_hub/__init__.py @@ -230,8 +230,8 @@ "inspect_scheduled_job", "list_accepted_access_requests", "list_collections", - "list_datasets", "list_daily_papers", + "list_datasets", "list_inference_catalog", "list_inference_endpoints", "list_jobs", @@ -888,8 +888,8 @@ "interpreter_login", "list_accepted_access_requests", "list_collections", - "list_datasets", "list_daily_papers", + "list_datasets", "list_inference_catalog", "list_inference_endpoints", "list_jobs", @@ -1246,8 +1246,8 @@ def __dir__(): inspect_scheduled_job, # noqa: F401 list_accepted_access_requests, # noqa: F401 list_collections, # noqa: F401 - list_datasets, # noqa: F401 list_daily_papers, # noqa: F401 + list_datasets, # noqa: F401 list_inference_catalog, # noqa: F401 list_inference_endpoints, # noqa: F401 list_jobs, # noqa: F401