Skip to content

feat: Implement search-a-licious endpoint support#415

Open
saivats wants to merge 4 commits intoopenfoodfacts:developfrom
saivats:feat/search-a-licious
Open

feat: Implement search-a-licious endpoint support#415
saivats wants to merge 4 commits intoopenfoodfacts:developfrom
saivats:feat/search-a-licious

Conversation

@saivats
Copy link
Copy Markdown

@saivats saivats commented Jan 26, 2026

Description
This PR adds support for the new high-performance search-a-licious endpoint.

Changes

  • Added search_a_licious method to ProductResource.
  • Mapped parameters (query, page, sort_by) to the new API structure.
  • Compatibility: Automatically renames the API response key hits to products so the output structure matches the existing text_search behavior.

Motivation
As discussed with @teolemon and @raphael0202 on Slack, I am building a restaurant management tool (Restron) that requires faster bulk search capabilities. The existing CGI-based search was a bottleneck, so exposing this new endpoint was critical for my use case.

Related Issue
Fixes #314

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.

Thank you for the implementation!

Comment thread openfoodfacts/api.py Outdated
Comment thread openfoodfacts/api.py Outdated
Comment thread openfoodfacts/api.py
@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 Jan 26, 2026
Comment thread openfoodfacts/api.py Outdated
Comment on lines +196 to +198
# Handle environment for Search-a-licious (Requested by review)
domain = "net" if self.api_config.environment == Environment.net else "org"
self.base_searchalicious_url = f"https://search.openfoodfacts.{domain}"
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.

You should probably use URLBuilder here, by adding a search method in a similar way as what's done for Robotoff:

def robotoff(environment: Environment) -> str:
.

@saivats saivats requested a review from raphael0202 January 26, 2026 11:36
@raphael0202
Copy link
Copy Markdown
Contributor

@saivats I added a comment above regarding URLBuilder, maybe you missed it!

Comment thread openfoodfacts/utils/__init__.py
@sonarqubecloud
Copy link
Copy Markdown

Comment thread openfoodfacts/api.py
self.base_search_url = URLBuilder.search(self.api_config.environment)

def get(
self,
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.

It seems you indented by mistake these methods. Can you fix it?
You should run black after each edit, to make sure the formatting stays consistent.

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

Development

Successfully merging this pull request may close these issues.

Integrate search-a-licious endpoint into the Python SDK

2 participants