Help:QuickStatements
Other languages:
Bahasa Indonesia Bahasa MelayuDeutsch English dansk españolfrançais italiano magyar polskiportuguês do Brasil română svenskaбеларуская (тарашкевіца) русскийукраїнська հայերեն العربية বাংলাதமிழ் മലയാളം 中文 日本語 粵語
Icon used on Commons by templates that upload to Wikidata using QuickStatements
QuickStatements
2019 Coolest Tool Award Winner
in the category
Editor
QuickStatements (QS) is a tool, written by Magnus Manske, that can edit Wikidata items, based on a simple set of text commands. The tool can add and remove statements, labels, descriptions, and aliases; as well as add statements with optional qualifiers and sources. The command sequence can be typed in the import window or created in a spreadsheet, text editor and pasted in. It can also be created by external code like Lua called from a template and passed as URL. Data edited in OpenRefine can also be exported to QuickStatements format.
The tools
QuickStatements tool went through several iterations and rewrites. You should always use the current version of this tool whenever possible. There are several QuickStatements versions available:
Syntax between versions can vary slightly. The rest of the document will describe the syntax of the current version, but will mark parts which were not supported in the earlier versions.
Command sequence syntax
This section describes syntax used since V1 version of the tool sometimes referred to as V1 commands[1].
Add simple statement
You can specify the statements to add by typing/pasting into the tool's text area. Different parts of the statement are separated by a TAB or "|"[2] characters. Each command is in a new line, or separated by "||"[2] characters. Hint: You can also use a spreadsheet software such as Microsoft Excel or LibreOffice Calc; copying/pasting the cells should automatically insert TABs. Also text editors like Notepad++ allow replacement of any symbol by TAB character (\t).
Each statement must consist of an entity, a property, and a value. An entity can be an item, a property, a lexeme[2], a form[2], or a sense[2].A value can be another entity, a string, a time, a location, or a quantity, depending on the property type, or one of the special values somevalue or novalue (see Unknown or no values).
Formatting of each part:

Add statement with qualifiers
Each statement "triplet" can be followed by an unlimited number of "qualifiers pairs" of propertyTAB value.
Example: Q41577083 TAB P570 TAB​+1600-00-00T00:00:00Z/7 TAB P1319 TAB​+1586-00-00T00:00:00Z/9
Meaning: add to
Gian Federigo Bonzagna (Q41577083)
date of death (P570)
16. century
/ earliest date (P1319)
+1586
Add statement with sources
Each statement can be followed by an unlimited number of "source pairs" to add references of source property TAB value. The source property is identical to the "normal" property, except it uses the form Sxx instead of Pxx.
Example: Q22124656 TAB P21 TABQ6581097 TAB S143 TAB Q24731821TAB S813 TAB +2017-10-04T00:00:00Z/11
Meaning: add to
Gotô Ichijô (Q22124656)
sex or gender (P21)
male (Q6581097)
with reference
imported from Wikimedia project (P143)
Commons Creator page (Q24731821)
/ retrieved (P813)
4 October 2017
Notes:

