The image is a bit advanced, I never tried that myself.
the wikipedia api sandbox is pretty confusing, (https://en.wikipedia.org/wiki/Special:ApiSandbox) but basically from that page, for your purposes, you want to do the following.
in Main in the dropdown menu for action you want to scroll to and select opensearch
below action you will find format you want this set to json
next in the lefthand column below main, go to action=opensearch
here you can type in an example search term under search, for example "REPLACE ME"
next, if you want you can go to limit in the same section, tick the box and set the max number of search results to return.
finally click the Make Request button up top, copy the field that says Request URL
your search url for your ajax will be “https://en.wikipedia.org” + the copied request url,
Don’t forget to replace “REPLACE+ME” with your actual search term.
There are a lot of other things the api can apparently do, but I don’t understand much beyond these terms.
I never implemented images on my project, but hypothetically I could help you with the pieces to figure it out.
I know that “https://en.wikipedia.org/w/api.php?action=query&format=json&prop=pageimages&titles=” +Wiki page’s Title here +"&piprop=original" will give you the main image for Some pages with images, but not all pages with images work.
You have to give it the title of the wikipedia page not a search term.
You would have to do this as an additional ajax request in a loop through each title after getting the titles from the 1st ajax request.
Hope that helps,