Thanks, Dmitry. That works like a charm.

Adrian Tineo


Am 10/08/16 um 22:12 schrieb Dmitry Brant:
"pageprops" is what you seek:

https://en.wikipedia.org//w/api.php?action=query&format=json&prop=pageprops&titles=Albert_Einstein



On Wed, Aug 10, 2016 at 4:06 PM, Adrian Tineo <adr...@adriantineo.com <mailto:adr...@adriantineo.com>> wrote:

    Hi all

    This is my first post in this list. I'm not clear if this is the
    best place for me to ask this question, so feel free to recommend
    some other contact point.

    Context:

    I am trying to find out via API what is the Wikidata item from a
    Wikipedia page. This is visible in the Tools side bar in the
    Wikipedia page but I can't figure out how to get this information
    from the API.

    Question:

    How can I get via API the Wikidata item matching a given Wikipedia
    article?

    Example:

    Say that the starting point is Albert Einstein's page in the
    English Wikipedia (https://en.wikipedia.org/wiki/Albert_Einstein
    <https://en.wikipedia.org/wiki/Albert_Einstein>). I can get the
    page content via API like so:

    https://en.wikipedia.org/w/api.php?action=query&format=json&titles=Albert
    <https://en.wikipedia.org/w/api.php?action=query&format=json&titles=Albert>
    Einstein&prop=revisions&rvprop=content

    I can get plenty of other info by using some other params to the
    query action. Some I have tried include:

        prop:extlinks, prop:info, meta:filerepoinfo, etc.

    None of these contain the Wikidata item matching the article
    though. I couldn't find out anything about it in the MediaWiki API
    help.

    As of now, the best I can do is:

    1. Query Wikidata with the page title like so:

    
https://www.wikidata.org/w/api.php?format=json&action=wbsearchentities&search=Albert
    
<https://www.wikidata.org/w/api.php?format=json&action=wbsearchentities&search=Albert>
    Einstein&language=en

    2. Browse through the output for the desired Albert Einstein entry
    among:

      * Q937, Albert Einstein, German-American physicist and founder
        of the theory of relativity
      * Q13426745, Albert Einstein, Studio album by Prodigy and The
        Alchemist
      * Q15990626, Albert Einstein, Wikimedia disambiguation page
      * 3 more entries

    This adds a complication, as I need the intelligence to tell which
    is the Wikidata item I was looking for, whereas in the Wikipedia
    page in the browser I can access the item (Q937) directly.

    Any help much appreciated.

    Regards,

    Adrian Tineo



    _______________________________________________
    Mediawiki-api mailing list
    Mediawiki-api@lists.wikimedia.org
    <mailto:Mediawiki-api@lists.wikimedia.org>
    https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
    <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api>




--
Dmitry Brant
Senior Software Engineer / Product Owner (Android)
Wikimedia Foundation
https://www.mediawiki.org/wiki/Wikimedia_mobile_engineering



_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Reply via email to