Coder Social home page Coder Social logo

wolfram-alpha's Introduction

wolfram-alpha

npm status build status dependency status coverage status

This 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.

Usage

Register for a Wolfram|Alpha application ID. The Wolfram|Alpha® API is available for free for non-commercial experimental use with a low monthly cap on queries. For more information, visit http://products.wolframalpha.com/developers/. Wolfram is a registered trademark of the Wolfram Group of Companies.

Install the module with npm, and (possibly) install the libxml dependency in your OS first:

$ sudo apt-get install libxml2-dev
$ npm install wolfram-alpha

Example usage:

var wolfram = require('wolfram-alpha').createClient("APIKEY-HERE", opts);

var results = yield wolfram.query("integrate 2x")
console.log("Result: %j", results);

Output

The results calls back with a result array of pods (each pod is typically one of the result blocks on the web interface). An empty results array corresponds to results found.

When results exist, each pod will have the following format:

results[0];
{
  title: "some title",
  subpods: [
    {
      text: "text found in the <plaintext> element",
      image: "link found in the <img src=> attribute",
      mathml: "mathml string found in the <mathml> element"
    },
    // maybe more subpods (but often not)
  ],
  primary: Boolean("was the primary attribute set on the pod?"),
  sounds: [
    "link found in the first <sound url=> attribute",
    // 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).

Running tests

Set the API key as an environment variable, then run the library's test command:

$ export WOLFRAM_APPID=APIKEY-HERE
$ npm test

License

MIT-Licensed. See LICENSE file for details.

wolfram-alpha's People

Contributors

clux avatar almanackist avatar edwarddrapkin avatar titanous avatar justinsisley avatar

Stargazers

Bankn8II©$A avatar

Forkers

aibolem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.