Wikipedia Viewer - Correct API?

Wikipedia Viewer - Correct API?
0

#1

I’m currently using:

https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&titles=” + input + “&format=json” + “&origin=*”

My Codepen is: Wikipedia Viewer

I try to console.log the javascript object. I notice the one that Codepen displays is way less detailed than the one in Google Dev Tools. I try to drill down to the article in the Google Dev Tools and I can’t find it. Am I using the correct address for the API?

Thanks in advance!


#2

I’m closer. I think.

The only thing I can’t seem to get is the one line snippet from each entry:
var wikiapi = “https://en.wikipedia.org/w/api.php?action=query&list=search&srnamespace=0&srprop=timestamp&srsearch=intitle%3A” + input +"&format=json" + “&origin=*”


#3

I wish I could have figured it on my own, but I used someone’s (I wish I could remember so I could link it to their post):
https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=dogs&format=json&origin=* and I was able to get the snippet of the article. Now I gotta make it look a little prettier and then this viewer is finished…except for the random article requirement.