Commons:Structured data/Get involved/Finding data

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

This page brings together several ways and tools to find or search data available from files with Structured Data on Commons.

If you are looking for more options, there is also a list of tools to contribute data and make batch uploads to Structured Data on Commons. Another option is this list of tools in the Wikimedia ecoystem

How to search Structured Data on Commons

The Commons search bar allows Structured Data on Commons statements to be searched. It works both with the new Commons search, Media search, and with the previous search, Search.

This is possible by using the haswbstatement search, which allows to users to search for a specific information available on files with Structured Data on Commons.

Digital representation of[edit]

If you want to search for a file in which the digital representation of (P6243) is the painting The Kiss (Q698487), you should search for: haswbstatement:P6243=Q698487

Depicts and qualifiers[edit]

If you want to search a file that depicts (P180) flower (Q506), but specifically those with the yellow (Q943) color (P462), you should search for: haswbstatement:P180=Q506[P462=Q943]

Categories on Commons[edit]

There is also a way to search Structured Data on Commons statements in different Commons categories, using the search bar.

  1. Add "incategory:"
  2. Followed by the name of the category with underlines (_) between each space. Example: Images_from_the_Rijksdienst_voor_het_Cultureel_Erfgoed
  3. Add "haswbstatement:" and the property you wish to seach. Example: haswbstatement:P180

In the end, the search will show files from the Images from the Rijksdienst voor het Cultureel Erfgoed category using depicts (P180) statements and it should appear like this: incategory:Images_from_the_Rijksdienst_voor_het_Cultureel_Erfgoed haswbstatement:P180

Wikimedia Commons Query Service

The Wikimedia Commons Query Service is still a beta version and based on the Wikidata Query Service. It uses Wikibase and the Wikidata Query Help provides the documentation needed to use it, except for the M IDs, which are described below.

M-IDs[edit]

The only Commons specific part of the Wikimedia Commons Query Service are M-IDs, which are a unique identifier for each file on Wikimedia Commons. They are equivalent to Q IDs (or QIDs) on Wikidata.

Find M IDs[edit]

Individual files[edit]

To find M IDs for individual images, look at a file in the left hand menu and find the Concept URI option. Right click and copy link, this link contains the M ID. This number consists of a letter M, followed by a few numbers.

Multiple files[edit]

The PetScan tool can be used to find M IDs for all the files in a category on Wikimedia Commons. Find the name of the Commons category and chose the following options:

  1. Language = commons
  2. Project = wikimedia
  3. Categories = Name of the category (replacing spaces in the name with underlines _). Example: Files_from_the_Helsinki_City_Museum
  4. Combination = Intersection
  5. Go to the Page properties tab and under Namespaces select the file box.

In the results, Page ID is the M ID (the letter M must be added by the user). The results can be either copied manually or, under the Output tab, there is a range of options for export.

SPARQL examples[edit]

More Commons queries examples are available on this page.

Digital Representations of "David" by Michelangelo[edit]

Files with digital representation of (P6243) set to David (Q179900).

# Digital depictions of "David" by Michelangelo
#defaultView:ImageGrid
SELECT ?file ?image WHERE {
  ?file wdt:P6243 wd:Q179900 . 
  ?file schema:contentUrl ?url .
  # workaround to show the images in an image grid
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)
}

Try it!

Files with multiple "Digital Representations of" statements[edit]

digital representation of (P6243) statements has "single value constraint", or in other words each file can be a digital representation of only one Wikidata item, (use depicts (P180) if there are more objects in the image). The query below finds constraint violations.

SELECT ?file (COUNT(?value) AS ?count)  {
  ?file wdt:P6243 ?value .
} 
GROUP BY ?file 
HAVING ( ?count > 1 ) 
ORDER BY DESC(?count)
LIMIT 100

Try it!

Tools for findability

This table brings together tools that allow users to find or search Structured data on Commons statements.

Tool name / code repository Maintainer What it does Main category Tracked / issues Status
Tool name / code repository Maintainer What it does Main category Phab / issue  Not started yet

Handy links