Page MenuHomePhabricator

Image Suggestions API: Support querying by title
Closed, ResolvedPublic

Description

Currently, the API supports querying by page ID: https://image-suggestion-api.wmcloud.org/?doc#/Image%20Suggestions/get_image_suggestions_v0__wiki___lang__pages

That works fine for production, but for local development it is not ideal, because if you want to retrieve a suggestion for an article in your local wiki, the local wiki page ID is unlikely to match the production wiki page ID.

For that reason, it would be nice to offer an option for querying by title(s). I don't know if this is already stored in the database, but you could call the Pages API https://api.wikimedia.org/wiki/API_reference/Core/Pages/Get_page with the title to get the ID. Note that the URL should use an environment variable for expansion, because in Kubernetes you wouldn't be able to make an HTTP request to api.wikimedia.org directly, it would have to go through a proxy. T276217: Use Envoy for making GET requests to lang.wikipedia.org/api.php is how we did this for research/mwaddlink, fwiw.

Event Timeline

kostajh added a subscriber: sdkim.

@sdkim is this something your team might be able to work on soon? If not, we might submit a patch because this would help us a lot for QA/testing in beta and in local development environments.

@kostajh This most likely not going to be able to get scoped in the near term. I would say definitely go ahead and submit the patch and ensure to ping PET in the #image-suggestion slack to notify.

cc: @BPirkle @nnikkhoui

Tgr subscribed.

Titles seem to be stored in the database so this seems easy enough.

Tgr renamed this task from Support querying by title to Image Suggestions API: Support querying by title.Oct 19 2021, 8:58 AM
Tgr claimed this task.
Tgr triaged this task as High priority.

Change 732262 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/vagrant@master] Add addimage role

https://gerrit.wikimedia.org/r/732262

Change 732471 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/services/image-suggestion-api@master] Add /:wiki/:lang/pages/:title path

https://gerrit.wikimedia.org/r/732471

Change 732477 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/extensions/GrowthExperiments@master] Add Image: Use title-based API endpoint

https://gerrit.wikimedia.org/r/732477

Change 732471 merged by jenkins-bot:

[mediawiki/services/image-suggestion-api@master] Add /:wiki/:lang/pages/:title path

https://gerrit.wikimedia.org/r/732471

Thanks for the review, @nnikkhoui and @BPirkle! Could you ping us once the patch has been deployed?

Change 732477 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Add Image: Use title-based API endpoint

https://gerrit.wikimedia.org/r/732477

Change 736314 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[operations/mediawiki-config@master] Use page id for GrowthExperiments image recommendations

https://gerrit.wikimedia.org/r/736314

Change 736314 merged by jenkins-bot:

[operations/mediawiki-config@master] Use page id for GrowthExperiments image recommendations

https://gerrit.wikimedia.org/r/736314

Change 736317 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[operations/mediawiki-config@master] Use title for GrowthExperiments image recommendations on testwiki

https://gerrit.wikimedia.org/r/736317

Change 736317 merged by jenkins-bot:

[operations/mediawiki-config@master] Use title for GrowthExperiments image recommendations on testwiki

https://gerrit.wikimedia.org/r/736317

Mentioned in SAL (#wikimedia-operations) [2021-11-02T23:45:50Z] <tgr@deploy1002> Synchronized wmf-config: Config: Use page id for GrowthExperiments image recommendations, except for testwiki ([[gerrit:736314|736314]] [[gerrit:736317|736317]] (T290949 T292154) (duration: 01m 03s)

Change 732262 merged by jenkins-bot:

[mediawiki/vagrant@master] Add addimage role

https://gerrit.wikimedia.org/r/732262