node-wolfram provides a simple API wrapper to use the Wolfram | Alpha service for NodeJS.
$ npm install wolfram-node
Used to set the query and make a request to Wolfram | Alpha and returns the result in JSON
query
- The actual input to be queried to Wolfram | Alphaassumption
- Applies an assumption to the query.translation
- Used to set the automatic translation to English. Defaults tofalse
reinterpret
- Used to reinterpret the query if Wolfram | Alpha does not understand. Defaults tofalse
primary
- Used to display the closest thing to a simple "answer" that Wolfram|Alpha can provide. Defaults totrue
Used to get the results for the given query in JSON
Used to return the query that is currently being set
Used to return the Pod from the Query Results
You will need an application ID to access the Wolfram | Alpha API. You can get it by signing up on Wolfram | Alpha Developer
var wolfram = require('./').init('APPLICATION_ID');
var data = {
query : 'pi',
assumption: '*C.pi-_*Movie-'
};
wolfram.ask(data, function(err, results) {
if(err)
throw err;
//Do something interesting with your data
//or simply display it
console.log(util.inspect(results, false, null));
});
wolfram.getPod(function(err, results) {
if(err)
throw err;
//Access the Pods here
console.log(util.inspect(results, false, null));
});
wolfram.getQuery(function(err, query) {
if(err)
throw err;
//Returns the Query currently being set
// {
// input: 'pi',
// assumption: '*C.pi-_*Movie-',
// translation: false,
// reinterpret: false,
// primary: true,
// appid: '***********'
// }
});
Install Mocha $ npm install -g mocha
Run Test $APPID = 'YOUR_APP_ID' npm test
MIT