Wolfram|Alpha Instant Calculators API
Wolfram|Alpha Instant Calculators APIReference

Instantly access interfaces for manipulating and evaluating equations with the Instant Calculators API.

The Instant Calculators API allows quick access to interactive form interfaces for calculating different values from common formulas. This process involves using Fast Query Recognizer API lookups to determine the correct attributes for a particular formula and Full Results API assumptions to represent and alter the possible states of a formula. The Instant Calculators API is implemented in a standard REST protocol using HTTP GET requests.

Although the majority of data available through the Wolfram|Alpha website is also available through this API, certain subjects may be restricted by default. To request access to additional topics, Contact Us. Use of the Instant Calculators API is subject to the API Terms of Use and Commercial Terms of Use.

Get StartedContact Us

Getting Started

Signup and Login

To get started, you must register a Wolfram ID and sign in to the Wolfram|Alpha Developer Portal.

Obtaining an AppID

Click the "Get an AppID" button to get your first AppID button to start the app creation process. Give your application a name, a simple description and select which app type to register an AppID. Each application must have its own unique AppID.

Using the Instant Calculators API

Sample Query

Now that you have an AppID, you can make your first query. Start with a Fast Query Recognizer API request to retrieve the information for a particular formula. The base URL for the Fast Query Recognizer API is:

Now that you have an AppID, you can make your first query. The base URL for queries is:

http://www.wolframalpha.com/queryrecognizer/query.jsp

Every query requires three pieces of information—an AppID, a mode and an input value—in order to be processed correctly. The appid parameter tells your query which AppID to use:

http://www.wolframalpha.com/queryrecognizer/query.jsp?appid=DEMO

The Fast Query Recognizer has two distinct modes, "Default" and "Voice", explained below. For the purposes of this sample query, we'll use the "Default" mode:

http://www.wolframalpha.com/queryrecognizer/query.jsp?appid=DEMO&mode=Default

Next, use the i parameter to specify the URL-encoded input for your query. For instance, here is a query for "RAID Array":

http://www.wolframalpha.com/queryrecognizer/query.jsp?appid=DEMO&mode=Default&i=RAID+array

When executed with a valid AppID, this URL will return an XML form with input elements for calculating the properties of a RAID array:

<queryrecognizer version="0.2" spellingcorrection="on" buildnumber="5662971"> 
	<query i="RAID array" accepted="true" timing="2.43" domain="formulas" resultsignificancescore="90"> 
		<formula name="RAIDArray" desc="RAID"> 
			<variable name="RAIDLevel" desc="RAID level" current="1" count="9">  
				<value name="RAID1" desc="RAID1"/> 
				<value name="RAID0" desc="RAID0"/> 
 				<value name="RAID5" desc="RAID5"/> 
 				<value name="RAID6" desc="RAID6"/> 
 				<value name="RAID1+0" desc="RAID10"/> 
 				<value name="RAID0+1" desc="RAID01"/> 
 				<value name="RAID5+0" desc="RAID50"/> 
				<value name="RAID5+1" desc="RAID51"/> 
 				<value name="RAID6+0" desc="RAID60"/> 
 			</variable> 
			<variable name="disks" desc="Number of drives" value="2"/> 
 			<variable name="size" desc="Drive size" value="500 GB"/>
		</formula> 
	</query>
</queryrecognizer>

Now, using these variable names, you can build a Full Results API query to calculate a specific value. The base URL for the Full Results API is:

http://www.wolframalpha.com/api/v2/query

As before, this query requires an App ID and an input value (using the input parameter):

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array

The rest of the URL uses formula assumptions (described below) to specify values for each variable. For instance, here is a query that uses the FormulaSelect assumption to evaluate the RAIDArray formula with default input values:

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array&assumption=FSelect_**RAIDArray-

This URL will return an XML form with the resulting value, along with elements for further calculations. The assumptions listed in this result correspond directly to the XML elements given in the Fast Query Recognizer API response:

