WikiPedia Viewer: Getting snippet/extract consistently

WikiPedia Viewer: Getting snippet/extract consistently
0.0 0



I’m playing with the Wikipedia API (finding it really hard?) and struggling to get the image and extract/snippet from the results. I tried using list=search at first and I like the snippet this returns, but I decided I wanted to get a) images and b) the canonical URL, too. So I added extracts to my query too (as described here but it’s not behaving as expected. It is working in some cases but a lot of the results return ‘undefined’ for extract. I’m not getting as consistent results as I did using snippet from list=search.

Here’s my current work-in-progress (not nearly finished yet!): an example of undefined is if you search for ‘elizabeth’.

My params are in the genParams variable and when you run the code you can open the sandbox API using the “Open Sandbox” link.

I tried to use gsrprop snippet too but it doesn’t seem to make any difference. Very confused by the API in general to be honest…

Any help with getting more consistent snippets would be much appreciated…