npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wolfram-alpha

v0.6.0

Published

Wolfram Alpha API

Downloads

46

Readme

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.