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
3 changes: 3 additions & 0 deletions src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"inspect_scheduled_job",
"list_accepted_access_requests",
"list_collections",
"list_daily_papers",
"list_datasets",
"list_inference_catalog",
"list_inference_endpoints",
Expand Down Expand Up @@ -887,6 +888,7 @@
"interpreter_login",
"list_accepted_access_requests",
"list_collections",
"list_daily_papers",
"list_datasets",
"list_inference_catalog",
"list_inference_endpoints",
Expand Down Expand Up @@ -1244,6 +1246,7 @@ def __dir__():
inspect_scheduled_job, # noqa: F401
list_accepted_access_requests, # noqa: F401
list_collections, # noqa: F401
list_daily_papers, # noqa: F401
list_datasets, # noqa: F401
list_inference_catalog, # noqa: F401
list_inference_endpoints, # noqa: F401
Expand Down
37 changes: 37 additions & 0 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9702,6 +9702,42 @@ def paper_info(self, id: str) -> PaperInfo:
hf_raise_for_status(r)
return PaperInfo(**r.json())

def list_daily_papers(
self,
*,
date: Optional[str] = None,
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`, *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*):
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} 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():
yield PaperInfo(**paper)

def auth_check(
self, repo_id: str, *, repo_type: Optional[str] = None, token: Union[bool, str, None] = None
) -> None:
Expand Down Expand Up @@ -10723,6 +10759,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
Expand Down
16 changes: 16 additions & 0 deletions tests/test_hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4228,6 +4228,22 @@ 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(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:
Expand Down
Loading