Wikipedia image API search - contains total results + fileinfo
<p>We want to build an image search based on Wikipedia Commons image database. I've experimented with different request formats but there seems to be no solution which fits 100% our needs. </p>

<p>What we want to achieve:</p>

<ol>
<li>User search f.e. "Einstein"</li>
<li>We show them "808 results for Einstein found in Wikipedia"</li>
<li>Show them the first 10 results and allow a pagination</li>
</ol>

<p>I tried:</p>

<pre><code>https://commons.wikimedia.org/w/api.php?action=query&amp;list=search&amp;srsearch=%22Einstein%22&amp;srnamespace=6
</code></pre>

<p>which returns the totals results (1842)</p>

<pre><code>"query": {
    "searchinfo": {
        "totalhits": 1842
    },
</code></pre>

<p>and the results like:</p>

<pre><code>{
    "ns": 6,
    "title": "File:Albert Einstein Head.jpg",
    "snippet": "DescriptionAlbert &lt;span class=\"searchmatch\"&gt;Einstein&lt;/span&gt; Head.jpg  English: Albert &lt;span class=\"searchmatch\"&gt;Einstein&lt;/span&gt; Fran\u00e7ais\u00a0: Portrait d'Albert &lt;span class=\"searchmatch\"&gt;Einstein&lt;/span&gt;  Date Copyrighted 1947, copyright not renewed. &lt;span class=\"searchmatch\"&gt;Einstein&lt;/span&gt;'s estate",
    "size": 968,
    "wordcount": 0,
    "timestamp": "2016-01-01T01:57:15Z"
}
</code></pre>

<p>But this response is missing a downloadable URL. For example the one of "File:Albert Einstein Head.jpg" is <a href="https://upload.wikimedia.org/wikipedia/commons/d/d3/Albert_Einstein_Head.jpg" rel="nofollow">https://upload.wikimedia.org/wikipedia/commons/d/d3/Albert_Einstein_Head.jpg</a></p>

<p>I would need to set another request to get the correct URLs by:</p>

<pre><code>https://commons.wikimedia.org/w/api.php?action=query&amp;titles=File:Albert Einstein Head.jpg|File:Einstein hair advice.jpg|File:Einstein - potpis.jpg&amp;prop=imageinfo&amp;iiprop=url
</code></pre>

<p>Is there way to search for Wikipedia images which include their title, the URL to download and the total results (totalhits) in a single request?</p>