We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
>>> results = api.facet.get('country') >>> print(results['count']) 575 >>> print(len(results['tags'])) 100
Get a facet returns only a single page (equivalent of https://world.openfoodfacts.net/countries.json)
something like that maybe?
def get(self, facet_name: Union[Facet, str], full_load: bool = False, unknown: bool = False) -> JSONType: facet = Facet.from_str_or_enum(facet_name) facet_plural = facet.value.replace("_", "-") all_results = [] page = 1 page_size = 100 params = {"json": "1"} if unknown: params["status"] = "unknown" while True: url = f"{self.base_url}/{facet_plural}" if page > 1: url = f"{url}/{page}" resp = send_get_request( url=url, params=params, api_config=self.api_config, auth=get_http_auth(self.api_config.environment), ) resp = cast(JSONType, resp) results = resp.get("tags", []) all_results.extend(results) if not full_load or len(results) < page_size: break page += 1 return {"tags": all_results}
It will probably face the request limitation after 5 or 10 pages.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Problem
Get a facet returns only a single page (equivalent of https://world.openfoodfacts.net/countries.json)
Proposed solution
something like that maybe?
It will probably face the request limitation after 5 or 10 pages.
The text was updated successfully, but these errors were encountered: