wikipedia api notes

you can link to any wikipedia page by an id

https://en.wikipedia.org/?curid=23251407

random number in this range seems ok:

232562

https://en.wikipedia.org/?curid=232962

get random stuff (doesn't only return articles):

https://en.wikipedia.org/w/api.php?action=query&list=random&rnlimit=5

one random article (CHAR LIMIT exchars=500):

https://en.wikipedia.org/w/api.php?action=query&generator=random&grnnamespace=0&prop=extracts&exchars=500&format=json

specify an article type (otherwise you get all kinds of non-article things like templates and talks) THE ORDER OF THIS SEEMS TO MATTER

&grnnamespace=0


https://en.wikipedia.org/w/api.php?action=query&generator=random&grnnamespace=1&prop=extracts&format=json

search for articles by a word (here the word is: meaning):

https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&list=search%7Calllinks&iwurl=1&srsearch=meaning



/w/api.php?action=query&format=json&list=search%7Calllinks&iwurl=1&srsearch=meaning

Request json: { "action": "query", "format": "json", "list": "search|alllinks", "iwurl": 1, "srsearch": "meaning" }

CORs errors

Adding origin=* fixes CORs errors for requests from localhost for this API.

Posted @ 2019-02-28 12:49