Closed stephanegigandet closed 1 year ago
Unfortunately my computer power cable crashed this morning.
@monsieurtanuki Sorry to hear that. :(
@stephanegigandet I have a new cable now: I'm back ;)
@monsieurtanuki Wonderful :)
@stephanegigandet Regarding api v3 and "get products" queries, in Smoothie we sometimes use "user" queries (e.g. "the products I contributed to"), and for that we use a different syntax.
Instead of /cgi/search.pl
, we use
/contributor/$userId.json
(for contributor)/api/v2/search
(for photographer, informer and to be completed)But it doesn't look like we can apply the api_version=3
parameter, which makes it impossible to retrieve packagings for user related search (which does not) - for text search it's OK as we saw.
@monsieurtanuki I also added recently a new field "packagings_complete" which takes values 0 or 1, to indicate if all the packaging components are listed: https://github.com/openfoodfacts/openfoodfacts-server/pull/7856/files
@monsieurtanuki for the "user" queries, I will need to implement /api/v3/search but there won't be server deployments until the first week of January.
There is a possible workaround:
It works for editors, photographers, informers
It doesn't work for contributor
@stephanegigandet Actually I wouldn't call it a workaround but the solution! I like this "search.pl / tagtype_x" syntax: doing so we reuse the same query search pattern as most queries.
Of course, if it could work for "contributor" that would solve it all. For the moment I will make it work in off-dart for editors, photographers and informers.
@stephanegigandet Actually there is probably a tag for "contributor": wouldn't it be creator
?
And for "to be completed", I interpret that as "all the products I'm an informer for and with the state 'en:to-be-completed'
".
Therefore I'm done here, just about to PR: I got the same counts with the old v2 (and "different" URI) and with the new v3 (all with the "standard" search.pl
).
The new API v3 to add/edit packaging components is almost finalized and implemented (but deployed only on the .dev server currently).
Server-side PR with the documentation and implementation: https://github.com/openfoodfacts/openfoodfacts-server/pull/7614
There could still be minor changes (in particular, it is likely that we will use PATCH requests instead of POST requests). I will update this bug when it is merged, deployed on .net and then on .org If you have feedback about the API, please let me know, we can still change things if needed.
Note that future v3 APIs will use the same model for reporting warnings and errors etc. so it would be good to have generic code for it. In particular, the API v3 for product READ is already implemented as well (with full v2 features support).
The API v3 product WRITE currently only supports packaging data, so we will need to keep the existing code for API v2 for some time.