The developer API exposes “External” trigger outside of mtion studio. It allows them to be queried as well as fired. This API can be called at localhost:35393 whenever a local instance of mtion studio is running.
Get all external triggers
Returns an array of external trigger datas in the currently opened clubhouse
Fires an external trigger with some optional parameter data. When called with GET the data is passed as a query parameter. When called with PATCH the data is passed as a JSON in the body. This request also returns the data of the trigger that was fired.
Below is a sample python script which queries the external triggers in the currently opened clubhouse. It then fires each one while passing some mock data to each of their parameters.
import requests# This script gets all of the external triggers in the current clubhouse# It then generates some sample data for each trigger's parameters# Finally, it fires each trigger using the sample parameter datadefmain(): trigger_datas =get_external_trigger_datas()if trigger_datas:for trigger_data in trigger_datas: sample_parameter_values =generate_parameter_values_for_trigger(trigger_data)fire_external_trigger(trigger_data, sample_parameter_values)# Calls the API to get all the external triggers in the currently opened clubhousedefget_external_trigger_datas(): url ="http://localhost:35393/external-trigger/triggers"try: response = requests.get(url) data = response.json() response.raise_for_status()print(f"Successfully received external trigger datas: {data}")return dataexcept requests.exceptions.RequestException as e:print(f"Error occurred: {e}, {data}")# Calls the API to fire a triggerdeffire_external_trigger(trigger_data,parameterValues): url =f"http://localhost:35393/external-trigger/fire-trigger/{trigger_data["id"]}" headers ={'Content-Type':'application/json'}try: response = requests.patch(url, json=parameterValues, headers=headers) data = response.json() response.raise_for_status()print(f"Successfully fired external trigger with ID: {trigger_data["id"]}")return dataexcept requests.exceptions.RequestException as e:print(f"Error occurred: {e}, {data}")# Generates some mock data for each of a trigger's parametersdefgenerate_parameter_values_for_trigger(trigger_data): output = []for parameter in trigger_data["output_parameters"]: parameterValue ={"parameter_index": parameter["parameter_index"]}match parameter["data_type"]:case"string": parameterValue["value"]="Sample string from python script!"case"number": parameterValue["value"]=123case"bool": parameterValue["value"]=Truecase"enum": parameterValue["value"]=0 output.append(parameterValue)print(f"Successfully generated mock data for external trigger: {output}")return output if__name__=="__main__":main()
Clubhouses
The developer API exposes clubhouses of mtion studio. This API can be called at localhost:35393 whenever a local instance of mtion studio is running.
Get all clubhouses
Returns an array of clubhouse datas for the current user.
curl -X GET 'http://localhost:35393/clubhouse/MCLB-bbe66e6c-f8c4-4ba4-99b7-630b16d09d15'
Sample Response
{"id":"MCLB-bbe66e6c-f8c4-4ba4-99b7-630b16d09d15","name":"Empty Template","description":"Build your own clubhouse from scratch. Nothing in here but your imagination. ","external_trigger_datas": []}
curl -X GET 'http://localhost:35393/active-clubhouse'
Sample Response
{"id":"MCLB-bbe66e6c-f8c4-4ba4-99b7-630b16d09d15","name":"Empty Template","description":"Build your own clubhouse from scratch. Nothing in here but your imagination. ","external_trigger_datas": []}
Code
Description
Code
Description
Code
Description
Code
Description
Code
Description
200 OK
Successfully retrieved the currently opened clubhouse’s external triggers
404 Not Found
No clubhouse open
200 OK
Successfully retrieved the trigger data
404 Not Found
No clubhouse open or trigger not found
200 OK
Successfully fired the trigger
404 Not Found
No clubhouse open or trigger not found
200 OK
Successfully retrieved the currently opened clubhouse’s external triggers
200 OK
Successfully retrieved the currently opened clubhouse’s external triggers
404 Not Found
Clubhouse not found
200 OK
Successfully retrieved the currently opened clubhouse’s external triggers