### Response Example (XML) Source: https://products.wolframalpha.com/api/documentation?scrollTo=result-examplepage An example of the XML output returned by a successful query. ```APIDOC ## Response Example (XML) ### Description This is a sample XML response for the query 'population of France'. It contains various pods with information related to the query. ### Response #### Success Response (200 OK) - **queryresult** (object) - Contains the results of the query. - **success** (boolean) - Indicates if the query was successful. - **error** (boolean) - Indicates if an error occurred. - **numpods** (integer) - The number of pods returned. - **pod** (array) - An array of pod objects, each containing information related to a specific aspect of the query. - **title** (string) - The title of the pod. - **id** (string) - The unique identifier for the pod. - **position** (integer) - The display position of the pod. - **subpod** (array) - An array of subpod objects within the pod. - **plaintext** (string) - Plain text representation of the subpod content. - **img** (object) - Image representation of the subpod content. - **src** (string) - URL of the image. - **alt** (string) - Alt text for the image. - **title** (string) - Title for the image. - **width** (integer) - Width of the image. - **height** (integer) - Height of the image. ``` -------------------------------- ### Example Query Construction Source: https://products.wolframalpha.com/api/documentation?scrollTo=xml-result-elements Examples of how to construct a query URL with the required AppID and input parameters. ```APIDOC ## Example Query URLs ### Description Demonstrates how to format the query URL with the `appid` and `input` parameters. ### Code Examples **Using a DEMO AppID:** ``` http://api.wolframalpha.com/v2/query?appid=DEMO ``` **Querying for "population of France":** ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ``` -------------------------------- ### Query Function Example Source: https://products.wolframalpha.com/api/documentation?scrollTo=assumption-FormulaSelect An example of a URL that calls the query function to get information about 'mortgage'. ```APIDOC ## Query Function ### Endpoint http://api.wolframalpha.com/v2/query?input=mortgage ### Description This example demonstrates how to use the query function to retrieve information about a given input. The API returns a `` tag which may contain an `` element if issues occur. ``` -------------------------------- ### Query Function Example Source: https://products.wolframalpha.com/api/documentation?scrollTo=podtimeout-async An example of a URL that calls the query function to get information about 'mortgage'. It demonstrates how errors are indicated in the response. ```APIDOC ## Query Function ### Description This function is used to retrieve information from Wolfram|Alpha based on a given input. ### Method GET ### Endpoint `/v2/query` ### Parameters #### Query Parameters - **input** (string) - Required - The query string to be processed by Wolfram|Alpha. - **appid** (string) - Required - Your Wolfram|Alpha AppID. ### Request Example `http://api.wolframalpha.com/v2/query?input=mortgage` ### Response #### Success Response (200) - **queryresult** (object) - Contains the results of the query, including success status, error information, and pod data. - **error** (object) - Present if an error occurred during the query. - **code** (integer) - The error code. - **msg** (string) - A short description of the error. #### Response Example (Error) ```xml 2 Appid missing ``` ``` -------------------------------- ### Making a Basic Query Source: https://products.wolframalpha.com/api/documentation?scrollTo=applying-formula-assumptions This example demonstrates how to construct a basic query to the Wolfram Alpha API, including the AppID and the URL-encoded input. ```APIDOC ## GET /v2/query ### Description This endpoint allows users to query Wolfram Alpha for information. It requires an AppID for authentication and an input parameter for the query itself. ### Method GET ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - Your Wolfram Alpha AppID. - **input** (string) - Required - The URL-encoded query input. ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ### Response #### Success Response (200) Returns an XML document containing the query results, including various pods with information related to the input. #### Response Example ```xml ... 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> ``` ``` -------------------------------- ### Query Function Example Source: https://products.wolframalpha.com/api/documentation?scrollTo=getting-started An example of a URL that calls the query function to get information about 'mortgage'. Errors are indicated by error=true in the <queryresult> tag. ```APIDOC ## Query Function ### Description This function retrieves information based on a given input. Errors during processing are indicated by `error=true` in the `<queryresult>` tag, with details provided in an `<error>` element. ### Endpoint `http://api.wolframalpha.com/v2/query` ### Example URL `http://api.wolframalpha.com/v2/query?input=mortgage` ### Error Response Example ```xml <queryresult success="false" error="true" numpods="0" datatypes="" timedout="" timedoutpods="" timing="0.02" parsetiming="0." parsetimedout="false" recalculate="" id="" host="http://www1.wolframalpha.com" server="13" version="2.6"> <error> <code>2</code> <msg>Appid missing</msg> </error> </queryresult> ``` ``` -------------------------------- ### Making a Sample Query Source: https://products.wolframalpha.com/api/documentation?scrollTo=handling-future-enhancements This section demonstrates how to construct a basic query to the WolframAlpha API. It outlines the base URL and the essential parameters required for a successful query. ```APIDOC ## Making a Sample Query ### Description This endpoint allows users to make queries to the WolframAlpha API to retrieve information. It requires an AppID for authentication and an input parameter for the query itself. ### Method GET ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - Your WolframAlpha AppID. - **input** (string) - Required - The URL-encoded input for your query. ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ### Response #### Success Response (200) Returns an XML document containing informational elements (pods) related to the input. The structure includes details about the query result, input interpretation, and other relevant data. #### Response Example ```xml <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> ``` ``` -------------------------------- ### Query Function Example Source: https://products.wolframalpha.com/api/documentation?scrollTo=subpod-states This example demonstrates a basic query to the Wolfram|Alpha API to get information about 'mortgage'. It shows the structure of a typical API request URL. ```APIDOC ## Query Function ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **input** (string) - Required - The input query string. - **appid** (string) - Required - Your Wolfram|Alpha AppID. ### Request Example ``` http://api.wolframalpha.com/v2/query?input=mortgage ``` ### Response Example (Error) ```xml <queryresult success="false" error="true" numpods="0" datatypes="" timedout="" timedoutpods="" timing="0.02" parsetiming="0." parsetimedout="false" recalculate="" id="" host="http://www1.wolframalpha.com" server="13" version="2.6"> <error><code>2</code> <msg>Appid missing</msg></error> </queryresult> ``` ``` -------------------------------- ### Making a Sample Query Source: https://products.wolframalpha.com/api/documentation?scrollTo=applying-assumptions This example demonstrates how to construct a URL to query the Wolfram Alpha API. It includes the base URL, the required 'appid' parameter, and the 'input' parameter for the query. The input is URL-encoded. ```APIDOC ## Making a Sample Query ### Description This endpoint allows you to make a sample query to the Wolfram Alpha API. You need to provide your AppID and the input for your query. The input should be URL-encoded. ### Method GET ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - Your Wolfram Alpha AppID. - **input** (string) - Required - The URL-encoded input for your query (e.g., "population%20of%20france"). ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ### Response #### Success Response (200) Returns an XML document containing the results of the query, organized into pods. The structure includes information about success, errors, number of pods, and timing details. #### Response Example (XML Snippet) ```xml <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> ``` ``` -------------------------------- ### Initial Query with Short Scan Timeout Source: https://products.wolframalpha.com/api/documentation?scrollTo=parameter-reference Example of an initial query to Wolfram|Alpha with a short scantimeout to get a quick set of pods. ```APIDOC ## Initial Query Example ### Description This example demonstrates how to make an initial query to the Wolfram|Alpha API with a specified short `scantimeout` to retrieve a subset of results quickly. ### Method GET ### Endpoint `/v2/query` ### Query Parameters - **appid** (string) - Required - Your Wolfram|Alpha App ID. - **input** (string) - Required - The query to be processed. - **scantimeout** (float) - Optional - The time in seconds to allow scanners to run. A shorter value results in a faster initial response but may miss some pods. ### Request Example `http://api.wolframalpha.com/v2/query?appid=DEMO&input=pi&scantimeout=1.0` ### Response Example (XML response containing pods and a `recalculate` URL if scanners timed out) ``` -------------------------------- ### Making a Sample Query Source: https://products.wolframalpha.com/api/documentation?scrollTo=assumption-FormulaSolve This snippet demonstrates how to construct a URL to query the Wolfram Alpha API. It includes the base URL, the required 'appid' parameter, and the 'input' parameter for the query. The example uses 'DEMO' as a placeholder AppID and 'population of France' as the input. ```APIDOC ## Making a Sample Query ### Description This endpoint allows you to make a sample query to the Wolfram Alpha API. You need to provide your AppID and the input for your query. ### Method GET ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - Your unique Wolfram Alpha AppID. - **input** (string) - Required - The URL-encoded input for your query. ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ### Response #### Success Response (200) The API returns an XML document containing informational elements (pods) related to the input. The structure includes a `<queryresult>` element with attributes like `success`, `error`, `numpods`, and `timing`. #### Response Example ```xml <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> ``` ``` -------------------------------- ### Asynchronous Query Example Source: https://products.wolframalpha.com/api/documentation?scrollTo=selecting-pods-by-title This example demonstrates how to use the `async=true` parameter to enable asynchronous mode for a 'weather' query. In this mode, the API returns an XML document where some pods are represented as URLs that need to be requested in a second step to get their actual XML content. ```APIDOC ## Asynchronous Mode By default, the API behaves synchronously, meaning that the entire XML document that represents the result of a query is returned as a single unit. The caller gets nothing back until the entire result is ready. By specifying `async=true`, you can tell Wolfram|Alpha to return an XML document in which some pods are represented as URLs that need to be requested in a second step to get their actual XML content. Do not confuse this with image URLs that are part of a normal result when the image format type is requested. Although the actual data in the images must be requested as a second step, the images themselves are already completely generated by the time the original XML result is returned. Here is an example using the "weather" query: ### Request ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=weather&async=true ``` This returns the following XML: ### Response Example (Partial) ```xml <queryresult success="true" error="false" numpods="3" datatypes="City,Weather" timedout="Data,Character" timedoutpods="Weather history & forecast,Historical temperatures for December 1,Weather station information" timing="4.573" parsetiming="0.09" parsetimedout="false" recalculate="http://www1.wolframalpha.com/api/v2/recalc.jsp?id=MSPa241bb3824736e9f4h600005cb57b31ibcb9f61&s=14" id="MSPa251bb3824736e9f4h6000066b50g24ci9gf998" host="http://www1.wolframalpha.com" server="14" version="2.6"> <pod title="Input interpretation" scanner="Identity" id="Input" position="100" error="false" numsubpods="1">...</pod> <pod title="Latest recorded weather for Champaign, Illinois" scanner="Data" id="InstantaneousWeather:WeatherData" position="200" error="false" numsubpods="1" primary="true">...</pod> <pod title="Weather forecast for Champaign, Illinois" scanner="Data" id="WeatherForecast:WeatherData" position="300" error="false" numsubpods="2" primary="true">...</pod> <assumptions count="1">...</assumptions> <sources count="4">...</sources> </queryresult> ``` ``` -------------------------------- ### Making a Sample Query Source: https://products.wolframalpha.com/api/documentation?scrollTo=assumption-TideStation This snippet demonstrates how to construct a URL to query the Wolfram Alpha API. It includes the base URL, the required 'appid' parameter, and the 'input' parameter for specifying the query. The example uses 'DEMO' as a placeholder AppID and 'population%20of%20france' as the URL-encoded input. ```APIDOC ## GET /v2/query ### Description This endpoint allows users to make queries to the Wolfram Alpha API. It requires an AppID for authentication and an input parameter to specify the query. The response is an XML document containing information related to the input. ### Method GET ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - Your Wolfram Alpha AppID. - **input** (string) - Required - The URL-encoded query string. ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ### Response #### Success Response (200) - **queryresult** (object) - Contains the results of the query, including pods, warnings, and sources. - **success** (boolean) - Indicates if the query was successful. - **error** (boolean) - Indicates if an error occurred. - **numpods** (integer) - The number of pods returned. - **pod** (array) - An array of pods, each containing information related to the query. - **title** (string) - The title of the pod. - **id** (string) - The unique identifier of the pod. - **position** (integer) - The position of the pod in the result. - **subpod** (array) - An array of subpods within the pod. - **plaintext** (string) - Plain text representation of the subpod content. - **img** (object) - Image representation of the subpod content. - **src** (string) - URL of the image. - **alt** (string) - Alt text for the image. - **width** (integer) - Width of the image. - **height** (integer) - Height of the image. #### Response Example ```xml <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> ``` ``` -------------------------------- ### Making a Sample Query Source: https://products.wolframalpha.com/api/documentation?scrollTo=informational-elements This snippet shows the base URL for queries and how to include the required 'appid' and 'input' parameters. The example demonstrates a query for the 'population of France'. ```APIDOC ## GET /v2/query ### Description This endpoint allows you to make queries to Wolfram Alpha to retrieve information. It requires an AppID for authentication and an input parameter for the query itself. ### Method GET ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - Your Wolfram Alpha AppID. - **input** (string) - Required - The URL-encoded input for your query (e.g., "population%20of%20france"). ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ### Response #### Success Response (200) The API returns an XML document containing informational elements (pods) related to the input query. The structure includes a `<queryresult>` element with details about the query's success, number of pods, and timing, followed by individual `<pod>` elements for different aspects of the result. ``` -------------------------------- ### Invoking Pod States Source: https://products.wolframalpha.com/api/documentation?scrollTo=result-states Demonstrates how to invoke a pod state change using the `podstate` parameter in the API query. This example shows how to get more digits for the decimal approximation of Pi. ```APIDOC ## Invoking a Pod State To change the state of a pod, use the `podstate` parameter in your API request. For example, to get more digits for the decimal approximation of Pi: ### Method GET ### Endpoint `/v2/query` ### Query Parameters - **appid** (string) - Required - Your Wolfram Alpha API application ID. - **input** (string) - Required - The input query. - **podstate** (string) - Required - The pod state to invoke, formatted as `PodID__StateName`. ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=pi&podstate=DecimalApproximation__More+digits ``` ``` -------------------------------- ### Basic Query Example Source: https://products.wolframalpha.com/api/documentation?scrollTo=listing-of-assumption-types This example demonstrates how to construct a URL to query the Wolfram Alpha API for the population of France, including the AppID and URL-encoded input. ```APIDOC ## GET /v2/query ### Description This endpoint allows you to query Wolfram Alpha for information. It requires an AppID for authentication and an input parameter for the query itself. ### Method GET ### Endpoint http://api.wolframalpha.com/v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - Your Wolfram Alpha AppID. - **input** (string) - Required - The URL-encoded query input. ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20of%20france ``` ### Response #### Success Response (200) Returns an XML document containing the query results, including pods with informational elements related to the input. #### Response Example ```xml <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> ``` ``` -------------------------------- ### Initial Query with Short Scan Timeout Source: https://products.wolframalpha.com/api/documentation?scrollTo=assumption-FormulaVariableInclude Use a short scantimeout to get the initial set of pods back quickly. This example demonstrates a query for 'pi' with a scantimeout of 1.0 second. ```URL http://api.wolframalpha.com/v2/queryappid=DEMO&?input=pi&scantimeout=1.0 ``` -------------------------------- ### Querying with includepodid and format parameters Source: https://products.wolframalpha.com/api/documentation?scrollTo=assumption-MixedFraction This example demonstrates how to use the `includepodid` parameter to fetch a specific pod and the `format` parameter to specify the desired output type. ```APIDOC ## GET /v2/query ### Description Customizes API output by including only specified pods and formatting the results. ### Method GET ### Endpoint /v2/query ### Parameters #### Query Parameters - **appid** (string) - Required - An ID provided by Wolfram Research that identifies the application or organization making the request. - **input** (string) - Required - URL-encoded text specifying the input string. - **includepodid** (string) - Optional - Specifies a pod ID to include in the result. To specify multiple elements, use multiple instances of the parameter. - **format** (string) - Optional - The desired format for individual result pods. For multiple formats, separate values with a comma. ### Request Example ``` http://api.wolframalpha.com/v2/query?appid=DEMO&input=population%20france&includepodid=Result&format=plaintext ``` ### Response #### Success Response (200) - **queryresult** (object) - Contains the results of the query. - **pod** (array) - An array of pods returned in the result. - **title** (string) - The title of the pod. - **subpod** (array) - An array of subpods within the pod. - **plaintext** (string) - The plain text content of the subpod. - **img** (object) - Image element if available. - **src** (string) - Source URL of the image. - **alt** (string) - Alt text for the image. - **title** (string) - Title of the image. - **width** (string) - Width of the image. - **height** (string) - Height of the image. #### Response Example ```xml <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" 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> ``` ``` -------------------------------- ### Increasing scantimeout to get more pods Source: https://products.wolframalpha.com/api/documentation?scrollTo=result-futuretopic For general queries, increasing scantimeout can yield more pods. This example shows a query with scantimeout set to 4, resulting in nearly double the number of pods compared to the default setting. ```xml <queryresult success="true" error="false" numpods="8" datatypes="" timedout="" timedoutpods="" timing="3.5" parsetiming="0.5" parsetimedout="false" recalculate="http://www1.wolframalpha.com/api/v2/recalc.jsp?id=MSPa123g3d0ef867ddhf940000522c808eic67ab0d&s=12" id="MSPa456g3d0ef867ddhf94000061a1ffic9c0h723a" host="http://www.wolframalpha.com" server="12" version="2.6"> <pod title="General" scanner="Identity" id="Input" position="100" error="false" numsubpods="1">...</pod> <pod title="Population" scanner="Numeric" id="Result" position="200" error="false" numsubpods="1" primary="true"> <subpod title=""> <plaintext> 1,362,319 </plaintext> </subpod> </pod> <pod title="Capital" scanner="Location" id="Capital" position="300" error="false" numsubpods="1"> <subpod title=""> <plaintext> Augusta </plaintext> </subpod> </pod> ... </queryresult> ``` -------------------------------- ### Image Map Data Retrieval Source: https://products.wolframalpha.com/api/documentation?scrollTo=podtimeout-scantimeout This example shows how to request image and imagemap formats to get data for interactive image maps within pods. The imagemap data contains clickable regions and their associated queries. ```APIDOC ## Requesting Image Map Data To retrieve image map data along with the image, include both `image` and `imagemap` in the `format` parameter. ### Method GET ### Endpoint `/v2/query` ### Query Parameters - **appid** (string) - Required - Your WolframAlpha API application ID. - **input** (string) - Required - The query input. - **format** (string) - Required - Comma-separated list of desired formats. Include `image,imagemap`. ### Example URL `http://api.wolframalpha.com/v2/query?appid=DEMO&input=france&format=image,imagemap` ### Image Map Structure The response will contain an `<imagemap>` element within relevant pods. This element includes `<rect>` subelements, each defining a clickable region with `left`, `top`, `right`, and `bottom` coordinates, a `query` attribute (URL-encoded), and a `title` attribute for display. #### Example Image Map Pod Structure <pod title='Name' scanner='Data' id='Identifiers:CountryData' position='200' error='false' numsubpods='1'> <subpod title=''> <img src='...' alt='...' title='...' 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' /> ... </imagemap> </subpod> ... </pod> ### Executing Image Map Queries To simulate a click on a region, use the `query` attribute from the `<rect>` element and optionally include the `assumptions` attribute in a new API request. #### Example Query URL with Assumption `http://api.wolframalpha.com/v2/query?appid=DEMO&input=France+full+name&assumption=ClashPrefs_*Country.France.CountryProperty.FullName-` ```