Adding labels, aliases, descriptions and sitelinks
As with adding simple text statements, each command must consist of an item, a command, and a string in double quotes.
If you want to remove a label/description/sitelink, the value has to be an empty string and the rest of the command will be the same.
Item creation
Please ensure you do not create duplicate items!
You can create new items by inserting a line consisting only of the word "CREATE". To add statements to the newly created item, use the word "LAST" instead of the Q number, and the statement will be added to the last created item.
An example for creating a new item, adding a sitelink, and setting a label:
CREATE
LAST TAB Sfrwiki TAB "Le croissant magnifique!"
LAST TAB Lfr TAB "Le croissant magnifique!"
Meaning: create a new item with a link to French Wikipedia w:fr:Le croissant magnifique! and with French label "Le croissant magnifique!"
Item merging
You can merge two items. The first item will be merged and (if successful) redirected into the second item.
MERGE TAB Qsource TAB Qdestination
Removing statements
You can remove specific statements by prefixing a line with "-"[2].
Example: -Q4115189 TAB P31 TAB Q1
Meaning: remove from
Wikidata Sandbox (Q4115189)
instance of (P31)
Universe (Q1)
Dates with precision>9 can be removed via their specific date:
-Q98426308 P585 +1988-05-11T00:00:00Z/11
Dates with precision≤9 may use either 00-00 or 01-01 as their month-date value, so may be necessary to attempt to remove both:
-Q98426308 P585 +1988-01-01T00:00:00Z/9 -Q98426308 P585 +1988-00-00T00:00:00Z/9
In addition you may remove statements with a specific statement ID using the following syntax:
-STATEMENT TAB Q1$00000000-0000-0000-0000-000000000000
The statement ID can be received by:
Comments
Every command can have a comment at its end, which will be inserted into the edit summary for the command[2]. Use the /* ... */ syntax. Before this a TAB may be inserted. Spaces around the comment will be removed before processing. The tool splits adding of a claim and its reference in two edits. When using the "version 1 format" import it seems not to be possible to add a comment for the edit adding the reference. The comment is added to the edit adding the claim (if the claim does not exist yet and is added at all).
Example: Q4115189 TAB P31 TAB Q1 /* This is a comment. */
Meaning: add to
Wikidata Sandbox (Q4115189)
instance of (P31)
Universe (Q1)
, with "This is a comment." in the edit summary.
CSV file syntax
Commands
In QuickStatements version 2, one can also cut and paste a properly structured CSV file as an alternative to the syntax introduced in QuickStatements version 1. The CSV file will specify commands to execute. The first row is a header describing how the columns are interpreted.
qid
Always the first column: the item or entity to edit. If left empty, a new item will be created. See item creation sample below.
The other columns may specify the following commands:
P1234
A property ID (uppercase) begins a new statement. The column value specifies the main value of the statement, in QuickStatements version 1 syntax.
qal1234
A lowercase "qal" followed by a property number (without "P") adds a qualifier to the current statement. The column value specifies the value of the qualifier, in QuickStatements version 1 syntax. There must be some "P" column before a "qal" column to specify which statement the qualifier is added to.
S1234
An uppercase "S" followed by a property number (without "P") begins a new source for the current statement. The column value specifies the value of the source, in QuickStatements version 1 syntax. There must be some "P" column before an "S" column to specify which statement the source is added to.
s1234
A lowercase "s" followed by a property number (without "P") adds another property-value pair to the current source. The column value specifies the value of the source, in QuickStatements version 1 syntax. There must be some "S" column before an "s" column to specify which source the property-value pair is added to.
Len
An uppercase "L" followed by a language code sets the label in that language.
Dfr
An uppercase "D" followed by a language code sets the description in that language.
Ade
An uppercase "A" followed by a language code adds an alias in that language.
Senwiki
An uppercase "S" followed by a site ID adds a sitelink to that site.
#
A number sign character sets the edit summary (comment) of the preceding command. The tool splits adding of a claim and its reference in two edits. A comment can be added to the edit summary of each of them. For the claim by putting a "#" column between the columns for the claim and its reference, for the reference by putting a "#" column behind its columns. For example:
qid,P21,#,S143,s813,# Q22124656,Q6581097,comment to claim adding edit,Q24731821,+2017-10-04T00:00:00Z/11,comment to reference adding edit
Item creation
To create a new item, the first element of the row needs to be empty, so the line starts with a ,.
For example
qid,Len,Den,P31 ,Regina Phalange,fictional character,Q5

