User:Husky/cheatsheet

A beginner's cheatsheetEdit

Common propertiesEdit

ToolsEdit

  • Wikidata Query Service - Query Wikidata using SPARQL
    • Use CTRL-Space for suggestions on items, properties, etc.
  • Property browser - Search all available properties
    • If you can't find a property, try looking up a well-known item. For example, if you want to find all properties applicable for paintings look up the Mona Lisa (Q12418).
  • VizQuery - Write a query without needing SPARQL
  • QuickStatements - Batch edit Wikidata using a spreadsheet-like format
  • Tools Directory - Find more Wikidata-related tools

SPARQLEdit

Find all instances of an item, and also all subclassed items? (e.g. all pets, including cats and dogs)

?item wdt:P31/wdt:P279* wd:Q39201.

Optional properties

optional { ?item wdt:P18 ?image. } # Add image if available

Remove all items that don't have certain property

minus { ?item wdt:P18 ?image } # Only show items with an image

Do an 'OR' query, find all items that have one of several values

?cat wdt:P31 ?instance. # Get the instance of subject
values ?instance { wd:Q146 wd:Q144 } # And display either cats or dogs

If there are multiple statements and you only want one

select (sample(?image) as ?image) where...
select (min(?year) as ?year) where...</code.