npm install wolfram-alphaThis is a Wolfram|Alpha API wrapper for Node.js.
All the query parameters are fully customizable as per the API reference, and the normal 'plaintext,image,sound,mathml' formats are all parsed properly.
Install the module with npm, and (possibly) install the libxml dependency in your OS first:
``sh`
$ sudo apt-get install libxml2-dev
$ npm install wolfram-alpha
Example usage:
`js
var wolfram = require('wolfram-alpha').createClient("APIKEY-HERE", opts);
var results = yield wolfram.query("integrate 2x")
console.log("Result: %j", results);
`
When results exist, each pod will have the following format:
`js`
results[0];
{
title: "some title",
subpods: [
{
text: "text found in the
image: "link found in the attribute",
mathml: "mathml string found in the
},
// maybe more subpods (but often not)
],
primary: Boolean("was the primary attribute set on the pod?"),
sounds: [
"link found in the first
// maybe more sounds
]
}
Sounds and mathml will only exist when you request them in the createClient opts.format string, and they are not guaranteed to exist. Text and images can be removed from the opts.format string as well which will likely mean you get much fewer pods.
Having a quick look at the API reference and the short source will prove useful for providing guarantees of what kind of data is available when.
Note that results[0] seems to always be the "Input Interpretation", while results[1] is the most relevant answers (but it will not always have results[1].primary === true despite this).
`bash``
$ export WOLFRAM_APPID=APIKEY-HERE
$ npm test