<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AResolveEntityId%2Fdoc</id>
	<title>Module:ResolveEntityId/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AResolveEntityId%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:ResolveEntityId/doc&amp;action=history"/>
	<updated>2026-04-17T13:05:48Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:ResolveEntityId/doc&amp;diff=144652&amp;oldid=prev</id>
		<title>imported&gt;Ahecht: /* Call from within a module (_id) */ fix</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:ResolveEntityId/doc&amp;diff=144652&amp;oldid=prev"/>
		<updated>2022-06-16T13:43:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Call from within a module (_id): &lt;/span&gt; fix&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating |beta}}&lt;br /&gt;
{{High-risk|~1200000}}&lt;br /&gt;
&amp;lt;!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --&amp;gt;&lt;br /&gt;
== Usage ==&lt;br /&gt;
Functions similarly to [[:mw:Extension:Wikibase_Client/Lua#mw.wikibase.resolvePropertyId|mw.wikibase.resolvePropertyId]], but for [[:wikidata:|Wikidata]] [[:mw:Extension:Wikibase_Client/Lua#mw.wikibase.entity|entities]] instead of properties.&lt;br /&gt;
&lt;br /&gt;
Returns an entity id for the given label or id. This allows using the entity&amp;#039;s labels instead of ids in all places. If no entity was found for the label or id, or if the label is ambiguous, a nil value is returned.&lt;br /&gt;
&lt;br /&gt;
When attempting to resolve a label, only entities with English Wikipedia sitelinks are considered in the search. If a label exists in Wikidata, but does not have the requisite language sitelink, a nil value is returned.&lt;br /&gt;
&lt;br /&gt;
=== Call from within a module (_id) ===&lt;br /&gt;
Example calls within a module might look like the following: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;text-align:left&amp;quot;|&lt;br /&gt;
!Code !! Result !! Notes&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;Q42&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|Q42|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;quot;Q42&amp;quot; is a valid Wikidata ID, and a Wikidata items exists with that Id, so it is therefore returned intact&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;Q0&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|Q0|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;quot;Q0&amp;quot; is not a valid Wikidata ID, and while the Wikipedia article [[Q0]] exists, it is a disambiguation page, so &amp;lt;code&amp;gt;&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is returned&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;Q404&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|Q404|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;quot;Q404&amp;quot; is a Wikidata redirect to Q395, so the latter is returned&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;Q2147483647&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|Q2147483647|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| Q2147483647 is a valid Wikidata ID, but no entity exists with that ID, so &amp;lt;code&amp;gt;&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is returned&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;Douglas Adams&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|Douglas Adams|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| The article [[Douglas Adams]] exists and has the Wikidata ID &amp;quot;Q42&amp;quot;, so that is returned.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;ThisIsNotARealWikidataItem&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;quot;ThisIsNotARealWikidataItem&amp;quot; is not a valid Wikidata ID, and no Wikipedia article exists at [[ThisIsNotARealWikidataItem]], so &amp;lt;code&amp;gt;&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is returned&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;ThisIsNotARealWikidataItem&amp;#039;, &amp;#039;Wikidata ID not found!&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|&amp;#039;Wikidata ID not found!&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above, but the custom error message &amp;lt;code&amp;gt;Wikidata ID not found!&amp;lt;/code&amp;gt; is returned&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;Douglas adams&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|Douglas adams|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;quot;Douglas adams&amp;quot; is not a valid Wikidata ID, and while [[Douglas adams]] (with a lower-case &amp;quot;a&amp;quot;) exists, it is a redirect to [[Douglas Adams]]. Therefore the Wikidata ID for the latter page is returned&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local resolveEntityId = require( &amp;quot;Module:ResolveEntityId&amp;quot; )._id&lt;br /&gt;
id = resolveEntityId(&amp;#039;Wikipedia:Village pump (technical)/Archive 1&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|style=&amp;quot;vertical-align: mid;&amp;quot;|&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;{{#invoke:ResolveEntityId|entityid|Wikipedia:Village pump (technical)/Archive 1|&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;quot;Wikipedia:Village pump (technical)/Archive 1&amp;quot; is not a valid Wikidata ID, and while [[Wikipedia:Village pump (technical)/Archive 1]] exists, it does not have a Wikidata ID, so &amp;lt;code&amp;gt;&amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is returned&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Use from within a template (entityid) ===&lt;br /&gt;
The following will return the entity id (or nothing if the ID doesn&amp;#039;t exist):&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#invoke:{{BASEPAGENAME}}|entityid|&amp;#039;&amp;#039;id&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following will return the entity id (or the alternate text if the ID doesn&amp;#039;t exist):&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#invoke:{{BASEPAGENAME}}|entityid|&amp;#039;&amp;#039;id&amp;#039;&amp;#039;|&amp;#039;&amp;#039;alternate text if &amp;#039;&amp;#039;id&amp;#039;&amp;#039; is &amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;}}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Former _entityid function===&lt;br /&gt;
The &amp;lt;code&amp;gt;_entityid&amp;lt;/code&amp;gt; function, which required that the frame be passed as the first argument, has been removed from the module because workarounds are no longer needed for [[:phab:T143970]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox | |&lt;br /&gt;
&amp;lt;!-- Categories below this line, please; interwikis at Wikidata --&amp;gt;&lt;br /&gt;
[[Category:Wikidata modules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Ahecht</name></author>
	</entry>
</feed>