Hi to all.
I'm trying to do an exercise from FreeCodeCamp
(http://freecodecamp.com/challenges/zipline-build-a-wikipedia-viewer) and I'm
using, for now, this query (link to the API Sandbox):
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query=search=json=lepidoptera=0=snippet|titlesnippet=search=lepidoptera
I get something like this:
...
"query": {"pages": {"53307": {"pageid":
53307,"ns": 0,"title": "Lepidoptera",
"index": 1},"31500598": {
"pageid": 31500598,"ns": 0,"title": "List of
Lepidoptera of Metropolitan France","index": 2},
"8279262": {"pageid": 8279262,
"ns": 0,"title": "List of Lepidoptera that feed on Ipomoea",
"index": 10},...},...,
"search": [{"ns": 0,
"title": "Lepidoptera","snippet": "The Lepidoptera
(/\u02ccl\u025bp\u0268\u02c8d\u0252pt\u0259r\u0259/
lep-i-DOP-t\u0259r-\u0259) is an order of insects that includes moths and
butterflies (both called lepidopterans). 180,000 species",
"titlesnippet": "Lepidoptera"
},{"ns": 0,"title": "List of
Lepidoptera of Metropolitan France","snippet": "Lepidoptera of France consist of both the
butterflies and moths recorded from Metropolitan France. According to a
recent estimate, there are a total of","titlesnippet": "List
of Lepidoptera of Metropolitan France"
},{"ns": 0,"title":
"Macroglossinae (Lepidoptera)","snippet": "The Macroglossinae
are a sub-family of Sphingidae moths in the order Lepidoptera. The subfamily is divided into three
tribes: Dilophonotini, Macroglossini","titlesnippet":
"Macroglossinae (Lepidoptera)"
},...]
...
Well... My doubt is: what thing exactly refers to the «index» parameter in
«pages» objects? At first instance, I believed it was the index of the same
page in the «search» array of objects. That seems logic. But, when using
that, sometimes certain indexes simply don't match (they pair «pageid» from
one page with «titlesnippet», «snippet», etc from another page). So, I don't
know if that «index» parameter is, in fact, about some other thing or if,
instead, there is a bug/problem with the API in this matter. And, of course,
I know that array index order starts at 0. And already searched about this in
the wiki, and found nothing.
If anybody can enlighten me about this, I will be very grateful :). Thanks in
advance for reading me :).
And also my apologies in advance, just in case I commited some mistake here:
this is my first time writing to a mailing list.
___
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api