Wolfram|Alpha Full Results APIReference
The Wolfram|Alpha Full Results API provides a web-based API allowing the computational and presentation capabilities of Wolfram|Alpha to be integrated into web, mobile, desktop and enterprise applications.
The API allows clients to submit free-form queries similar to the queries one might enter at the Wolfram|Alpha website, and for the computed results to be returned in a variety of formats. It is implemented in a standard REST protocol using HTTP GET requests. Each result is returned as a descriptive XML or JSON structure wrapping the requested content format.
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 Full Results API is subject to the API Terms of Use.
RESOURCES:
Getting Started
Start using the Full Results API in minutes by following these basic steps.Signup and Login
To get started, you must register a Wolfram ID and sign in at 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.
Sample Query
Now that you have an AppID, you can make your first query. The base URL for queries is:
http://api.wolframalpha.com/v2/query
Every query requires two pieces of information—an AppID and an input value—in order to be processed correctly. The appid parameter tells your query which AppID to use:
http://api.wolframalpha.com/v2/query?appid=DEMO
Next, use the input parameter to specify the URL-encoded input for your query. For instance, here is a query for “population of France”:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france
When executed with a valid AppID, this URL will return an XML document with informational elements (referred to as pods relating to the input. Here is the XML output for the "population of France" query, with most elements collapsed for brevity:
<queryresult success="true" error="false" numpods="5" datatypes="Country" timedout="Data,Percent,Unit,AtmosphericProperties,UnitInformation,Music,Geometry" timedoutpods="" timing="6.272" parsetiming="0.27" parsetimedout="false" version="2.6">
<pod title="Input interpretation" scanner="Identity" id="Input" position="100" error="false" numsubpods="1">...</pod>
<pod title="Result" scanner="Data" id="Result" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
64.1 million people (world rank: 21st) (2014 estimate)
</plaintext>
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP291g37h8915724h4b800004ec2h0de24da9sbp?MSPStoreType=image/gif&s=12" alt="64.1 million people (world rank: 21st) (2014 estimate)" title="64.1 million people (world rank: 21st) (2014 estimate)" width="313" height="18"/>
</subpod>
</pod>
<pod title="Recent population history" scanner="Data" id="RecentHistory:Population:CountryData" position="300" error="false" numsubpods="1">...</pod>
<pod title="Long-term population history" scanner="Data" id="LongTermHistory:Population:CountryData" position="400" error="false" numsubpods="1">...</pod>
<pod title="Demographics" scanner="Data" id="DemographicProperties:CountryData" position="500" error="false" numsubpods="1">...</pod>
<warnings count="1">...</warnings>
<sources count="1">...</sources>
</queryresult><queryresult success="true" error="false" numpods="5" datatypes="Country" timedout="Data,Percent,Unit,AtmosphericProperties,UnitInformation,Music,Geometry" timedoutpods="" timing="6.272" parsetiming="0.27" parsetimedout="false" version="2.6">
<pod title="Input interpretation" scanner="Identity" id="Input" position="100" error="false" numsubpods="1">...</pod>
<pod title="Result" scanner="Data" id="Result" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
64.1 million people (world rank: 21st) (2014 estimate)
</plaintext>
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP291g37h8915724h4b800004ec2h0de24da9ife?MSPStoreType=image/gif&s=12" alt="64.1 million people (world rank: 21st) (2014 estimate)" title="64.1 million people (world rank: 21st) (2014 estimate)" width="313" height="18"/>
</subpod>
</pod>
<pod title="Recent population history" scanner="Data" id="RecentHistory:Population:CountryData" position="300" error="false" numsubpods="1">...</pod>
<pod title="Long-term population history" scanner="Data" id="LongTermHistory:Population:CountryData" position="400" error="false" numsubpods="1">...</pod>
<pod title="Demographics" scanner="Data" id="DemographicProperties:CountryData" position="500" error="false" numsubpods="1">...</pod>
<warnings count="1">...</warnings>
<sources count="1">...</sources>
</queryresult>
Formatting Input
All URLs used to make queries must be URL encoded (e.g. spaces represented as "%20" and backslashes represented as "%5c").
For mathematical queries, Wolfram|Alpha will also accept input formatted using presentation LaTeX or MathML. This can be useful when passing information back and forth between the API and a website or application using one of these formats.
Adding Parameters
You can add URL-encoded parameters to customize output. For instance, if you only wanted the "Result" pod from the above output, you could use the includepodid parameter:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20france&includepodid=Result
This way, only pods with that exact ID are returned in the XML output:
<queryresult success="true" error="false" numpods="1" datatypes="" timedout="" timedoutpods="" timing="0.895" parsetiming="0.277" parsetimedout="false" recalculate="" id="MSPa201c626hgh07fd2ee900003c1966c16708edi1" host="http://www1.wolframalpha.com" server="13" related="http://www1.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa211c626hgh07fd2ee90000368i61d9578b12h4&s=13" version="2.6">
<pod title="Result" scanner="Data" id="Result" position="100" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
64.1 million people (world rank: 21st) (2014 estimate)
</plaintext>
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP221c626hgh07fd2ee900004eagdagf39fchhhg?MSPStoreType=image/gif&s=13"
alt="64.1 million people (world rank: 21st) (2014 estimate)"
title="64.1 million people (world rank: 21st) (2014 estimate)"
width="313" height="18"/>
</subpod>
</pod>
<sources count="1">...</sources>
</queryresult>
Note that this result returns both a <plaintext> element and an <img> element. You can select which output type you prefer using the format parameter:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20france&includepodid=Result&format=plaintext
By using parameters in your queries, you can reduce the output to just the pieces you need. Notice how much shorter this output is than that of the original query:
<queryresult success="true" error="false" numpods="1" datatypes="" timedout="" timedoutpods="" timing="0.723" parsetiming="0.266" parsetimedout="false" recalculate="" id="MSPa1751g37h8915724h4b80000365icce2he8ca3g1" host="http://www1.wolframalpha.com" server="12" related="http://www1.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa1761g37h8915724h4b80000267ba77dbgig0651&s=12" version="2.6">
<pod title="Result" scanner="Data" id="Result" position="100" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
64.1 million people (world rank: 21st) (2014 estimate)
</plaintext>
</subpod>
</pod> <sources count="1">...</sources>
</queryresult>
A list of possible parameters is included below.
Parameter Reference
Basic Parameters
PARAMETER NAME | FUNCTION | SAMPLE VALUES | DEFAULT VALUES | NOTES |
---|---|---|---|---|
input | URL-encoded text specifying the input string | "5+largest+countries", "Doppler%20shift", "pascal%27s%20triangle" | N/A (Queries without an input value will fail) | Required parameter |
appid | An ID provided by Wolfram Research that identifies the application or organization making the request | X7WEHY-W45KYJL3C9 | N/A (Queries without an AppID will fail) | Required parameter |
format | The desired format for individual result pods | "image", "imagemap", "plaintext", "minput", "moutput", "cell", "mathml", "sound", "wav" | Return basic text and image formats ("plaintext,image") | All possible values for this parameter are listed here. For multiple formats, separate values with a comma. |
output | The desired format for full results | "xml", "json" | Return an XML document | All possible values for this parameter are listed here |
Pod Selection
PARAMETER NAME | FUNCTION | SAMPLE VALUES | DEFAULT VALUES | NOTES |
---|---|---|---|---|
includepodid | Specifies a pod ID to include in the result | "Result", "BasicInformation:PeopleData", "DecimalApproximation" | All pods included | To specify multiple elements, use multiple instances of the parameter |
excludepodid | Specifies a pod ID to exclude from the result | "Result", "BasicInformation:PeopleData", "DecimalApproximation" | No pods excluded | To specify multiple elements, use multiple instances of the parameter |
podtitle | Specifies a pod title to include in the result | "Basic+Information", "Image", "Alternative%20representations" | All pods returned | To specify multiple elements, use multiple instances of the parameter. Use * as a wildcard to match zero or more characters in pod titles. |
podindex | Specifies the index(es) of the pod(s) to return | "1", "7", "5,12,13" | All pods returned | To specify multiple elements, separate values with a comma |
scanner | Specifies that only pods produced by the given scanner should be returned | "Numeric", "Data", "Traveling" | Pods from all scanners returned | To specify multiple elements, use multiple instances of the parameter |
Location
PARAMETER NAME | FUNCTION | SAMPLE VALUES | DEFAULT VALUES | NOTES |
---|---|---|---|---|
ip | Specifies a custom query location based on an IP address | "192.168.1.1", "127.0.0.1" | Use caller's IP address for location | Only one location parameter may be used at a time. IPv4 and IPv6 addresses are supported. |
latlong | Specifies a custom query location based on a latitude/longitude pair | "40.42,-3.71", "40.11, -88.24", "0,0" | Use caller's IP address for location | Only one location parameter may be used at a time |
location | Specifies a custom query location based on a string | "Boston, MA", "The North Pole", "Beijing" | Use caller's IP address for location | Only one location parameter may be used at a time |
Size
PARAMETER NAME | FUNCTION | SAMPLE VALUES | DEFAULT VALUES | NOTES |
---|---|---|---|---|
width | Specify an approximate width limit for text and tables | "200", "500" | Width set at 500 pixels | This parameter does not affect plots or graphics. Width values are approximate; behavior may vary for different content. |
maxwidth | Specify an extended maximum width for large objects | "200", "500" | Width set at 500 pixels | This parameter does not affect plots or graphics. Width values are approximate; behavior may vary for different content. |
plotwidth | Specify an approximate width limit for plots and graphics | "100", "200" | Plot width set at 200 pixels | This parameter does not affect text or tables. Width values are approximate; behavior may vary for different content. |
mag | Specify magnification of objects within a pod | "0.5", "1.0", "2.0" | Magnification factor of 1.0 | Changing this parameter does not affect the overall size of pods |
Timeouts/Async
PARAMETER NAME | FUNCTION | SAMPLE VALUES | DEFAULT VALUES | NOTES |
---|---|---|---|---|
scantimeout | The number of seconds to allow Wolfram|Alpha to compute results in the "scan" stage of processing | "0.5", "5.0" | Scan stage times out after 3.0 seconds | This parameter effectively limits the number and breadth of subtopics that will be included in a result |
podtimeout | The number of seconds to allow Wolfram|Alpha to spend in the "format" stage for any one pod | "0.5", "5.0" | Individual pods time out after 4.0 seconds | This parameter can be used to prevent a single pod from dominating too much processing time, or to return only the "quick" information in your result |
formattimeout | The number of seconds to allow Wolfram|Alpha to spend in the "format" stage for the entire collection of pods | "0.5", "5.0" | Format stage times out after 8.0 seconds | Use this parameter in conjunction with podtimeout to balance between returning a few large results and numerous quick results |
parsetimeout | The number of seconds to allow Wolfram|Alpha to spend in the "parsing" stage of processing | "0.5", "5.0" | Parsing stage times out after 5.0 seconds | Queries that time out in this phase will return a <queryresult> element with success=false and parsetimeout=true. Very few queries will exceed the default. |
totaltimeout | The total number of seconds to allow Wolfram|Alpha to spend on a query | "0.5", "5.0" | Queries time out after 20.0 seconds | Combine with other timeout parameters to define a last-resort time limit for queries. |
async | Toggles asynchronous mode to allow partial results to return before all the pods are computed | "true", "false", "3.0" | Asynchronous mode disabled ("false") | Specifying a number sets the time limit (in seconds) for returning partial results |
Miscellaneous
PARAMETER NAME | FUNCTION | SAMPLE VALUES | DEFAULT VALUES | NOTES |
---|---|---|---|---|
reinterpret | Whether to allow Wolfram|Alpha to reinterpret queries that would otherwise not be understood | "true", "false" | Do not reinterpret queries ("false") | This parameter will force the API to decide among <didyoumeans> and similar XML results |
translation | Whether to allow Wolfram|Alpha to try to translate simple queries into English | "true", "false" | Do not attempt translation ("false") | Translation attempts are displayed as <translation> warnings in XML results |
ignorecase | Whether to force Wolfram|Alpha to ignore case in queries | "true", "false" | Do not ignore case ("false") | This can be useful for differentiating abbreviations, acronyms and titles |
sig | A special signature that can be applied to guard against misuse of your AppID | N/A | No signature applied | For access to this feature, contact us |
assumption | Specifies an assumption, such as the meaning of a word or the value of a formula variable | "*C.pi-_*Movie", "DateOrder_**Day.Month.Year--" | Assumptions made implicitly by the API | Values for this parameter are given by the input properties of <value> subelements of <assumption> elements in XML results |
podstate | Specifies a pod state change, which replaces a pod with a modified version, such as displaying more digits of a large decimal value | "WeatherCharts:WeatherData__Past+5+years", "2@DecimalApproximation__More+digits" | Pod states generated implicitly by the API | Specify consecutive state changes with the @ symbol (e.g. podstate=2@DecimalApproximation__More+digits) |
units | Lets you specify the preferred measurement system, either "metric" or "nonmetric" (US customary units) | "metric", "nonmetric" | Chosen based on caller's IP address | Using location parameters will affect the units displayed for a query) |
List of XML Result Elements
- success — true or false depending on whether the input could be successfully understood. If false, there will be no <pod> subelements.
- error — true or false depending on whether a serious processing error occurred, such as a missing required parameter. If true, there will be no pod content, just an <error> subelement.
- numpods — The number of pods.
- version — The version specification of the API on the server that produced this result.
- datatypes — Categories and types of data represented in the results (e.g. "Financial").
- timing — The wall-clock time in seconds required to generate the output.
- timedout — The number of pods that are missing because they timed out (see the timeout query parameters).
- parsetiming — The time in seconds required by the parsing phase.
- parsedtimeout — Whether the parsing stage timed out (try a longer parsetimeout parameter if true).
- recalculate — A URL to use to recalculate the query and get more pods.
- title — The pod title, used to identify the pod and its contents.
- error — true or false depending on whether a serious processing error occurred with this specific pod. If true, there will be an <error> subelement
- position — A number indicating the intended position of the pod in a visual display. These numbers are typically multiples of 100, and they form an increasing sequence from top to bottom.
- scanner — The name of the scanner that produced this pod. A general guide to the type of data it holds.
- id — A unique identifier for a pod, used for selecting specific pods to include or exclude.
- numsubpods — The number of subpod elements present.
- src — The exact URL of the image being displayed, to be used for displaying the image.
- alt — Alternate text to display in case the image does not render correctly—usually the same as the <plaintext> representation of the image.
- title — Descriptive title for internal identification of an image—usually the same as the <plaintext> representation of the image.
- width — The width of the image in pixels; can be changed using the width control parameters.
- height: — The height of the image in pixels; scales depending on width setting.
- type — Classification of an assumption that defines how it will function.
- word — The central word/phrase to which the assumption is applied.
- template — A statement outlining the way an assumption will be applied.
- count — Number of possible values available from an assumption.
- word — The exact word taken from the original query.
- suggestion — Wolfram|Alpha's suggested respelling of the word.
- text — The message normally displayed to the user when a word is reinterpreted because of a <spellcheck> warning.,
- phrase — The exact phrase taken from the original query.
- trans — Wolfram|Alpha's suggested translation of the phrase.
- lang — The language from which Wolfram|Alpha attempted to translate.
- text — The message normally displayed on the Wolfram|Alpha website to inform the user of this warning (e.g. "Translating from German to 'weather today'").
- code — The error code, an integer.
- msg — A short message describing the error.
<queryresult>
<queryresult> contains the entire API result. The <queryresult> element is a superelement of all others listed. It has the following attributes:
<pod>
<pod> elements are the main output of the Full Results API. Each pod contains a piece or category of information about the given query. It has the following attributes:
<subpod>
Subelements of <subpod> that contain the results for a single subpod. <subpod> has a title attribute, which is usually an empty string because most subpods have no title.
<img>
HTML <img> elements suitable for direct inclusion in a webpage. They point to stored image files giving a formatted visual representation of a single subpod. They only appear in pods if the requested result formats include img. In most cases, the image will be in GIF format, although in a few cases it will be in JPEG format. The filename in the <img> URL will tell you whether it is GIF or JPEG. The <img> tag also contains the following attributes:
<imagemap>
HTML image maps for visual elements that can be clicked to execute further queries. Contains <rect> subelements that specify the corners of clickable areas with coordinates (using the top-left corner as the origin).
<plaintext>
Textual representation of a single subpod. Only appears if the requested result formats include plain text. <plaintext> has no attributes or subelements.
<mathml>
Contains the MathML representation of a single subpod. MathML output opens with <math> and includes formatting subelements such as <mfrac> and <msup>. This element type will only appear if the requested result formats include mathml.
<sound>
HTML <sound> elements suitable for direct inclusion in a webpage. They point to stored sound files giving an audio representation of a single subpod. These elements only appear in pods if the requested result formats include sound or wav. The type attribute will tell whether the format is MIDI or WAV.
<minput>
Wolfram Language input that can be executed within a Wolfram Language environment to provide the result given in a single subpod.
<moutput>
Wolfram Language output representation of the result given in a single subpod.
<cell>
A Wolfram Language Cell expression that can be interpreted in a Wolfram Language environment to render exactly the same output as the Wolfram|Alpha website for a single subpod. The expression is wrapped in a <![CDATA[...]]> element, and can sometimes span across multiple elements.
<assumptions>
The <assumptions> element is a subelement of <queryresult>. Its content is a series of <assumption> elements. It has a count attribute, giving the number of <assumption>> subelements.
<assumption>
The <assumption> element is a subelement of <assumptions>. It defines a single assumption, typically about the meaning of a word or phrase, and a series of possible other values. It has the following attributes:
<states>
The <states> element is a subelement of <pod> or <subpod>. It has a count attribute and it contains a series of <state> and/or <statelist> elements. See the "Pod States" section of the main text for more details.
<state>
The <state> element, always a subelement of <states>, contains a particular pod state for a single pod or subpod. It has a name attribute that describes the pod state and an input attribute that can be used to modify subsequent queries.,
<warnings>
The <warnings> element occurs as a subelement of <queryresult>. It contains <warning> subelements, each of which describes a particular warning generated during the query.
<spellcheck>
The <spellcheck> element contains a warning about a word that was reinterpreted because Wolfram|Alpha concluded it was misspelled. It contains the following attributes:
<delimiters>
The <delimiters> element contains a warning about mismatched parentheses or other bracketing elements that Wolfram|Alpha attempted to rectify. Currently, the only attribute is text, and its value is the message "An attempt was made to fix mismatched parentheses, brackets or braces."
<translation>
The <translation> element contains a warning about a phrase in a query that Wolfram|Alpha attempted to translate to English before computation. It has the following attributes:
<reinterpret>
The <reinterpret> element contains a warning about a query or part of a query that was reinterpreted by Wolfram|Alpha to provide more useful and/or relevant results. It has a text attribute displaying the message "Using closest Wolfram|Alpha interpretation:", along with a list of <alternative> elements showing other possible interpretations.
<error>
The <error> element occurs as either a subelement of <queryresult>, if there was a failure that prevented any result from being returned, or as a subelement of <pod>, if there was an error that only prevented the result from a given pod from being returned. <error> has the following attributes:
<sources>
The <sources> element is a subelement of <queryresult>. The <sources> element contains a series of <source> subelements, each one defining a link to a webpage of source information. See the "Sources" section for more details.
<infos>
The <infos> element contains <info> elements that contain pieces of information about the contents of a pod.
<languagemsg>
The <languagemsg> element appears if the input is recognized as a foreign language that is not supported. It includes messages in English and the unsupported language stating that the language is not yet supported.
<generalization>
The <generalization> element appears when Wolfram|Alpha recognizes that more information is available on a broader query than the one specified.
<tips>
The <tips> element contains various <tip> subelements with text offering pointers for better queries.
<didyoumeans>
The <didyoumeans> element contains various <didyoumean> elements with text suggesting alternative queries with similar spelling. Because it is difficult to verify the relevance of these suggestions, we recommend against using them in your implementations.
<futuretopic>
The <futuretopic> element appears when a query result refers to a topic still under development.
<examplepage>
The <examplepage> element appears when a query is recognized as a category for which a set of example queries has already been prepared.
Explanation of Pods
By default, the Wolfram|Alpha website returns a large set of categorized information related to a given query. Each category of output is contained in a rectangular pod, which in turn includes subpods with individual pieces of data. Every pod has a title (displayed in the top-left corner) and at least one subpod. Most information is displayed as a GIF image by default. Here is the main Wolfram|Alpha output for the "tides Seattle" query:
When you make a call to the Full Results API, it will return pod and subpod information as an XML document. Using only the required parameters, all pods from a particular query are returned in their default format and state. Here is the Full Results API output for the same query (with some XML elements truncated for brevity and readability):
<queryresult success="true" error="false" numpods="4" datatypes="Tide" timedout="" timedoutpods="" timing="2.041" parsetiming="0.159" parsetimedout="false" recalculate="" id="MSPa2841c605802big7c5h700001bi6h0g908bch9ei" host="http://www1.wolframalpha.com" server="13" related="http://www1.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa2851c605802big7c5h700003d89ihc926f55828&s=13" version="2.6">
<pod title="Input interpretation" scanner="Identity" id="Input" position="100" error="false" numsubpods="1">...</pod>
<pod title="Result" scanner="Tide" id="Result" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
Tuesday, February 11, 2014 | | | |
high tide | 4:06 am PST (4 h 10 min ago) | +11 feet | | | | | |
low tide | 9:32 am PST (1 h 16 min from now) | +6.7 feet | | | | | |
high tide | 2:10 pm PST (5 h 55 min from now) | +9.9 feet | | | | | |
low tide | 8:59 pm PST | +0.5 feet | | | | | |
(computed using historical data, not taking into account weather, etc. heights relative to all-time average lowest daily tide)
</plaintext>
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP2871c605802big7c5h70000185h5d64e91gb027?MSPStoreType=image/gif&s=13" alt=" ... " title=" ... " width="400" height="326"/>
</subpod>
<states count="5">...</states>
<infos count="1">...</infos>
</pod>
<pod title="Averages" scanner="Tide" id="Averages" position="300" error="false" numsubpods="1">...</pod>
<pod title="Tide measurement station" scanner="Tide" id="TideMeasurementStation" position="400" error="false" numsubpods="1">...</pod>
<assumptions count="1">...</assumptions>
</queryresult>
Pod Selection
It is often the case that applications using the Full Results API are not interested in the complete set of pods returned for a given query. For example, if you are writing an application that wants to acquire weather information from Wolfram|Alpha, and you are only interested in the pod that displays the table of current weather conditions, you need a way to ask the API to return only that pod. Because Wolfram|Alpha has much less work to do to generate only that one pod, this query will execute much more quickly than getting all the pods and picking out the one you want yourself.
The following sections describe various parameters that you can use to control the set of pods returned for a given query. These parameters can be used together in the same query, in which case a pod will be included in the result if it meets any (not necessarily all) of the included specifications.
The most robust way to identify an individual pod is by its ID, which is given by its id attribute. Because the title parameter can vary in its wording (which may include time, location or other query-specific information), it is not effective at identifying pods by general content. Similarly, the index parameter may change from query to query or as the API is updated, reducing its usefulness in broader contexts. Using the pod ID ensures consistent output for a category of queries.
You can choose to include or exclude pods based on their IDs. The URL parameters for these actions are includepodid and excludepodid. Let's say that you have a weather application, and you want to display the pod that gives current weather information for a given location. Here is what that pod looks like for the query "weather Chicago" (with some elements collapsed for brevity):
<pod title="Latest recorded weather for Chicago, Illinois" scanner="Data" id="InstantaneousWeather:WeatherData" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
temperature | 73 \u005c[Degree]F (wind chill: 73 \u005c[Degree]F)
conditions | partly cloudy
relative humidity | 29% (dew point: 39 \u005c[Degree]F)
wind speed | 17 mph (51 minutes ago)
</plaintext>
<img ... />
</subpod>
<states count="2">...</states>
<infos count="1">...</infos>
</pod>
The title includes the name of the city, but the ID is a logical description of the contents of the pod. If you wanted Wolfram|Alpha to return only this one pod, you would use the includepodid parameter like this:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=weather+Chicago&includepodid=InstantaneousWeather:WeatherData
Similarly, if you wanted to include all the pods except for this one, you would use the excludepodid parameter. You can include or exclude multiple pods by specifying more than one instance of either parameter. However, you cannot mix includepodid and excludepodid in one query, as this is not a meaningful operation.
You can also choose to identify pods by their titles. The title is the text that appears in the upper-left corner of each pod. Note that the trailing colon is not part of the title. The podtitle parameter allows you to specify one or more pod titles to include; any pods that do not have matching titles will be excluded. You can specify a specific title or match a class of titles by using "*" as a wildcard that matches zero or more characters. To specify more than one title, use multiple podtitle parameters. For example, this query requests two pods: the one titled "Weather station information", and the one that begins with "Latest recorded weather" (using a wildcard to match the rest of the title because it ends with the requested location, which may change from query to query).
http://api.wolframalpha.com/v2/query?appid=DEMO&input=weather+Chicago&podtitle=Weather+station+information&podtitle=Latest+recorded+weather*
Another way to specify pods is by their indices (podindex). The index is an incremental count representing the order in which pods were computed by Wolfram|Alpha, starting at 1. It corresponds to the top-to-bottom ordering of pods on the website and in the XML returned by the API. You can specify a single pod or several pods. For example, podindex=2 requests only the second pod, and podindex=1,2,4 requests those three specific pods.
Pod indices are not a very stable way to identify specific pods, as ordering of pods in Wolfram|Alpha can change over time as new pod types are created or existing ones are promoted or demoted in importance. The first pod gives the input interpretation, but after that the output is likely to change over time. Additionally, pod indices are not explicitly stated in the XML output, making it difficult to track what pods should be returned for a given query. Using pod indices is good when you just want to say something like, "Give me whatever Wolfram|Alpha thinks are the five most important pods."
If you are using the podtimeout parameter, it is important to note that the index numbers are decided at the close of the "scan" stage. The culling of pods based on index is done before the later format stage, so pods that are dropped because they time out in formatting have no bearing on the index numbers.
Each pod is produced by a software component called a scanner. There are many scanners in Wolfram|Alpha, each one corresponding roughly to a subject area or data type. The <pod> element has a scanner attribute that shows the name of the scanner that produced it, and this name is a guide to the type of content that the pod contains. You can use the scanner parameter to include only pods generated by one or more specific scanners. To specify more than one scanner, you can either use commas to separate names, such as scanner=Numeric,MathematicalFunctionData, or multiple scanner specifications, like scanner=Numeric&scanner=MathematicalFunctionData.
Formatting Output
The Output Parameter
By default, the Full Results API returns an XML document with individual elements representing the different parts of a Wolfram|Alpha result. Using the output parameter, you can tell the API to return a JSON result instead:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=tides%20seattle&output=json
Here is the "Result" pod from this query:
{
"title" : "Result",
"scanner" : "Tide",
"id" : "Result",
"position" : 200,
"error" : false,
"numsubpods" : 1,
"primary" : true,
"subpods" : [
{ ... }
]
}
Note that this parameter only changes the web format of the result; all pods have the same output elements and values regardless of which setting you use.
The Format Parameter
To change the output format of a pod or pods, use the format parameter in your URL. Not all results are available in all the formats listed below; the parameter will apply itself to any pods that allow the specified format. Multiple format options can be used in the same URL, separated by commas, and each applicable option will display in the result.
The image format option gives you the same types of GIF images as seen on the Wolfram|Alpha site. Each subpod is returned as an HTML <img> tag ready for direct inclusion in a webpage:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=tides%20seattle&&format=image
In some cases, JPEG images are returned instead of GIF. The filename in the <img> URL will tell you whether it is GIF or JPEG. The image below shows the "Result" pod that is returned from the "tides Seattle" query, with the image URL highlighted:
<pod title="Result" scanner="Tide" id="Result" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP2251baf4ff97adai0b200001b128d6ace53249f?MSPStoreType=image/gif&s=14"
alt=" Tuesday, November 3, 2015 | | | | low tide ... lowest daily tide)"
width="400" height="366"/>
</subpod>
<states count="5">...</states>
<infos count="1">...</infos>
</pod>
Loading this URL (or embedding the <img> tag in an HTML document) gives you back the exact image that would normally be displayed inside that pod:
The HTML alt text for the image is usually the same text returned by using the plaintext format option.
Many pods on the Wolfram|Alpha website have HTML image maps associated with them so that you can click parts of the pod image to execute queries. Most table-style pods have this property, so that each element in the table or list can be clicked to trigger a query based on the content of that item. This is useful for dynamic visual elements with different parts that can be clicked to trigger another query. The API provides information that you can use to replicate this "image map" functionality in your own programs.
We will use the "France" query as an example. To get image map data in the result, you need to include imagemap as a format type (in addition to image):
http://api.wolframalpha.com/v2/query?appid=DEMO&input=france&format=image,imagemap
For reference, here is the "Name" pod on the website, with the links highlighted as they are when the mouse is hovering over the pod:
This is what the "Name" pod looks like in the API result from the above query:
<pod title='Name'
scanner='Data' id='Identifiers:CountryData' position='200'
error='false' numsubpods='1'>
<subpod title=''>
<img src='http://www1.wolframalpha.com/Calculate/MSP/MSP93ff?MSStoreType=image/gif'
alt='full name | French Republic
full native name | République française
internet code | .fr'
title='full name | French Republic
full native name | République française
internet code | .fr'
width='294' height='106' />
<imagemap>
<rect left='12' top='8' right='39' bottom='28'
query='France+full+name'
assumptions='ClashPrefs_*Country.France.CountryProperty.FullName-'
title='France full name' />
<rect left='39' top='8' right='76' bottom='28'
query='France+full+name'
assumptions='ClashPrefs_*Country.France.CountryProperty.FullName-'
title='France full name' />
<rect left='12' top='42' right='39' bottom='62'
query='France+full+native+name'
assumptions='ClashPrefs_*Country.France.CountryProperty.FullNativeNames-'
title='France full native name' />
<rect left='39' top='42' right='83' bottom='62'
query='France+full+native+name'
assumptions='ClashPrefs_*Country.France.CountryProperty.FullNativeNames-'
title='France full native name' />
<rect left='83' top='42' right='120' bottom='62'
query='France+full+native+name'
assumptions='ClashPrefs_*Country.France.CountryProperty.FullNativeNames-'
title='France full native name' />
<rect left='12' top='76' right='68' bottom='96'
query='France+internet+code'
assumptions='ClashPrefs_*Country.France.CountryProperty.InternetCode-'
title='France internet code' />
<rect left='68' top='76' right='98' bottom='96'
query='France+internet+code'
assumptions='ClashPrefs_*Country.France.CountryProperty.InternetCode-'
title='France internet code' />
</imagemap>
</subpod>
<states count='1'>
<state name='More'
input='Identifiers:CountryData__More' />
</states>
</pod>
The <imagemap> element contains information that you can use to identify clickable areas within the pod and the queries that should be issued if those areas are clicked. Each <rect> subelement identifies a separate region. Notice that in this case, seven <rect> elements appear within the <imagemap> tag—each word in the boxes is considered a separate region. The coordinates are based on (0, 0) being the top-left corner of the pod. The query attribute gives the query input, and it is already URL encoded for direct use in a subsequent query URL. The title attribute is a text string that shows the query in a readable form, which you might want to display as a tooltip when the mouse hovers over the region.
The assumptions attribute gives a value you would include in the query to ensure that it is interpreted as desired. For example, to simulate a user click in the region identified by the first <rect> element in the above pod, you might execute the following query:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=France+full+name&assumption=ClashPrefs_*Country.France.CountryProperty.FullName-
See the Assumptions section for more information about using assumptions to customize output.
The plaintext format option produces the text format that you see when you highlight a pod and click the "Plaintext" button on the Wolfram|Alpha site. The result is contained in the <plaintext> tag and can be extracted as-is.
<pod title="Result" scanner="Tide" id="Result" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
Tuesday, November 3, 2015 | | | |
low tide | 3:27 am PST (9 h 58 min ago) | +1.1 feet | | | | | |
high tide | 11:02 am PST (2 h 23 min ago) | +11.2 feet | | | | | |
low tide | 5:42 pm PST (4 h 17 min
from now) | +5.3 feet | | | | | |
high tide | 10:20 pm PST (8 h 54 min from now) | +7.9 feet | | | | | |
(computed using historical data, not taking into account weather, etc. heights relative to all-time average lowest daily tide)
</plaintext>
</subpod>
<states count="5">...</states>
<infos count="1">...</infos>
</pod>
You may find it difficult to write general-purpose code to analyze text in this format, so use it only if you want simple text to display to your users, or if you know the structure of the text in advance (e.g., it will be a number, a latitude-longitude pair, a table, etc.).
Some Wolfram|Alpha results are mathematical expressions or formulas that require traditional math notation to be readable (e.g. superscripts, fractions, integral signs). Presentation MathML is a W3C standard XML format for mathematics. Many browsers can render MathML (either natively or through a plugin), and it is widely used in scientific software and popular equation editors.
MathML output is provided when you request the mathml format type. The following is the "Statement" pod from the query "pythagorean theorem", using the mathml option:
<pod title="Statement" scanner="Data" id="StatementPod:FamousMathProblem" position="200" error="false" numsubpods="1">
<subpod title="">
<mathml>
<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:mathematica="http://www.wolfram.com/XML/" mathematica:form="StandardForm">
<mrow>
<mtext>For a right triangle with legs</mtext>
<mrow>
<mi>a</mi>
</mrow>
<mtext>and</mtext>
<mrow>
<mi>b</mi>
</mrow>
<mtext>and hypotenuse</mtext>
<mrow>
<mrow>
<mi>c</mi>
</mrow>
<mtext>,</mtext>
</mrow>
<mrow>
<mrow>
<mrow>
<mrow>
<msup>
<mi>a</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<msup>
<mi>b</mi>
<mn>2</mn>
</msup>
</mrow>
<mo>=</mo>
<msup>
<mi>c</mi>
<mn>2</mn>
</msup>
</mrow>
</mrow>
<mo>.</mo>
</mrow>
</mrow>
</math>
</mathml>
</subpod>
</pod>
When the MathML output (enclosed in the <math> tag) is parsed in a web document, it displays clean, formatted mathematical text:
For a right triangle with legs a and b and hypotenuse c, a2+b2=(c2).
Some pods have sounds associated with them. Using the sound format type will return audio data as either "audio/midi" (MIDI format) or "audio/x-wav" (WAV format), depending on the nature of the result.
http://api.wolframalpha.com/v2/query?appid=DEMO&input=C+major&podtitle=Music+notation&format=sound
<pod title="Music notation" scanner="Music" id="MusicNotation" position="300" error="false" numsubpods="0">
<sounds count="1">
<sound url="http://www1.wolframalpha.com/Calculate/MSP/MSP3831c605804acbi0aeb000016c4402g20b8c038?MSPStoreType=audio/midi&s=13" type="audio/midi"/>
</sounds>
</pod>
The MIME type is specified within the <sound> tag; in this case, the output is a MIDI object. As with the image format type, the highlighted link leads directly to an audio file that can be embedded into an HTML page using the <sound> tag. Note that the sound format will only provide output for queries that generate a sound as part of their natural output—it will not convert text or other visual formats to audio.
For programs that can only handle WAV sounds, the wav format type returns audio data as an uncompressed audio file. Here is the result of using the wav option on the same query as above:
<pod title="Music notation" scanner="Music" id="MusicNotation" position="300" error="false" numsubpods="0">
<sounds count="1">
<sound url="http://www1.wolframalpha.com/Calculate/MSP/MSP731g35g30d3e5h09e600005bhcec0af7cf0g5e?MSPStoreType=audio/x-wav&s=12" type="audio/x-wav"/>
</sounds>
</pod>
The pod is nearly identical, except that the audio type has changed to "audio/x-wav". This format type is a more robust way to retrieve sounds, since the WAV format is understood by most platforms. As with the sound format, this will not convert text or other visual formats to audio.
This is the text format that you see in the "Wolfram Language plaintext input" popup that appears when you click some results on the Wolfram|Alpha site. Some results can be generated directly by single Wolfram Language input expressions. For example, the "Continued fraction" pod in the Wolfram|Alpha result for the query "pi" has a Wolfram Language input representation of ContinuedFraction[Pi, 27]. Use the minput option to get this type of result. This can be useful if you want to feed the input into Wolfram Language code for manipulating results:
<pod title="Continued fraction" scanner="ContinuedFraction" id="ContinuedFraction" position="500" error="false" numsubpods="1">
<subpod title="">
<minput>ContinuedFraction[Pi, 27]</minput>
</subpod>
<states count="2">...</states>
</pod>
Using the moutput option returns the text format that you see in the "Wolfram Language plaintext output" popup that appears when you click some results on the Wolfram|Alpha site. This format is not available for all results, and it will sometimes be large (e.g. for mathematical plots), or not very useful (e.g. when the original source data is only available to the Wolfram Language as a raster image, such as a country's flag). The first formula in the "Continued fraction" pod in the Wolfram|Alpha output for the query "pi" has a Wolfram Language output representation of {3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, 3}. This can be useful if you want to feed the output into a Wolfram Language environment:
<pod title="Continued fraction" scanner="ContinuedFraction" id="ContinuedFraction" position="100" error="false" numsubpods="1">
<subpod title="">
<moutput>
{3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, 3}
</moutput>
</subpod>
<states count="2">...</states>
</pod>
Note that the results from the minput type will evaluate directly to the results from the moutput type when entered in a Wolfram Language environment.
In[1]:= ContinuedFraction[Pi, 27]
Out[1]= {3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, 3}
The cell format type returns Wolfram Language Cell expressions. These are the same cells rendered by Wolfram|Alpha to produce the pod images you see on the website. Here is the cell output of the same pod from the "pi" query, with the Wolfram Language Cell expression highlighted:
<pod title="Continued fraction" scanner="ContinuedFraction" id="ContinuedFraction" position="500" error="false" numsubpods="1">
<subpod title="">
<cell compressed="false">
<![CDATA[
Cell[BoxData[FormBox[TagBox[GridBox[List[List[TemplateBox[List["\\"[\\"", "\\"
3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15,\\"", "\\" \\[Ellipsis]]\\""],
"RowDefault"]]], Rule[GridBoxAlignment, List[Rule["Columns", List[List[Left]]]]],
Rule[DefaultBaseStyle, "Column"], Rule[GridBoxItemSize, List[Rule["Columns", List[List[Scaled[1.003`]]]]]]], "Column"],
TraditionalForm]], "Output", List[], Rule[PageWidth, 500], Rule[Magnification, 1], Rule[CellMargins, List[List[0, 0], List[0, 0]]],
Rule[ShowCellBracket, False], Rule[FontFamily, "Bitstream Charter"], Rule[FontSize, 14], Rule[NumberSeparator, "\\[ThinSpace]"]]
]]>
</cell>
</subpod>
<states count="2">...</states>
</pod>
Although it can be cumbersome to look at, this cell statement is interpreted by the Wolfram Language to provide a parsed version of the pod content. In this particular case, the cell returned (when processed as a Wolfram Language statement) is essentially the plaintext result with added formatting:
[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, 3, 13, ...]
The Wolfram Language has rich, direct integration with Wolfram|Alpha, using the API internally to process these cell expressions. If for any reason you want to obtain them outside of the Wolfram Language, you can request the cell format type.
Controlling the Width of Results
Wolfram|Alpha formats pod images to a default maximum width of 500 pixels. If you want to change this width, such as for a small mobile device screen, the API provides four parameters you can use. The width and maxwidth parameters apply to images of text and tables, which are the majority of Wolfram|Alpha output, whereas plotwidth only applies to plots and other graphics. You can use the mag parameter to change the size of a pod's content without changing the size of the pod. It's important to note that these values are approximate, and the result of using these parameters may vary for different query types.
The width parameter specifies a "hard limit" on the width of text and table elements. An easy way to see the effect of the width parameter is to look at the "Decimal approximation" pod from the "pi" query. Here is that pod when the width parameter is not specified:
<pod title="Decimal approximation" scanner="Numeric" id="DecimalApproximation" position="100" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
3.1415926535897932384626433832795028841971693993751058...
</plaintext>
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP291g37i75c7bh16e7b0000698324f506ghc9c5?MSPStoreType=image/gif&s=12"
alt="3.1415926535897932384626433832795028841971693993751058..."
title="3.1415926535897932384626433832795028841971693993751058..."
width="443" height="20"/>
</subpod>
<states count="1">...</states>
</pod>
The number of digits shown in the plaintext representation is chosen so as to fit within a width of 500 pixels, and you can see that the width attribute of the <img> element shows that the rendered image is 443 pixels wide. If we try this query again and add the parameter width=250, here is the new pod:
<pod title="Decimal approximation" scanner="Numeric" id="DecimalApproximation" position="100" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
3.1415926535897932384626433832795028841971693993751058...
</plaintext>
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP141g37i758a591379d00006ac21dae92c98172?MSPStoreType=image/gif&s=12"
alt="3.141592653589793238462643..."
title="3.141592653589793238462643..."
width="219" height="20"/>
</subpod>
<states count="1">...</states>
</pod>
With this smaller width requested, Wolfram|Alpha displays fewer digits, and the new image width is 219 pixels. This option works well for single-element or plain text results, since Wolfram|Alpha can choose to truncate the output. However, for more complex output, requesting a specific width can force elements to be displayed in an undesirable way (e.g. mid-expression line breaks, awkward vertical spacing, etc.).
The maxwidth parameter allows users of the API to adopt a two-part strategy for controlling width. You can specify a desired width using the width parameter, but if you also specify a higher maxwidth value, then when Wolfram|Alpha formats results to the width value, it will attempt to detect undesirable line breaks and automatically reformat to your larger maxwidth. In other words, using width and maxwidth together lets you tell the API, "Please format text and tables to a certain width, but if this is going to look really ugly, I'd rather have it formatted at a higher width instead."
Consider the effect of using this strategy on the "Doppler shift" query. If you wanted most output to be limited to 100 pixels but you realized that some elements would display poorly this way, you might set a maxwidth of 200.
The plotwidth parameter controls the width at which plots and graphics are rendered. The default value is 200 pixels. Many graphics in Wolfram|Alpha are deliberately rendered at larger sizes to accommodate their content. Specifying plotwidth is currently an experimental feature that does not yet affect many type of graphics.
The mag parameter controls the magnification of pod images. The default value is 1.0, meaning no magnification. Magnification does not affect the pixel width of images, so if you specify a width parameter or accept the default of 500 pixels, images will still come back at that size if you specify a magnification value. For instance, if you specify mag=2.0, then the pod image is formatted to a width of half the requested width (say, 250 pixels) and then blown up by a factor of 2 during rendering, to 500 pixels. This option is useful for displaying image elements like font sizes, tick marks, line-wrapping and spacing on high-density screens (e.g. tablets or mobile phones). Since such elements can be very sensitive to formatting width, they may fit on a screen but be too small to read or interpret; magnification can "blow up" an image without changing its absolute size.
For instance, suppose you wanted to display the "Averages" pod from the "tides Seattle" query on a small vertical screen. Without any size parameters, this table is wider than it is tall:
This would be okay for a normal wide screen, but shrinking it to fit on a vertical screen would make the text too small to read. Combining the mag and width parameters (in this case, "mag=2" and "width=400"), you can increase the size of the text without changing the absolute width of the table:
Specifying Your Location
Many queries return results that depend on your current location. A query about weather conditions, for example, needs to know the caller's location, and a mortgage computation wants to present results in the local currency. By default, Wolfram|Alpha attempts to determine the caller's location from the IP address, but you can override this by specifying location information in one of the three forms listed.
Note that the units used in query results are altered by these location parameters. See the Unit Assumption subsection in the Applying Assumptions section for more information on changing units.
Semantic Location
The location parameter lets you specify a string like "Los Angeles, CA" or "Madrid" to be semantically interpreted as a location. This is essentially the same as calling the Wolfram Language's Interpreter function and using the first result as the location for the query.
Latitude and Longitude
The latlong parameter lets you specify a latitude/longitude pair like "40.42,-3.71". Negative latitude values are south, and negative longitude values are west. Although this is the most exact way to specify a location, it will fail if no valid data is available nearby for the query.
IP Address
The ip parameter lets you set the IP address of the caller, which will be used to determine a location. With this parameter, if you are forwarding calls from your own web visitors to the Full Results API, you can propagate their IP addresses.
Combining Location Parameters
You can include multiple location parameters in your query, and they will be evaluated in order of precedence (location → latlong → ip) until a valid location is found. In this way, you can use extra location parameters as "backups" in case the initial specification fails. For instance, if you were executing a "weather" query using a location string, you might also want to include a default latitude/longitude location in case the given string is invalid:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=weather&format=image&location=the+moon&latlong=51.5,-0.1167
In this case, Wolfram|Alpha will attempt to parse the location string first. Since "the Moon" is not a valid location for a weather query, the given latitude/longitude will be used instead.
Informational Elements
Information
Some pods on the Wolfram|Alpha website have text buttons in their lower-right corners that provide extra information about the contents of that pod. In the results from the "tides Seattle" query, the "Tide measurement" pod has buttons titled "Satellite image" and "Units". Clicking these types of buttons will cause either a popup window or a new browser window to appear with more information about the request:
The data for these informational links is available in the API via the <infos> element, which appears inside any <pod> elements for which information links are available. Here is the <infos> XML element from this query:
<pod title="Tide measurement station" scanner="Tide" id="TideMeasurementStation" position="400" error="false" numsubpods="1">
<subpod title="">...</subpod>
<states count="2">...</states>
<infos count="2">
<info>
<units count="1">
<unit short="mi" long="miles"/>
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP1231c61gh85106867i900006848e4e79bchdi50?MSPStoreType=image/gif&s=13" width="88" height="26"/>
</units>
</info>
<info>
<link url="http://maps.google.com?ie=UTF8&z=17&t=k&ll=47.6017%2C-122.338&q=47.6017%20N%2C%20122.338%20W" text="Satellite image"/>
</info>
</infos>
</pod>
The content of the <infos> element is always one or more <info> elements. Each <info> element represents one piece of information about the contents of the pod. In some cases, these bits of information are formatted as separate lines on the website (as shown above), and in other cases they are placed together on a single line separated by a vertical bar.
Here is another example of an <infos> element. This is the "Alternative representations" pod for the "pi" query:
<infos count="4">
<info text="log(x) is the natural logarithm">
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP1171bagf712c7721c3i000014840g8d3116fgd4?MSPStoreType=image/gif&s=14"
alt="log(x) is the natural logarithm"
title="log(x) is the natural logarithm"
width="198" height="18"/>
<link url="http://reference.wolfram.com/mathematica/ref/Log.html" text="Documentation" title="Mathematica"/>
<link url="http://functions.wolfram.com/ElementaryFunctions/Log" text="Properties" title="Wolfram Functions Site"/>
<link url="http://mathworld.wolfram.com/NaturalLogarithm.html" text="Definition" title="MathWorld"/>
</info>
<info text="i is the imaginary unit">
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP1181bagf712c7721c3i00005a6fh9g2b203976h?MSPStoreType=image/gif&s=14"
alt="i is the imaginary unit"
title="i is the imaginary unit"
width="146" height="18"/>
<link url="http://reference.wolfram.com/mathematica/ref/I.html" text="Documentation" title="Documentation"/>
<link url="http://mathworld.wolfram.com/i.html" text="Definition" title="MathWorld"/>
</info>
<info text="cos^(-1)(x) is the inverse cosine function">
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP1191bagf712c7721c3i0000395b11i0377aigfh?MSPStoreType=image/gif&s=14"
alt="cos^(-1)(x) is the inverse cosine function"
title="cos^(-1)(x) is the inverse cosine function"
width="275" height="18"/>
<link url="http://reference.wolfram.com/mathematica/ref/ArcCos.html" text="Documentation" title="Mathematica"/>
<link url="http://functions.wolfram.com/ElementaryFunctions/ArcCos" text="Properties" title="Wolfram Functions Site"/>
<link url="http://mathworld.wolfram.com/InverseCosine.html" text="Definition" title="MathWorld"/>
</info>
<info>
<link url="http://functions.wolfram.com/Constants/Pi/27/ShowAll.html" text="More information"/>
</info>
</infos>
If you do that query on the website, you will see four info lines for that pod, the first three of which are text followed by several mouseover links:
The content on the <info> element varies. In some cases, there is a text attribute that gives a string of textual information that is not intended to be a link in itself. The possible subelements are:
Used when the item is just a standard link of some text pointing to a URL, like in the "Satellite image" link in the result above, or the common "More information" link pointing to a MathWorld page. The <link> element contains a url attribute giving the URL containing the referenced information, a text attribute giving a textual name for the link (the website uses this as the text of the link itself) and in some cases a title attribute (used by the website as a popup when the mouse hovers over the link).
Used when the link is a popup window showing a table of unit abbreviations used in the pod alongside their long names. The tides example above shows an unusual case where the table has only one row. Each row is represented as a <unit> element giving the short and long names of the unit. Wolfram|Alpha creates nicely rendered images of these units tables, so there is also an <img> element that points to the URL for the image of the entire table if you want to show your users a picture.
Some info lines contain descriptive text along with one or more links. The text is provided in the text attribute of the <info> element, but often the text contains a mathematical symbol or nomenclature that looks best when displayed as a typeset image. The <img> element contains a link to an image of the text. This is the same image that is displayed on the website.
Sources
In the bottom section of many Wolfram|Alpha results is a link titled "Sources". On the website this displays a popup window listing information about data sources that were either used to compute the result or could be referenced for more information. Here is the expanded "Sources" element for the "tides Seattle" query:
The API returns this information inside the <sources> element. The <sources> element contains a series of <source> subelements, each one defining a link to a webpage of source information:
<sources count="2">
<source url="http://www.wolframalpha.com/sources/CityDataSourceInformationNotes.html" text="City data"/>
<source url="http://www.wolframalpha.com/sources/TideDataSourceInformationNotes.html" text="Tide data"/>
</sources>
Source information is not always present, such as for a purely mathematical computation.
Generalizations
For some types of queries, Wolfram|Alpha decides that although it can provide some results for the precise query that was given, there is a "generalization" of the query for which more information can be provided. In these cases, it reports the suggested generalized query via the <generalization> element. Queries that produce this element are relatively rare. An example is "price of copernicium": if you try this query on the website, you will see that it displays the two pods available for "price of copernicium", then a separator that reads "General results for: copernicium", followed by the pods generated by the "copernicium" query:
The query returns two small pods, but suggests the generalization "copernicium", about which much more information is available. Here is the XML result generated by sending this query to the Full Results API:
<queryresult success="true" error="false" numpods="1" datatypes="Element" timedout="" timedoutpods="" timing="1.313" parsetiming="0.259" parsetimedout="false" recalculate="" id="MSPa641c6749c3894adgef000045hg0hc62e590bf6" host="http://www1.wolframalpha.com" server="13" version="2.6">
<pod title="Input interpretation" scanner="Identity" id="Input" position="100" error="false" numsubpods="1">...</pod>
<sources count="1">...</sources>
<generalization topic="copernicium" desc="General results for:" url="http://www1.wolframalpha.com/api/v2/query?id=MSPa671c6749c3894adgef0000469f1ii4h3ca513c&s=13"/>
</queryresult>
If you want to display the extra results available for that query or give users a chance to click something to request them, you can get the pods from the generalized query by calling the URL given in the url attribute (highlighted above). Note that you must append your own AppID to this URL:
http://www1.wolframalpha.com/api/v2/query?id=MSPa1431c67498dg069cdf700004e52c8i1e6fbe3b0&s=13&appid=DEMO
What comes back is a standard <queryresult> element with results from the "copernicium" query. Using the URL provided is faster than simply issuing a new query for "copernicium", since the work of parsing the query has already been performed.
Primary Result Tagging
Although Wolfram|Alpha returns many pods for most queries, there is sometimes the notion of a "primary result" for a given query. This is especially true for queries that correspond to Wolfram Language computations (e.g. "2+2") or simple data lookups (e.g. "France GDP"). If you are looking to display the closest thing to a simple "answer" that Wolfram|Alpha can provide, you can look for pods tagged as primary results via the primary=true attribute. Here is an example—the "Result" pod from the query "France GDP":
<pod title="Result" scanner="Data" id="Result" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
$2.829 trillion per year (world rank: 6th) (2014 estimate)
</plaintext>
<img src= ... />
</subpod>
</pod>
Primary result tagging is a relatively new feature in Wolfram|Alpha, and many queries do not have a primary result, often because it is not meaningful for that query.
Pod States
Many pods on the Wolfram|Alpha website have text buttons in their upper-right corners that substitute the contents of that pod with a modified version (a different state). Clicking any of these buttons will recompute just that one pod to display different information. The API returns information about these pod states and allows you to programmatically invoke them (similar to applying assumptions, described later).
A simple example is the query "pi", which returns a pod titled "Decimal approximation" with a button named "More digits". A website user can click this button to replace the pod with a new one showing more digits of pi:
Here is what that pod looks like in the API result:
<pod title="Decimal approximation" scanner="Numeric" id="DecimalApproximation" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>
3.1415926535897932384626433832795028841971693993751058...
</plaintext>
<img ... />
</subpod>
<states count="1">
<state name="More digits" input="DecimalApproximation__More digits"/>
</states>
</pod>
The <states> element contains all the alternative states available for that pod. The name of each state is the same as the text that appears on the Wolfram|Alpha website. You can perform the "pi" query and ask that the "More digits" state be invoked automatically by using the podstate parameter, passing the value of the input attribute from the corresponding <state> element:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=pi&podstate=DecimalApproximation__More+digits
Note that the value of the input attribute in the <state> element is not URL encoded, so you will have to perform this encoding yourself when you use it. The result from the above query will be exactly as if a website user had clicked the "More digits" button (notice the difference in the plaintext output):
<pod title="Decimal approximation" scanner="Numeric" id="DecimalApproximation" position="200" error="false" numsubpods="1" primary="true">
<subpod title="">
<plaintext>3.1415926535897932384626433832795028841971693993751058...</plaintext>
<img ... />
</subpod>
<states count="2">
<state name="Fewer digits" input="DecimalApproximation__Fewer digits"/>
<state name="More digits" input="DecimalApproximation__More digits"/>
</states>
</pod>
Changing the current state of a pod may also invoke more possible states—in this case, a "Fewer digits" state is now available, along with an extended "More digits" state. State changes can be chained together to simulate any sequence of button clicks. You can simulate clicking the "More digits" button twice as follows:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=pi&podstate=DecimalApproximation__More+digits&podstate=DecimalApproximation__More+digits
When invoking the same pod state change multiple times, as in the above query, you can use a shortcut of specifying only one podstate parameter and indicating the multiplicity by prepending "n@". For example, the following query invokes the "More digits" state twice, exactly like the previous example:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=pi&podstate=2@DecimalApproximation__More+digits
Some states are logically grouped into sets, which are represented on the website as popup menus. For example, the "Weather history and forecast" pod from the query "weather" shows some charts along with a popup menu that controls the time period (it has values like "Current week", "Last month", etc.) This type of state control is represented with the <statelist> element. Here is the <states> element in the API result for that pod. Note that this pod has two other button-type states ("Show metric" and "More"):
<states count="3">
<statelist count="9" value="Current week" delimiters="">
<state name="Current week" input="WeatherCharts:WeatherData__Current week"/>
<state name="Current day" input="WeatherCharts:WeatherData__Current day"/>
<state name="Next week" input="WeatherCharts:WeatherData__Next week"/>
<state name="Past week" input="WeatherCharts:WeatherData__Past week"/>
<state name="Past month" input="WeatherCharts:WeatherData__Past month"/>
<state name="Past year" input="WeatherCharts:WeatherData__Past year"/>
<state name="Past 5 years" input="WeatherCharts:WeatherData__Past 5 years"/>
<state name="Past 10 years" input="WeatherCharts:WeatherData__Past 10 years"/>
<state name="All" input="WeatherCharts:WeatherData__All"/>
</statelist>
<state name="Show metric" input="WeatherCharts:WeatherData__Show metric"/>
<state name="More" input="WeatherCharts:WeatherData__More"/>
</states>
The value attribute of the <statelist> element names the state that is currently in effect. To request that this pod show data for the last five years, you would use this URL:
http://api.wolframalpha.com/v2/query?input=weather&appid=DEMO&podstate=WeatherCharts:WeatherData__Past+5+years
Subpod States
Most podstate changes are for entire pods, but a few Wolfram|Alpha queries have podstate changes at the subpod level. An example of one such query is "inductance of a circular coil". On the website, the third pod is titled "Self-inductance of a single-layer circular coil of small radius", and it has two subpods. The second one is called "Result", and it has a podstate button called "Show formula":
You can see by the position and behavior of this button that it only modifies the "Result" subpod, not the entire pod. In the API, each such subpod has its own <states> element. Here is the XML for that pod:
<pod title="Self-inductance of a single-layer circular coil" scanner="Formula" id="SelfInductanceSingleLayerCircularCoil" position="300" error="false" numsubpods="2">
<subpod title="Input values">
<plaintext>
coil turns | 10
coil radius | 1 cm (centimeter)
coil length | 20 cm (centimeters)
</plaintext>
<img src= ... />
</subpod>
<subpod title="Result">
<plaintext>
self-inductance | 189.3 nH (nanohenries)
= 0.1893 muH (microhenries)
= 1.893*10^-7 H (henries)
</plaintext>
<img src= ... />
<states count="1">
<state name="Show formula" input="SelfInductanceSingleLayerCircularCoil__Result_Show formula"/>
</states>
</subpod>
</pod>
You can see that the <states> element is a subelement of <subpod>, not <pod>. To invoke this podstate change, you use it like any other podstate:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=weather&podstate=Self-inductanceOfASingle-layerCircularCoil__Result _Show+formula
The result would have a third pod in which only the Result subpod was modified compared to the original query.
Note: In previous versions of the API, there was no input attribute in the <state> element, and the value passed for the podstate parameter was just the name of the state (e.g. "More digits"). This is still supported, but it has the drawback that state changes cannot be invoked on a per-pod basis, so any pod with a "More digits" state would have it invoked, not just the "Decimal approximation" pod. Using the value of the input attribute will restrict the state change to a specific pod, and is the preferred form.
Using Assumptions
Wolfram|Alpha makes numerous assumptions when analyzing a query and deciding how to present its results. A simple example is a word that can refer to multiple things, like "pi", which is a well-known mathematical constant but is also the name of a movie. Other classes of assumptions are the meaning of a unit abbreviation like "m", which could be meters or minutes, or the default value of a variable in a formula, or whether 12/13/2001 is a date or a computation. Using the API, you can programmatically invoke these assumption values to alter the output of a query (similar to pod states, described above).
Listing of Assumption Types
This is a complete listing of possible assumptions, categorized by functionality. Each assumption name links to a more in-depth explanation of the parameter, its usage and available options.
- Categorical assumptions
- Clash — choose among possible interpretation categories for a query (e.g. "pi" could be a named constant or a movie)
- MultiClash — choose among possible interpretation categories for in Structure of Assumptions dividual words in a query (e.g. in "log 0.5", "log" could be a PDF or a plotting function)
- SubCategory — choose among similar results within the same interpretation category (e.g. "hamburger" could be a basic hamburger, McDonald's hamburger, etc.)
- Attribute — choose specific traits of results within a SubCategory (e.g. for a "basic hamburger" you can specify patty size, condiments, etc.)
- Mathematical assumptions
- Unit — choose among possible interpretations of a query as a unit of measure (e.g. "m" could be meters or minutes)
- AngleUnit — choose whether to interpret angles in degrees or radians (e.g. "sin(30)" could be 30 degrees or 30 radians)
- Function — choose among possible interpretations of a query as a mathematical function (e.g. "log" could be the natural logarithm or the base 10 logarithm)
- ListOrTimes — choose whether to interpret space-separated elements as a list of items or as multiplication (e.g. "3 x" could be {3, x} or 3×x)
- ListOrNumber — choose whether to treat commas between numbers as thousands separators or list delimiters (e.g. "1,234.5" could be 1234.5 or {1, 234.5})
- CoordinateSystem — choose which coordinate system to use, given an ambiguous query (e.g. "div(x rho, y z, z x)" could refer to Cartesian3D or Cylindrical3D)
- I — choose whether to interpret "i" as a variable or as the imaginary unit (e.g. "5x+3i" could be a complex number with one variable or an expression with two variables)
- NumberBase — choose which number base to use, given an ambiguous query (e.g. "100110101" could be binary or decimal)
- MixedFraction — choose whether to interpret input as a mixed fraction or as multiplication (e.g. "3 1/2" could be 3½ or 3×½)
- Date and time assumptions
- TimeAMOrPM — choose whether a time is in the morning or the afternoon (e.g. "3:00" could be 3am or 3pm)
- DateOrder — choose the order of day, year and month elements in a date (e.g. "12/11/1996" could be Dec. 11, 1996, or Nov. 12, 1996)
- MortalityYearDOB — choose whether a mortality rate refers to a data year or a birth year (e.g. "life expectancy France 1910" could refer to statistics from 1910 or those for people born in 1910)
- Scientific assumptions
- TideStation — choose among tide stations in a tide query (e.g. "tides Seattle" could use Seattle, Bangor or Tacoma tide stations as a source)
- Formula input assumptions
- FormulaSelect — choose among possible interpretations of a query as a mathematical formula (e.g. "Doppler shift" can refer to either the classical or relativistic Doppler shift)
- FormulaSolve — choose which value to solve for in a formula (e.g. solving for sound speed in the Doppler shift formula)
- FormulaVariable — supply a non-default value to a specific variable in a formula (e.g. give the "Doppler shift" query a source speed of 30 m/s)
- FormulaVariableOption — choose among different representations of a variable or variables in a formula (e.g. the Doppler shift formula can split the frequency reduction factor into source and observed frequencies)
- FormulaVariableInclude — choose extra variables to include in a formula (e.g. "Doppler shift" can also include the observer's speed and wind speed)