How to: Work with subservices

Spark allows users to separate different groups of calculations into subservices. For example, imagine an Excel file that performs addition on one set of values and multiplication on another. Only one set of results is may be needed at a time. With subservices, the request can specify just one of the the operations instead of returning the addition and multiplication results every time.

Map the subservice

Syntax: Xinput_<subservice>.<parameter> and Xoutput_<subservice>.<parameter>

  1. Follow the instructions to create a name in Define a named range in Excel for the selected range.

  2. When creating the name, use the noted prefix defined in the syntax.

Example of mapping subservices

In this example, within the same Excel file there are 2 products being priced, ProductX and ProductY. These 2 products are separated into 2 subservices. Each subservice has 2 Xinputs, Age and Sex. Corresponding outputs need to be mapped for the ProductX and ProductY subservices.

Submit API requests for subservices

  1. In the API Tester Adjust service parameters, there is a field to select subservices.

    • When a Spark services has no subservices, this field is blank.

    • When a Spark Service has subservices, the field initially contains Default.

  2. Use the dropdown to select which subservices to include in the API call.

  3. Spark filters the inputs and outputs based on the selected subservices.

Integrating to a subservice

To understand how to call a subservice, use the API Tester "Raw view" to review the parameters.

  • The selected subservices are included in the Execute API (v3) request_meta parameter service_category.

  • The Default subservice mentioned above is denoted as #Default#.

Find out more in the Parameters to control the response outputs of the Execute API (v3) request_meta.

Metadata subservice

circle-exclamation

Syntax: Xoutput_metadata.<parameter>

Use the metadata subservice together with the Metadata API for static data (in other words, data that doesn't change when other inputs change). This subservice is much faster than using the full Execute API, since it does not perform any calculations.

Example file

Upload the example service to Spark to practice using subservices. Map the output cells for the two subservice inputs in the file and use the API tester to pick a subservice and control which values are returned. You can also map a range to a metadata output and see this feature in action.

file-download
21KB

Last updated