For example
creates a new item. Suitable for LibreOffice (paste in cell A1)
filenamelabeldescriptionqid,P31,Len,Den,P18
Mona Lisa - the Louvre.jpgMona Lisaoil painting by Leonardo da Vinci=",Q3305213,"""&B2&""","""&C2&""","""""""&A2&""""""""
Mona Lisa - the Louvre.jpgMona Lisaoil painting by Leonardo da Vinci,Q3305213,"Mona Lisa","oil painting by Leonardo da Vinci","""Mona Lisa - the Louvre.jpg"""
Statement removal commands
Statement column headers may also begin with - to remove the statement. (Note that this is only valid in the header for the whole column, not in individual values.) Removing other column types is not yet supported and will result in an error when the command is run; however, sitelinks and labels can be removed by setting them to the empty string (without - in the column header).
qid,P31,-P31
Q4115189,Q5,Q5
Adds to the sandbox item a P31 value of human (Q5) and then removes that same statement again.
Commas and double-quotes
Labels, descriptions, aliases and sitelinks do not need to be in double quotes unless they itself contain commas (,) or double quotes (").
In this case, replace all double quotes with two double quotes (e.g. Toys "R" UsToys ""R"" Us) and then wrap the string in a pair of double quotes (e.g. "Toys ""R"" Us").
Samples: Toys "R" Us and Patterns, Predictors, and Outcome
qid,Len
Q4115189,"Toys ""R"" Us"
Q4115189,"Patterns, Predictors, and Outcome"
To add a string value containing double quotes ("), replace all double quotes with two double quotes ("").
As any string value, then wrap it into three double quotes ("""), e.g. """Toys ""R"" Us""".
Samples for Q4115189#P370, notably Toys "R" Us
qid,P370
Q4115189,"""Toys ""R"" Us"""
Q4115189,"""Patterns, Predictors, and Outcome"""
Q4115189,"""Wikidata sandbox item 1"""
Combined sample
qid,Len,Den,Aen,P31,-P31,P21,P735,qal1545,S248,s214,S143,Senwiki
Q4115189,Douglas Adams,author,Douglas Noël Adams,Q5,Q36180,Q6581097,Q463035,"""1""",Q54919,"""113230702""",Q328,Douglas Adams
Q4115189,"Toys ""R"" Us",testin sample,Toys R Us,Q5,Q36180,Q6581097,Q463035,"""1""",Q54919,"""113230702""",Q328,"Toys ""R"" Us"
Samples by value type
Samples use the sandbox item (Q4115189) and can be pasted directly into Quickstatements for testing. Should be risk-free.
Label
qid,Len
Q4115189,Sandbox
Q4115189,"Patterns, Predictors, and Outcome"
Q4115189,"Toys ""R"" Us"
Description
qid,Den
Q4115189,Wikidata item for tests
Q4115189,"sample for Patterns, Predictors, and Outcome"
Q4115189,"description sample for Toys ""R"" Us"
Alias
qid,Aen
Q4115189,Wikidata sandbox
Q4115189,"Predictors, Patterns, and Outcome"
Q4115189,"Toys ""4"" You"
Item
qid,P369
Q4115189,Q5
Q4115189,somevalue
Q4115189,novalue
L123,Q5
L123-S1,Q5
L123-F1,Q5
somevalue is for unknown value Help, novalue for no value Help. F1 and S1 on Lexeme:L123 would have to exist for it to work.
String or external-id
qid,P370
Q4115189,"""Sandbox"""
Q4115189,"""Patterns, Predictors, and Outcome"""
Q4115189,"""Toys ""R"" Us"""
Monolingual text
qid,P1450
Q4115189,en:"Sandbox"
Q4115189,en:"Toys "R" Us"
Q4115189,"en:""Toys ""R"" Us"""
Q4115189,"en:""Patterns, Predictors, and Outcome"""
en is for English
Date/time
qid,P577
Q4115189,+1856-01-01T00:00:00Z/9
Q4115189,+1856-01-01T00:00:00Z/10
Q4115189,+1856-01-01T00:00:00Z/11
Precisions are 9=year, 10=month, 11=day, so the dates are 1856, January 1856 and 1 January 1856.
Image/Commons media file
qid,P18
Q4115189,"""Frans Breydel - A merry company.jpg"""
Q4115189,"""'Girl Reading' by Mary Colman Wheeler, El Paso Museum of Art.JPG"""
Q4115189,"""Kaubalaeva ""E. Russ"" vrakk.jpg"""
Q4115189,"""''L'empereur Napoleon III'' de Franz-Xaver Winterhalter.jpg"""
Images are:
URL
qid,P856
Q4115189,"""https://example.com/"""
Q4115189,"""https://example.com/equalsign=test"""
Q4115189,"""https://example.com/underscore_test"""
Quantity
qid,P1114
Q4115189,10
Q4115189,+20
Q4115189,+3.1415926
Q4115189,-40
Q4115189,5.5U11574
Q4115189,+60U11573
Q4115189,+7.5U11574
Q4115189,-80~1.5
Q4115189,2.2~0.3
Q4115189,+1.2~0.3
U11573 is for metre (Q11573), U11574 for second (Q11574). Note the odd result of 1.2~0.3.
Full example
Full examples can be found at Help:QuickStatements/examples​.
Running QuickStatements
Using QuickStatements version 2
QuickStatements V2 intro screen
Here is how to use QuickStatements (version 2) in basic mode:
  1. Go to https://quickstatements.toolforge.org
  2. Make sure you are logged in OAuth and your name is visible in the upper right corner. If not then log in.
  3. Click "New batch".
  4. For working with Wikimedia Commons Structured Data:
    1. Look for the pull-down menu Create new command batch for ... and change project from Wikidata to Commons [Batch mode only!]
    2. You need "M" ids to work on instead of "Q" numbers. Look up the media identifiers for Commons files with the Minefield tool
    3. Use statements in the form of "MXXXX|PXX|QXXX" or use the CSV format option
    4. Initiate the query with the "Run" or "Run in the background" button to run it in the batch mode
  5. Cut and paste your commands. See the syntax in the section above.
  6. When you are done, click "Import V1 commands" or "Import CSV commands".
  7. The tool will convert your commands into human-readable form. Inspect them and click "Run" or "Run in the background" to execute
  8. As your commands are being processed, double-check the results, and press "STOP" if you detect a problem.
  9. The user interface will tell you when all commands have been processed.
