Skip to content

feat: search-a-licious integration to the Python SDK#326

Closed
hahacen wants to merge 2 commits intoopenfoodfacts:developfrom
hahacen:searchalicious-integration
Closed

feat: search-a-licious integration to the Python SDK#326
hahacen wants to merge 2 commits intoopenfoodfacts:developfrom
hahacen:searchalicious-integration

Conversation

@hahacen
Copy link
Copy Markdown

@hahacen hahacen commented Apr 25, 2025

Add support for Advanced Search (search_advanced)

  • This pull request adds the search_advanced(query, filters=None, page=1) method to the Open Food Facts Python SDK, addressing Issue #314.
    • Allows developers to perform advanced product searches with optional filters and pagination.
    • Integrated cleanly into the existing API class.
    • Includes error handling for missing responses.

  • Fixes Integrate search-a-licious endpoint into the Python SDK #314.

@sonarqubecloud
Copy link
Copy Markdown

@areebahmeddd
Copy link
Copy Markdown
Member

Hey @hahacen,

Nice work! Since maintainers are mostly focused on other repos, feedback here might be limited. For a quicker response, feel free to share it in the #api channel on OFF Slack: link : )

@raphael0202 raphael0202 changed the title Searchalicious integration feat: searchalicious integration May 21, 2025
Copy link
Copy Markdown
Contributor

@raphael0202 raphael0202 left a comment

Choose a reason for hiding this comment

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

First, sorry for the delay in the code review, the permanent team has been quite overwhelmed lately.
Thank you for your contribution! I think you implemented the wrong search endpoint, you can find more details on my comment below.

Comment thread openfoodfacts/api.py
self.facet = FacetResource(self.api_config)
self.robotoff = RobotoffResource(self.api_config)

def search_advanced(self, query: str, filters: dict = None, page: int = 1):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Invalid type for filters parameter here:

Suggested change
def search_advanced(self, query: str, filters: dict = None, page: int = 1):
def search_advanced(self, query: str, filters: Optional[dict] = None, page: int = 1):

Comment thread openfoodfacts/api.py
def search_advanced(self, query: str, filters: dict = None, page: int = 1):
"""Advanced product search using Search-a-licious endpoint."""
filters = filters or {}
params = {"search_terms": query, "page": page, **filters}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The search terms should be provided using the q parameter, see the search-a-licious documentation here: https://search.openfoodfacts.org/docs#/default/search_get_search_get

Comment thread openfoodfacts/api.py
"""Advanced product search using Search-a-licious endpoint."""
filters = filters or {}
params = {"search_terms": query, "page": page, **filters}
url = f"{self.product.base_url}/cgi/search.pl"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not search-a-licious endpoint, https://search.openfoodfacts.org/search is the right one

@github-project-automation github-project-automation Bot moved this from In progress to Review in progress in 🐍 Python SDK - Keep on par with the API May 21, 2025
@github-project-automation github-project-automation Bot moved this to Backlog (ready for dev) in 🔎 Search-a-licious Jun 27, 2025
@Idotr1997
Copy link
Copy Markdown

can someone please merge it?

@teolemon teolemon changed the title feat: searchalicious integration feat: search-a-licious integration to the Python SDK Aug 10, 2025
@teolemon
Copy link
Copy Markdown
Member

@raphael0202
Copy link
Copy Markdown
Contributor

can someone please merge it?

And the requested changes above were not done yet!

@teolemon teolemon moved this from Todo to In Progress in 🧃🛠️ Open Food Facts SDK tracking Aug 14, 2025
@teolemon teolemon moved this from Backlog (ready for dev) to In Progress in 🔎 Search-a-licious Aug 21, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in 🔎 Search-a-licious Feb 13, 2026
@github-project-automation github-project-automation Bot moved this from Review in progress to Done in 🐍 Python SDK - Keep on par with the API Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Integrate search-a-licious endpoint into the Python SDK

5 participants