<queryresult success="true" error="false" numpods="6" datatypes="Formula" timedout="" timedoutpods="" timing="1.206" parsetiming="0.167" parsetimedout="false" recalculate="http://www1.wolframalpha.com/api/v2/recalc.jsp?id=MSPa2011gbbhiifba6cgfi400002i5eg0e93cgh2cii2608364162801778372" id="MSPa2021gbbhiifba6cgfi400005hgc7b4763330aid" host="http://www1.wolframalpha.com" server="12" related="http://www1.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa2031gbbhiifba6cgfi400002i9c4b31fd835heh2608364162801778372" version="2.6"> 
	<pod title="Input interpretation" scanner="Formula" id="Input" position="100" error="false" numsubpods="1"> ... </pod> 
	<pod title="Input values" scanner="Formula" id="InputValue" position="300" error="false" numsubpods="1"> ... </pod>
	<pod title="Results" scanner="Formula" id="Result" position="400" error="false" numsubpods="1" primary="true">
		<subpod title=""> 
			<img .../>
			<plaintext>total RAID capacity | 500 GB  (gigabytes)
= 0.5 TB  (terabytes)
= 5×10^11 bytes
base-2 RAID capacity | 465.7 GiB  (gibibytes)</plaintext>
		</subpod>
	</pod>
	 <pod title="Parameters" scanner="Formula" id="Parameters" position="500" error="false" numsubpods="1"> ... </pod>
	<pod title="Minimum configuration" scanner="Formula" id="MinimumConfiguration" position="600" error="false" numsubpods="1"> ... </pod>
	<assumptions count="5">
		<assumption type="FormulaSolve" template="Calculate ${desc1}" count="2">
			<value name="RAIDArray.totalsize" desc="total RAID capacity" input="*FS-_**RAIDArray.totalsize--"/>
			<value name="RAIDArray.size" desc="drive size" input="*FS-_**RAIDArray.size--"/>
		</assumption>
		<assumption type="FormulaVariable" desc="RAID level" current="2" count="9">
			<value name="DriveStorageMethod:RAID0" desc="RAID0" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID0"/>
			<value name="DriveStorageMethod:RAID1" desc="RAID1" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID1"/>
			<value name="DriveStorageMethod:RAID5" desc="RAID5" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID5"/>
			<value name="DriveStorageMethod:RAID6" desc="RAID6" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID6"/>
			<value name="DriveStorageMethod:RAID1+0" desc="RAID10" valid="true«" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID1%2B0"/>
			<value name="DriveStorageMethod:RAID0+1" desc="RAID01" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID0%2B1"/>
			<value name="DriveStorageMethod:RAID5+0" desc="RAID50" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID5%2B0"/>
			<value name="DriveStorageMethod:RAID5+1" desc="RAID51" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID5%2B1"/>
			<value name="DriveStorageMethod:RAID6+0" desc="RAID60" valid="true" input="*FP.RAIDArray.RAIDLevel-_DriveStorageMethod%3ARAID6%2B0"/>
</assumption>
<assumption type="FormulaVariable" desc="number of drives" current="1" count="1">
			<value name="RAIDArray.disks" desc="2" valid="true" input="*F.RAIDArray.disks-_2"/>
</assumption>
<assumption type="FormulaVariable" desc="drive size" current="1" count="1">
			<value name="RAIDArray.size" desc="500 GB" valid="true" input="*F.RAIDArray.size-_500+GB"/>
</assumption>
<assumption type="FormulaVariableInclude" template="Also include ${desc1}" count="1">
			<value name="RAIDArray.spareDisks" desc="spare drives" input="*FVarOpt-_**RAIDArray.spareDisks--"/>
		</assumption>
	</assumptions>
</queryresult>

The sections below give more detail on using formula assumptions.

Formulas Overview

Many Wolfram|Alpha queries generate simple interfaces for exploring equations, formulas and other information using pull-down menus and fillable text fields. For example, the "RAID array" query yields the following user interface:

Many Wolfram|Alpha queries generate simple interfaces for exploring equations, formulas and other information using pull-down menus and fillable text fields. For example, the "RAID array" query yields the following user interface:

Adjusting the options in this form allows the user to calculate the total storage capacity for various RAID configurations. The Instant Calculators API allows you to recreate this functionality with structured XML that can be easily embedded into web deployments:

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array&assumption=FSelect_**RAIDArray-&assumption=*FP.RAIDArray.RAIDLevel-_RAID6&assumption=*F.RAIDArray.disks-_2&assumption=*F.RAIDArray.size-_500+GB

