Module:Wikidata/doc: Difference between revisions

Content deleted Content added
Methods: clarify documentation for when preferred values exist
Methods: Arbitrary Access
Line 20:
* <tt>ViewSomething</tt>: gets anything in the structured data, including labels, descriptions, references and interwiki links. See [https://en.wikipedia.org/w/index.php?title=Module_talk%3AWikidata&diff=652812891&oldid=650633541#Is_it_possible_to_get_value.28s.29_in_structured_tree_by_this_Module.3F]
* <tt>Dump</tt>: spies the structured data. It uses the same arguments as ViewSomething. Try this with preview only to see results. That helps you a lot in developing Lua scripts that access the data. If used without arguments, it dumps everything including labels, descriptions, references and interwiki links. See [https://en.wikipedia.org/w/index.php?title=Module_talk%3AWikidata&diff=652812891&oldid=650633541#Is_it_possible_to_get_value.28s.29_in_structured_tree_by_this_Module.3F]
 
=== Arbitrary Access ===
As of 16 September 2015, it is now possible to fetch data from other articles by using their QID.
The following call:
* <code><nowiki>{{#invoke:Wikidata|getValueFromID|<QID>|<Property>|FETCH_WIKIDATA}}</nowiki><code>
will do the same as getValue, but takes an extra parameter, which is the QID of the Wikidata item that you want to get the property value from.
For example:
* <code><nowiki>{{#invoke:Wikidata|getValueFromID|Q151973|P26|FETCH_WIKIDATA}}</nowiki><code>
will fetch a list of the linked values for 'spouse' (P26) from 'Richard Burton' (Q151973) from anywhere in the English Wikipedia.
 
This means that testing environments may be set up in user space, but please remember that these call are classed as ''expensive'', so please use them as sparingly as possible.
 
== Parameters ==