Skip to content
Open
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
36 changes: 36 additions & 0 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/test_hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
SpaceInfo,
SpaceRuntime,
User,
PaperInfo,
WebhookInfo,
WebhookWatchedItem,
repo_type_and_id_from_hf_id,
Expand Down Expand Up @@ -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:
Expand Down
Loading