Using QuickStatements version 1
Screenshot of using QuickStatements version 1
QuickStatements version 1 is still available, but no longer maintained. It stopped working for some users, while still working fine for others.
  1. Go to https://wikidata-todo.toolforge.org/quick_statements.php
  2. Cut and paste your commands into the window
  3. Click "Do it"
  4. The user interface will tell you when all statements have been processed.
Using QuickStatements version 2 in batch mode
Warning: As of May 2020 duplicated items may be created in batch mode. Please make sure you can find and merge them! This does not affect frontend mode.
When to use batch mode?
QuickStatements version 2 has "Run in background" button
Batch mode (also known as running in the background or asynchronous batch mode) means your statements are executed from a Wikimedia server, rather than from your Web browser. This has several advantages:
But there are also drawbacks:
Before running a batch, it can be a good idea to run a few commands directly in non-batch mode to get a good view of what is being done.
Using batch mode
  1. Prepare your statement normally as described in Using QuickStatements version 2 section above
  2. Instead of pressing "Run", press "Run in background" button.
  3. "Your last batches" will show a list of the most recent batches run by you, with statistics.
The following statistics values are available:
Running QuickStatements through URL
What you should see if you click on the example link in this section
An alternative way of communicating with QuickStatements is to use URL instead of cutting and pasting commands into import window. For example, a command to add to
Emile Justin Merlot (Q37887397)
VIAF ID (P214)
"96480189"
with source
imported from Wikimedia project (P143)
Wikimedia Commons (Q565)
is Q37887397TAB P214 TAB "96480189" TAB S143 TABQ565. You can also get prefilled QuickStatement window with https://quickstatements.toolforge.org/#/v1=​Q37887397​%7C​P214​%7C​%2296480189%22​%7C​S143​%7C​Q565 or https://quickstatements.toolforge.org/#/v1=Q37887397%7CP214%7C%2296480189%22%7CS143%7CQ565​. The steps of converting V1 syntax to URL are:
  1. replace TAB with "|" and newline with "||"
  2. apply URL encoding to the string, which will replace "|" with "%7C", double quote with "%22", space with "%20", slash "/" with "%2F", etc.[4]
  3. put https://quickstatements.toolforge.org/#/v1= in front of it
Many templates on Commons, like c:Template:Creator or c:Template:Artwork use that technique to package information that can be imported to Wikidata into a clickable URL.
Hints:

Limitations
QuickStatements version 2 currently cannot:
Note that for using QuickStatements an account needs to be autoconfirmed.
FAQ
Can QuickStatements add reference statements with more than one claim?
Yes, current QuickStatements can add references that have for example both imported from Wikimedia project (P143) and retrieved (P813) (see here) or both stated in (P248) and page(s) (P304).
How do I experiment with QuickStatements?
Use Wikidata Sandbox (Q4115189).
How do I report issues with the tool?
Check with other users at the talk page or at Wikidata:Project chat. Confirmed bugs should be reported on Phabricator after reading mw:How to report a bug.
Where do I suggest new features?
You can ask at tool's Bitbucket page or at User:Magnus Manske/quick statements2, but be aware that we keep Magnus busy!
What is the maximum number of commands I can enter at once?
Not documented. It was already tested with over 11,000 commands. But note that such large batch runs will take several hours to complete.
Best practices
Using the API to start batches
If you are logged in on QuickStatements, you can get a token on your user page. That page also contains information about how to use the token to submit batches programmatically. You need to have submitted at least one server-side batch manually before for this to work!
Edit groups
QuickStatements V2 creates edit groups for all individual batches. You may discuss individual edit groups, or rollback the whole edit group.
See also
References
  1. https://wikidata-todo.toolforge.org/quick_statements.php
  2. 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 syntax works only in QuickStatements version 2
  3. Note that due to the way computers operate with floating-point numbers the input format of version 2 may produce undesired results when working with decimal numbers.
  4. https://www.url-encode-decode.com/ is a handy URL encoder/decoder
Last edited on 15 November 2021, at 14:33
Wikidata
All structured data from the main, Property, Lexeme, and EntitySchema namespaces is available under the Creative Commons CC0 License; text in the other namespaces is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.
Privacy policy
Terms of Use
Desktop
HomeRandom Nearby Log in Settings DonateAbout WikidataDisclaimers
WatchEdit