Calling Wolfram APIs

The CloudConnector for Excel uses the WolframAPI Excel function to call Wolfram APIs that live in a Wolfram Cloud. These Wolfram APIs are created by a developer as described in the Writing Wolfram APIs section.

In the Wolfram Public Cloud, calling a Wolfram API will use the cloud credits of the API owner. More information can be found in the Cloud Credits Usage section. In a Wolfram Enterprise Private Cloud, there is no accounting system.

Wolfram API Functions

There are two key Excel functions to call Wolfram APIs.

NameFunctionalityExample
WolframAPIcall an APIWolframAPI("Example/AddTwo",n1,n2, )
Parameteradd a parameterParameter("x","A1")

Excel functions for calling Wolfram APIs.

A Wolfram API is called with the WolframAPI function. The first argument of WolframAPI is the API name. All subsequent arguments are parameters to the given API, and must be Parameter functions. Parameter functions have two arguments. The first is the parameter name and the second is the parameter value.

You can construct a WolframAPI that calls the /Documentation/Example/AddTwo API as follows:

=WolframAPI("/Documentation/Example/AddTwo", Parameter("x", 5), Parameter("y", 10))

The Wolfram API has two parameters, and , which have values 5 and 10, respectively. Executing this API will return the value 15.

More examples of Wolfram API calls can be found in the Examples section.

API Name

The first argument in the WolframAPI function in Excel is the API name. This name has two specifications.

        

"TestExample/AddNumbers"use the default API deployment name specified in the CloudConnector preferences
"/deployer/TestExample/AddNumbers"specify the API deployment name explicitly

Specifying the API name of a Wolfram API.

If the Wolfram API you wish to call is not from the default cloud account, you must include the cloud account in the API name as follows:

=WolframAPI("/Documentation/Example/AddTwo", Parameter("x", 5), Parameter("y", 10))

The default cloud account is specified in the CloudConnector for Excel Preferences. In the preceding case, if you have set your default cloud account to "Documentation", you can remove the cloud account from the beginning of the API name:

=WolframAPI("Example/AddTwo", Parameter("x", 5), Parameter("y", 10))

Note that the first WolframAPI has a "/" in front, whereas the second does not.

Parameter

Parameters for Wolfram APIs are specified with the Parameter function in Excel. Each parameter takes a name and a value:

Parameter("name", value)

The name is always a string. The value can be a string or a number, but can also be a reference to any number of cells in an Excel spreadsheet.

Insert API Call

Insert API Call is a dialog that provides Excel users with an easy-to-use tool to enter Wolfram API calls into a spreadsheet. To access this dialog, click the Insert API Call button in the Wolfram tab.

The following screenshot demonstrates how a WolframAPI with API name "/Documentation/Example/AddTwo" is placed in the cell D2. The parameters of and are set to B2 and B3, respectively.

API Name

In the API Name field, you can enter any API name. Clicking the Update button will call the Wolfram Cloud and fill out the Parameters section with any parameter names that exist for the API.

Output Location

The Output Location field is the location where you would like your WolframAPI function to be placed, once you click the Insert button. While this field is selected, you can select any cell in a worksheet and the value will be updated.

Parameters

These are the Parameters of the WolframAPI function. The left-hand column contains all the parameter names and the right-hand column all the values. When one of the value fields is highlighted, cells in a worksheet can be selected to paste a reference in the field. You can remove a parameter by clicking the "-" button or add with the Add button.