Questions tagged [wikipedia-api]

Related to the use of the MediaWiki API on Wikipedia. Consider also the tags [wikipedia] if your question isn't about the API or [mediawiki-api] if your question isn't about Wikipedia.

Documentation for the API is available at mediawiki.org; a summary of all available parameters and short help is available by accessing the API endpoint on the wiki.

In addition, there is a REST API that allows fetching commonly used data in a simple format. A list of all endpoints can be found in the REST API Documentation.

Please make sure to read the etiquette for best practices for using the API and general usage guidelines.

1085 questions
3
votes
1 answer

MediaWiki API - what are the differences between 'opensearch' & 'query', and 'generator' & 'list' in the API call url

I'm trying to work with the mediawiki API for a project on FreeCodeCamp. I've read through these pages on the API docs: OpenSearch Generators Lists Query And it's still not clear what the real differences are, and when and why I'd need to use…
firefiber
  • 155
  • 1
  • 2
  • 10
3
votes
3 answers

How to parse Wikipedia XML with PHP?

How to parse Wikipedia XML with PHP? I tried it with simplepie, but I got nothing. Here is a link which I want to get its…
yuli chika
  • 9,053
  • 20
  • 75
  • 122
3
votes
1 answer

Is there a Wikipedia API which allows you to search and load articles?

Possible Duplicate: Is there a Wikipedia API? Is there a Wikipedia API which will allow me to search Wikipedia and load the the article? And are there any examples of using it in C#?
Jason Quinn
  • 2,443
  • 3
  • 28
  • 36
3
votes
3 answers

How to bind to a json key if it always gets returned with a different/random name?

I am busy with a angular 4.x app where I am trying to display a random wikipedia article. The JSON I see in chrome dev tools under query/pages alwasys has a different nubered pageID. Instead of returning pages as an array they return it as a JSON…
user2094257
  • 1,645
  • 4
  • 26
  • 53
3
votes
1 answer

How to download a Wikipedia image for a species page

I routinely want images of organisms to complement datasets and it would be great if I could pull out a species image for, say a bottlenose dolphin, given the Genus and species. I would then use this image in a K12 educational Shiny App similar to…
mattador
  • 421
  • 4
  • 12
3
votes
3 answers

Json first object is a *, how to get it?

If I run: $("#results ul").append(data.parse.langlinks.map(function(val){ return "
  • " + val.lang + "
  • " })); I get all correct values of lang but I need to get the first object and it doesn't have a verbal naming but it has * So when I try…
    rob.m
    • 9,843
    • 19
    • 73
    • 162
    3
    votes
    2 answers

    How can I search wikidata based on an external identifier such as a Spotify ID?

    If I know that Kanye West's Spotify ID is 5K4W6rqBFWDnAN6FQUkS6x, what is the easiest way to resolve that identifier to his Wikidata page, which is https://www.wikidata.org/wiki/Q15935 ? Do I need to do this with a SPARQL query or is there a way to…
    Simon Willison
    • 15,642
    • 5
    • 36
    • 44
    3
    votes
    1 answer

    Does the wikipedia API give structured information on the infobox?

    I am aware of the following solutions: The wikipedia infobox can be returned as HTML or in the "wikitext" model. However, in both cases, I'd need to parse the data after, which is highly error-prone. Use DBpedia or Wikidata. Unfortunately, these…
    T. M.
    • 58
    • 1
    • 6
    3
    votes
    2 answers

    Making a tree of Wikipedia links

    I am trying to use the Wikipedia API to get all links on all pages. Currently I'm using https://en.wikipedia.org/w/api.php?format=json&action=query&generator=alllinks&prop=links&pllimit=max&plnamespace=0 but this does not seem to start at the first…
    dangee1705
    • 3,445
    • 1
    • 21
    • 40
    3
    votes
    3 answers

    Access-Control-Allow-Origin with Wikipedia API with Javascript

    Trying to receive a response from the Wikipedia API on Codepen. The reply should be a json which i'm trying to console.log. In the console however I see an error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote…
    ErezBerez
    • 131
    • 1
    • 8
    3
    votes
    2 answers

    How to retrieve history version of Wikipedia article by given date?

    Is there a way to use MediaWiki API or any other tool to automatically retrieve a previous version of a Wikipedia article using an approximate date (without knowing the 'oldid' value)? For example how can I retrieve the history version of Stack…
    godidier
    • 923
    • 16
    • 34
    3
    votes
    3 answers

    PHP foreach loop returns an extra unwanted array (Wikipedia API)

    I've been researching this all day and haven't found any solutions. I'm also very new to php. The purpose of my function is to take user input (Category1) of a Wikipedia article and return its categories. The basic function below does this without…
    Sabaghian
    • 33
    • 3
    3
    votes
    2 answers

    What do the parameters in Wikipedia API response mean?

    When calling the Wikipedia API, what do the keys in the links objects mean? I'm guessing ns stands for namespace, but why is it an integer? Why is exists empty for every object? Why is what appears to be the page name title key called *? For…
    kal
    • 160
    • 8
    3
    votes
    1 answer

    Getting a list of all URLs redirecting to a Wikipedia page?

    I need to know all the different URLs that lead to the same end Wikipedia article URL for a project I'm doing. For example: https://en.wikipedia.org/wiki/Lucite redirects to the final…
    EazyC
    • 809
    • 1
    • 10
    • 30
    3
    votes
    0 answers

    Wikipedia API search by relevancy

    When I fire a POST/GET request with the following parameters, the API returns search result sorted by relevancy array( 'format' => 'json', 'action' => 'query', 'list' => 'search', 'srsearch' => $query ); example GET…
    Lord Stiltskin
    • 133
    • 1
    • 8