Formula XML Elements

The following is a brief summary of formula-related XML elements returned by the Fast Query Recognizer API, along with the standard attributes for each.

<formula>

This element is the outer wrapper for the formula. It has two attributes: name, the internal name of the formula, and desc, the descriptive name used for display purposes.

<variable>

Each variable used in the formula has its own element with unique name and desc attributes. Variables with a limited number of options use a pull-down interface; these elements include the current attribute to indicate which option is currently active and the count attribute to indicate how many options are available. Continuous variables instead have the value attribute, which represents the current value in a fillable text field.

<value>

The values within a pull-down menu are represented by these elements. Each has its own unique name and desc attributes.

Building API Requests

Requests are built from the elements listed in XML results. Each element returned by the Fast Query Recognizer API corresponds to an assumption to be used in the Instant Calculators API. This section describes these assumptions and demonstrates how to build a query from XML elements.

Formula Select

To select which formula you would like to display, use the FormulaSelect assumption type with the syntax FSelect_**<FORMULA_NAME>- (where <FORMULA_NAME> corresponds to the name attribute of the formula element). Here is a query that generates the RAIDArray calculator from above with default values:

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array&assumption=FSelect_**RAIDArray-

Formula Pulldown Value

Individual pull-down values can be selected using the FP assumption type with the syntax *FP.<FORMULA_NAME>.<VARIABLE_NAME>-_<VARIABLE_VALUE> (where <VARIABLE_NAME> and <VARIABLE_VALUE> represent the name attributes of the variable element and of the enclosed value element, respectively). This query creates a RAIDArray calculator with the RAID6 option selected from the RAIDLevel pull-down:

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array&assumption=FSelect_**RAIDArray-&assumption=*FP.RAIDArray.RAIDLevel-_RAID6

Formula Text Input

Use the F assumption type with the syntax *F.<FORMULA_NAME>.<VARIABLE_NAME>-_<VARIABLE_VALUE> to populate values for fillable text fields. Extending on the previous examples, this query gives a value of 4 for the disks variable:

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array&assumption=FSelect_**RAIDArray-&assumption=*FP.RAIDArray.RAIDLevel-_RAID6&assumption=*F.RAIDArray.disks-_4

Formula Solve

Some formulas allow you to solve for different values. You can select a variable using the FormulaSolve assumption type with the syntax *FS-_**<FORMULA_NAME>--. The value for <FORMULA_NAME> comes from the FormulaSolve assumption in the XML returned by the Full Results API. For instance, here is a query to solve for the drive size of a RAID array rather than the total RAID capacity:

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array&assumption=FSelect_**RAIDArray-&assumption=*FS-_**RAIDArray.size--

Formula Variable Include

You can also include or exclude specific variables in formulas (when available) with the FormulaVariableInclude assumption type, which uses the syntax *FVarOpt-_**<VARIABLE_NAME>--. The value for <VARIABLE_NAME> comes from the FormulaVariableInclude assumption in the XML returned by the Full Results API. This query would request the inclusion of "spare drives" as a variable in your RAID array calculation:

http://www.wolframalpha.com/api/v2/query?appid=DEMO&input=RAID+array&assumption=FSelect_**RAIDArray-&assumption=*FVarOpt-_**RAIDArray.spareDisks--

Errors

The following is a brief list of common errors and their recommended solutions. For detailed information on warnings and interpretation issues, see the Warnings section of the Full Results API documentation.

Input parameter not present in query (Error 1000)

This error indicates that the Full Results API did not find an input parameter while parsing. In most cases, this can be fixed by checking that you have used the correct syntax and have included a non-blank input parameter.

Invalid appid (Error 1)

This error is returned when a request contains an invalid option for the appid parameter. Double-check that your AppID is typed correctly and that your appid parameter is using the correct syntax.

Appid missing (Error 2)

This error is returned when a request does not contain any option for the appid parameter. Double-check that you have entered an AppID and that your appid parameter is using the correct syntax.

Wolfram|Alpha API Quick Links

Get Started

free non-commercial development account

Contact Us

flexible commercial licensing with low monthly plans available