spencermountain / wtf_wikipedia

a pretty-committed wikipedia markup parser
https://observablehq.com/@spencermountain/wtf_wikipedia
MIT License
778 stars 129 forks source link

Additional Wikipedia Endpoints #278

Closed lawrencenull closed 5 years ago

lawrencenull commented 5 years ago

Just wanted to make the community aware of additional endpoints I discovered. Some of you may already be aware of them, some might not. I found them incredibility useful for my project with this library. Using Tove Lo as an example. Hope it is useful.

  1. Wiki Summary Endpoint- This is what Wikipedia uses to generate their info card popups. Contains the wikibase ID, Summary, Picture, etc.

url: https://en.wikipedia.org/api/rest_v1/page/summary/Tove_Lo

  1. Wiki Metadata Endpoint - Contains list of articles related to the entity and a section breakdown of the article's anchors (Early life, Career, etc), so no more guessing what sections are included in the wiki template. Also lists links to translations, etc.

url: https://en.wikipedia.org/api/rest_v1/page/metadata/Tove_Lo

spencermountain commented 5 years ago

yeah, that extract concept is a game-changer. Maybe we should add this stuff to the wiki, or something like that - feel free!

lawrencenull commented 5 years ago

I was using it to pull in extended wikidata info about an entity and build a summary, same thing Google and Bing do. Works with any entity once you have the wiki_base id.

Sorry for the Jquery.

https://output.jsbin.com/hucuqen

output: {"label":"Alias","value":"Ebba Tove Elsa Nilsson"}{"label":"label","value":"Swedish singer and songwriter"}{"label":"Name","value":"Tove Lo"}{"label":"place of birth","value":"Stockholm"}{"label":"sex or gender","value":"female"}{"label":"country of citizenship","value":"Sweden"}{"label":"instance of","value":"human"}{"label":"sexual orientation","value":"bisexuality"}{"label":"occupation","value":"singer"}{"label":"occupation","value":"lyricist"}{"label":"occupation","value":"composer"}{"label":"occupation","value":"songwriter"}{"label":"genre","value":"electropop"}{"label":"genre","value":"indie pop"}{"label":"genre","value":"pop music"}{"label":"genre","value":"synth-pop"}{"label":"ISNI","value":"0000 0004 3658 4183"}{"label":"VIAF ID","value":"310521186"}{"label":"GND ID","value":"1065690355"}{"label":"Library of Congress authority ID","value":"no2014103395"}{"label":"record label","value":"Universal Records"}{"label":"record label","value":"Universal Music Group"}{"label":"record label","value":"Island Records"}{"label":"BnF ID","value":"169460553"}{"label":"IMDb ID","value":"nm6241336"}{"label":"discography","value":"Tove Lo discography"}{"label":"Commons category","value":"Tove Lo"}{"label":"voice type","value":"soprano"}{"label":"MusicBrainz artist ID","value":"56756959-1e78-429c-b897-e1d056cb0225"}{"label":"date of birth","value":"1987-10-29T00:00:00Z"}{"label":"Freebase ID","value":"/m/0wt63mj"}{"label":"NKCR AUT ID","value":"xx0209398"}{"label":"family name","value":"Nilsson"}{"label":"given name","value":"Elsa"}{"label":"given name","value":"Tove"}{"label":"given name","value":"Ebba"}{"label":"location of formation","value":"Djursholm"}{"label":"topic's main category","value":"Category:Tove Lo"}{"label":"CONOR ID","value":"250217059"}{"label":"instrument","value":"piano"}{"label":"instrument","value":"voice"}{"label":"instrument","value":"percussion instrument"}{"label":"birth name","value":"Tove Ebba Elsa Nilsson"}{"label":"name in native language","value":"Tove Lo"}{"label":"AllMusic artist ID","value":"mn0003035440"}{"label":"GTAA ID","value":"256181"}{"label":"Spotify artist ID","value":"4NHQUGzhtTLFvgF5SZesLK"}{"label":"Discogs artist ID","value":"3506702"}{"label":"Twitter username","value":"ToveLo"}{"label":"Instagram username","value":"tovelo"}{"label":"Facebook ID","value":"tovelo"}{"label":"work period (start)","value":"2012-01-01T00:00:00Z"}{"label":"Genius artist ID","value":"Tove-lo"}{"label":"iTunes artist ID","value":"570136838"}{"label":"SoundCloud ID","value":"tovelo"}{"label":"Last.fm ID","value":"Tove+Lo"}{"label":"Songkick artist ID","value":"7561184"}{"label":"Dagens Nyheter topic ID","value":"tove-lo"}{"label":"Giphy username","value":"tovelo"}{"label":"Billboard artist ID","value":"tove-lo"}{"label":"on focus list of Wikimedia project","value":"Art+Feminism"}{"label":"Genius artist numeric ID","value":"127642"}

spencermountain commented 5 years ago

that sparql query is a thing of joy. What are you working on? I'd love this library to be more complimentary/consistent with the structured-data available from wikimedia. If you see anything it could do better, let me know.

Even a test-runner, comparing the outputs, probably would surface a bunch of good bugs.

lawrencenull commented 5 years ago

I'm building an assistant sort of thing, kind of like a smart speaker except more visual. I'm using your WTF and compromise libraries. Here is the complete function to get the wikidata ID from wiki summary thrown into an infobox kind of thing. I'm sure someone could clean up my javascript and make it more inline with the WTF library if anyone is interested. I use it for the ID's for additional services like musicbrainz, tmdb, etc.

https://output.jsbin.com/bulufef