Skip to content

Conversation

@BastienGimbert
Copy link
Contributor

Problem :

There was no simple function to get daily papers by date from the API.

Summary :

Add HfApi.list_daily_papers(date) to call /api/daily_papers.
Add a small test to check the endpoint returns objects and ISO date

Testing

pytest -q tests/test_hf_api.py::PaperApiTest

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @BastienGimbert, thanks for the PR and sorry for the long delay! PR is in a pretty good shape already. I've left a few comments to make it to the finish line. Thanks in advance 🤗

Comment on lines 9707 to 9708
*,
date: str,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*,
date: str,
date: Optional[str] = None,
*,

Date should be made optional, in which case it returns recent ones https://huggingface.co/api/daily_papers

(also it's fine to have date as positional arg)

```
"""
path = f"{self.endpoint}/api/daily_papers"
params = {"date": date}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
params = {"date": date}
params = {"date": date} if date is not None else {}

assert hasattr(papers[0], "title")

def test_list_daily_papers_by_date_invalid_date(self) -> None:
with self.assertRaises(ValueError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with self.assertRaises(ValueError):
with self.assertRaises(BadRequestError):

more specific to raise BadRequestError (HTTP 400)

…ter and add tests for default behavior ( After

Wauplin review )
@BastienGimbert
Copy link
Contributor Author

Hello @Wauplin,
I made all the changes you asked me to and added the new test.
6/6 tests passed
And yes, I forgot to declare it in ‘init.py’. my bad ;')

Have a nice day !

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick update @BastienGimbert ! I'll merge as soon as the CI passes.
Have a nice day too 😃

Copy link

@Samoed Samoed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems from https://huggingface-openapi.hf.space/#tag/papers/get/apipaperssearch daily papers also support p, limit, week, month, sort fields

@Wauplin
Copy link
Contributor

Wauplin commented Nov 28, 2025

@bot /style

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

Style bot fixed some files and pushed the changes.

@Wauplin
Copy link
Contributor

Wauplin commented Nov 28, 2025

Seems from https://huggingface-openapi.hf.space/#tag/papers/get/apipaperssearch daily papers also support p, limit, week, month, sort fields

@Samoed Would you like to open a follow-up PR once this one is merged to add support for these parameters? :)

@Samoed
Copy link

Samoed commented Nov 28, 2025

Yes, of course

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants