web

web / WikipediaParser / 0.1.2

README.md

0. TL;DR

This algorithm provides basic API access to Wikipedia.

1. Introduction

Search Wikipedia, get article summaries, get data like links and images from a page, and more. This algorithm wraps the MediaWiki API so you can focus on accessing relevant Wikipedia data, instead of downloading the latest Wikipedia dump.

Input:

  • (Required): Only one of them
    • A Wikipedia article name (key = "articleName")
    • Search for a Wikipedia article (key = "search")
    • Number of random articles (key = "random")
  • (Optional): Set Wikipedia Language (key = "lang")

Output:

  • JSON formatted page data (only for article name)
  • List of article names (for searching a term & random articles)

2. Retrieving a Wikipedia Article

A wikipedia Article: Retrieve a Wikipedia Articles by it's title name (key = "articleName")

Example of retrieving a Wikipedia Article:

"AI Winter"

or

{
  "articleName": "AI Winter"
}

3. Searching for a Wikipedia Article

  • Search for a Wikipedia Article: Search for Wikipedia articles that match the search term (key = search)

Example of searching for Wikipedia articles:

{
  "search": "Great Filter"
}

4. Getting Random Wikipedia Article(s)

  • Number of Random Articles: Get up to 500 random Wikipedia articles (key = random)

Example of getting random Wikipedia articles:

{
  "random": 10
}

5. Outputs

  • JSON formatted page data: Output is returned after for requesting a valid Wikipedia article.

Example for JSON formatted page data (for articleName = "AI Winter"):

{
    "pageid": "3548574",
    "links": ["1997 Asian financial crisis", "AAAI", "AI effect", "AI winter", ...],
    "title": "AI winter",
    "url": "https://en.wikipedia.org/wiki/AI_winter",
    "summary": "In the history of artificial intelligence, an AI winter is a period of ...",
    "content": "In the history of artificial intelligence, an AI winter is a period of ...",
    "references": ["http://dx.doi.org/10.1109%2FMIS.2007.62", "http:ftp://ftp.cordis.europa.eu/pub/ist/docs/kct/fp7-ict-at-glance_en.pdf", ...],
    "images": ["https://upload.wikimedia.org/wikipedia/commons/9/98/Ambox_current_red.svg", "https://upload.wikimedia.org/wikipedia/commons/3/31/Perceptron.svg", ...]
}
  • A List of article names: Output is returned after searching for a term or requesting a number of random articles.

Example for a list of article name (for search = "Fermi Paradox"): 

[
  "Fermi paradox",
  "Fermi Paradox (album)",
  "Planetarium hypothesis",
  "Noogenesis",
  "Manifold Trilogy",
  "Great Filter",
  "Zoo hypothesis",
  "Neocatastrophism",
  "The Fermi Paradox Is Our Business Model",
  "Fermi and Frost"
]

Example for a list of article names (for random = 10):

[
  "2005 CIS football season",
  "Outre-Forêt",
  "Cryptomyrmex",
  "Stephen Kelman",
  "Samuel Owens",
  "Stockport Central Library",
  "Liam Fox",
  "StealthNet",
  "Smales Farm Busway Station",
  "U.S. Route 62 in Arkansas"
]

6. Retrieving from a Language Specific Wiki

  • A wikipedia Article: Retrieve a Wikipedia Articles by it's title name (key = "articleName") and language (key = "lang")

Example of retrieving a Wikipedia Article from Dutch:

{
  "articleName": "AI Winter",
	"lang": "nl"
}

7. Credits

For more information please visit: https://wikipedia.readthedocs.org/en/latest/