Return Wikipedia Summary

Hello,
I would like to create a wolfram application that returns only the Wikipedia summary. Is this possible with the Wolfram Alpha API? I am using Python.

Any help is appreciated.

No, you wouldn’t use the Wolfram|Alpha API for this. You would use Mathematica or Mathematica online to make an API.

The code to do this in the WolframLanguage is :

WikipediaData["Elephant", "SummaryPlaintext"]

This returns the summary for the wikipedia article on “Elephant”. We can create an API to do this with just one line:

CloudDeploy[APIFunction[{"Title" -> "String"}, WikipediaData[#Title, "SummaryPlaintext"] &], Permissions -> "Public"]

There is also a function called EmbedCode which produces Python code that will call an automatically generated API. You can learn more about these functions in the Wolfram Language documentation:

Thanks for the response Sean. I guess I cannot use this package then? wolframalpha · PyPI

You can use the WolframAlpha API to interact with Wolfram|Alpha.

Wolfram|Alpha doesn’t do this thing you want with Wikipedia articles, does it? Wolfram|Alpha is mostly free to use. You can try it and see it what it does.

Hey Sean,

Wolfram|Alpha does give me the wikipedia summary if I run the queries here http://www.wolframalpha.com/ but it doesnt if I use the python package. This is why I am a bit confused.

Thanks,
Glenn

What query are you using to get the wikipedia summary? What does your API query look like?

Have you tried using the API explorer?
http://products.wolframalpha.com/api/explorer.html

Let’s say I ask “Who is Iron Man” in the website. who is iron man - Wolfram|Alpha I will get a response with the wikipedia summary.

I have tried the API explorer. But when I use it for the same query the Wikipedia summary is absent. http://products.wolframalpha.com/api/explorer.html

Thanks again for your help. Wolfram is pretty awesome.

This looks a lot like a bug in W|A API. You should contact Wolfram support.
Alternatively, you could download the summary using one of the Python modules for accessing Wikipedia, or just use the plain old urllib2.