1

Could someone explain how I can access Wolfram's API data? I'm not worried about formatting for now--I would just like to learn the basics of interacting with the API.

The Wolfram website FAQ says this: "The Wolfram|Alpha API is designed to operate with interactive web technologies such as AJAX, Flash, and Silverlight."

And the documentation, which is located here: http://products.wolframalpha.com/api/documentation.html, says this: "A simple API call to retrieve output for the query "pi" would look like this:

http://api.wolframalpha.com/v2/query?input=pi&appid=XXXX

This query did not specify a desired output format, and the default is to retrieve the plaintext and image representations of each subpod. The image is returned as an <img> tag suitable for direct inclusion in a web page. Here is the output:"

I just have no idea how to put this together to actually access the Wolfram API data. Do I use AJAX or something else? What is the basic code for accessing the data?

I'm very new at this, so any help would be greatly appreciated. Thanks a lot!!

Musa
  • 96,336
  • 17
  • 118
  • 137

2 Answers2

0

If you use JQuery, a common javasSript framework, you can make an ajax request as follows

var requestData = function() {
   $.ajax({
   url: "http://api.wolframalpha.com/v2/query?input=pi&appid=XXXX",
}).done(function(data) {
   //data should contain the response from wolframalpha
});  
Rich Hildebrand
  • 1,607
  • 17
  • 15
0

To use XMLHttpRequest their server must enable credentials by setting the Access-Control-Allow-Credentials response header to “true”

https://en.wikipedia.org/wiki/Cross-origin_resource_sharing

By AJAX I think they mean your server code should make the request. In the next example they use Java Server Pages on their own domain to make the request:

https://reference.wolfram.com/webMathematica/tutorial/ApplicationsAJAX.html

Check other answers:

Wolfram API javascript cross origin sharing issue

Community
  • 1
  • 1
shuji
  • 7,369
  • 7
  • 34
  • 49