2

I want to use the Wikipedia API to select a famous person's name from the People category from my Javascript application. Basically, I would like to send the name or partial name and get results that contains the Wikipedia URL, title, an excerpt of the content and if possible the main picture.

I have been trying two ways, but I cannot make it work as I want.

First I have tried with search, but I cannot find the way of make it return the url. Would sectiontitle be good as unique identifier? Can snippet be plain text somehow? Cannot find how to filter by category.

Second, I have tried with opensearch, but the JSON response does not contain images, while the XML response does:

JSON: http://en.wikipedia.org/w/api.php?action=opensearch&search=mariano&namespace=0&format=json

XML: http://en.wikipedia.org/w/api.php?action=opensearch&search=mariano&namespace=0&format=xml

It is not possible to filter by category. Also, some results include a link to the disambiguation page, when I would prefer to get the list of possible matches rather than such link.

How could I search by title and get full title, url, small description and a picture link?

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
vtortola
  • 34,709
  • 29
  • 161
  • 263

1 Answers1

3

Opensearch is for input field autocompletion; it's based on an external spec and not very flexible. You should use the search API as a generator for some other API such as info which can return more details (example).

Tgr
  • 27,442
  • 12
  • 81
  • 118