Wikipedia API + Cross-origin requests

I had the same problem while working on a freeCodeCamp project and the solution was so simple it made me laugh, since I had spent hours searching for it. In your jQuery URL include the parameter below. &origin=* Working CodePen $.getJSON( ‘https://en.wikipedia.org/w/api.php?action=query&format=json&gsrlimit=15&generator=search’ + ‘&origin=*’ + // <– this is the magic ingredient! ‘&gsrsearch=”q, function(data){ /* … Read more

How can I get the Infobox from a Wikipedia article by the MediaWiki API? [duplicate]

You can do it with a URL call to the Wikipedia API like this: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xmlfm&titles=Scary%20Monsters%20and%20Nice%20Sprites&rvsection=0 Replace the titles= section with your page title, and format=xmlfm to format=json if you want the article in JSON format.

How to obtain a list of titles of all Wikipedia articles

The allpages API module allows you to do just that. Its limit (when you set aplimit=max) is 500, so to query all 4.5M articles, you would need about 9000 requests. But a dump is a better choice, because there are many different dumps, including all-titles-in-ns0 which, as its name suggests, contains exactly what you want … Read more

Searching Wikipedia using the API

I don’t think you can do both in one query. 1. To get the first result, use the Opensearch API. https://en.wikipedia.org/w/api.php?action=opensearch&search=zyz&limit=1&namespace=0&format=jsonfm https://en.wikipedia.org/w/api.php ?action=opensearch &search=zyz # Search query &limit=1 # Return only the first result &namespace=0 # Search only articles, ignoring Talk, Mediawiki, etc. &format=json # ‘jsonfm’ prints the JSON in HTML for debugging. This will … Read more

How to use wikipedia api if it exists? [closed]

You really really need to spend some time reading the documentation, as this took me a moment to look and click on the link to fix it. :/ but out of sympathy i’ll provide you a link that maybe you can learn to use. http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=timestamp|user|comment|content That’s the variabled you will be looking to get. Your … Read more

How can I get Wikipedia content using Wikipedia’s API?

See this section in the MediaWiki API documentation, specifically involving getting the contents of the page. use the sandbox to test the API call. These are the key parameters. prop=revisions&rvprop=content&rvsection=0 rvsection = 0 specifies to only return the lead section. See this example. http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&titles=pizza To get the HTML, you can use similarly use action=parse http://en.wikipedia.org/w/api.php?action=parse&section=0&prop=text&page=pizza … Read more