Page MenuHomePhabricator

Create API endpoint for search functionality
Closed, ResolvedPublic

Event Timeline

Community comment received on this idea here:

The webpage I mentioned before grepped out some Commons images from a wikipedia page as a proof of concept, so I could combine them with my own photographs and photographs from other relevant sites. What I'd want from an API is json or csv output with image name, description, date taken and lat/long and copyright information. If the requesting API could filter on those at the same time as wikidata Q number, that would be great. If there is a measure of image quality/how often its used, being about to chose the 10 "best" images would be useful. I could just about cope with a SPARQL query, but many users would want something simpler. Overall purpose, proving skins on wikidata/commons for a particular interest group Vicarage (talk) 17:15, 30 August 2022 (UTC)

When this task is resolved, should alert the user.

Dominicbm changed the task status from Open to In Progress.Sep 5 2022, 2:47 PM
Dominicbm moved this task from Backlog to In Progress on the View-it! board.

I have created a Node/Express API with basic functionality, allowing you to pull 20 images for a Q-number. I'll soon expand this to allow filtering, pagination, and additional metadata if it's available. Once complete, the frontend UI can start using it as well.

Example:
https://view-it.toolforge.org/api/Q2

returns:

{
  "total": 4840,
  "results": [
    {
      "image": "https://commons.wikimedia.org/wiki/File:Scandinavia.TMO2003050.jpg",
      "thumb": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Scandinavia.TMO2003050.jpg/320px-Scandinavia.TMO2003050.jpg",
      "title": "Scandinavia.TMO2003050.jpg",
      "width": 320,
      "height": 411
    },
    {
      "image": "https://commons.wikimedia.org/wiki/File:As08-16-2593.jpg",
      "thumb": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/As08-16-2593.jpg/320px-As08-16-2593.jpg",
      "title": "As08-16-2593.jpg",
      "width": 320,
      "height": 283
    },
    ...
  ]
}

API endpoint has been expanded with offsets and filters.

Query parameters:
offset: Number of images to offset by
assessment: featured, quality, or valued, based on assessment on Commons
property: Wikidata property to search by. Options are depicts (P180), main (P921), and creator (P170). If not specified, defaults to the custommatch:depicts_or_linked_from search.
resolution: small (<500 pixels), medium (500-1000 pixels), and large (>1000 pixels)

Dominicbm moved this task from In Progress to Done on the View-it! board.