Help with wikipedia viewer api

I am working on the wikipedia viewer and have been reading about wikipedia apis and how to query for pages.
What I wanted to do or what I had in mind was to search for the user entered keyword using the api and display a list of related pages.However I am confused between generators and lists and totally in the dark about searching for pages that might be related to a search term.the wiki api help is a little too…confusing? for me.
Any help is much appreciated.
I will continue digging in till I can find something relevant.

Yeah, even after you get good at APIs, they can be confusing. They are also all different and often poorly documented and can change without warning. Here is a pen I wrote to help someone with a similar problem. This is the relevant code:

$(document).ready(function() {
  var searchTerm = 'apple'
  var wikiUrl = '' +
      '?callback=?' +
      '&action=opensearch' +
      '&profile=fuzzy' +
      '&limit=10' +
      '&prop=fileinfo' +
      '&format=json' +
      '&search=' + searchTerm

    url: wikiUrl,
    dataType: 'json',
    success: function(response) {
      console.log('response', response);
    error: function(err) {
      console.log('Error:', err)

Let us know if you need something explained.

thank you Kevin.
I will try with your code.

Hi. I had difficulty doing the Wikipedia Viewer because of the API. I’ve gone through the documentation several times and kept on failing on my ajax(no return response) and saw this thread. Thanks for this but may I just know if there is an easier way to tell which data parameters I need so as to pass on the correct URL for the ajax for better success on APIs next time? Thanks.

It’s tough. Every API is different, many are poorly documented, and they can change without warning. I usually check the docs first, and then start doing some google searches to see if anyone has figured it out.

I just thought maybe there’s an easier way to spot these things. Thanks for the reply Kevin!