Page MenuHomePhabricator

Commons API call to get Structured data for image file
Closed, DeclinedPublic

Description

This allows us to get the following data from the Commons file name :

  • Depicts statements (list of Wikidata IDs only, labels are found after in T222495)
  • Captions in all entered languages

Parameters for call to https://commons.wikimedia.org/w/api.php

actionwbgetentities
titles[filename]
sitescommonswiki

example: https://commons.wikimedia.org/w/api.php?action=wbgetentities&titles=File:DIWALI_A_FESTIVAL_OF_LIGHTS.jpg&sites=commonswiki

result = response.entities[mediaIdentifer]  //only property in response.query.pages

depictsStatements = result.statements.P180  //array of 'depicts' statements

Each element in the array is an object representing a single depicts statement. The Wikidata item for each statement is found with:

depictsStatement.datavalue.value.id

Event Timeline

NavinoEvans renamed this task from API call to get Structured data for image file to Commons API call to get Structured data for image file.May 3 2019, 11:18 PM
NavinoEvans moved this task from In progress to Backlog on the ISA board.
NavinoEvans moved this task from Backlog to In progress on the ISA board.

Change 508510 had a related patch set uploaded (by Eugene233; owner: Eugene233):
[labs/tools/Isa@master] Commons API call to get Structured data for image file

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

Change 508510 abandoned by Eugene233:
Commons API call to get Structured data for image file

Reason:
in favor of 508813

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