civis.utils.run_template(id, arguments, JSONValue=False, client=None)[source]

Run a template and return the results.

id: int

The template id to be run.

arguments: dict

Dictionary of arguments to be passed to the template.

JSONValue: bool, optional

If True, will return the JSON output of the template. If False, will return the file ids associated with the output results.

client: :class:`civis.APIClient`, optional

If not provided, an civis.APIClient object will be created from the CIVIS_API_KEY.

output: dict

If JSONValue = False, dictionary of file ids with the keys being their output names. If JSONValue = True, JSON dict containing the results of the template run. Expects only a single JSON result. Will return nothing if either there is no JSON result or there is more than 1 JSON result.


>>> # Run template to return file_ids
>>> run_template(my_template_id, arguments=my_dict_of_args)
{'output': 1234567}
>>> # Run template to return JSON output
>>> run_template(my_template_id, arguments=my_dict_of_args, JSONValue=True)
{'result1': 'aaa', 'result2': 123}