REST API

When a page is started, REST API endpoints are exposed under /api.

This API may be used to update a page from an external script.

See awe.api_client.APIClient source for details on specific endpoints. The code is short and pretty self explanatory.

Python Client

class awe.api_client.APIClient(host='127.0.0.1', port=8080)[source]

REST API client.

Can be used to update a running page from an external script.

Parameters:
  • hostawe server host.
  • portawe server port.
get_status()[source]

Verify liveness of awe’s server.

get_elements(include_data=False, include_props=False)[source]

Get all elements currently registered.

Parameters:
  • include_data – Should element data be included in the response.
  • include_props – Should element props be included in the response.
get_element(element_id)[source]

Get a single registered element.

Parameters:element_id – The element id.
new_element(obj, params=None, element_id=None, root_id=None, parent_id=None, new_root=False)[source]

Create a new element. Equivalent to calling the new() method on elements.

Parameters:
  • obj – The obj argument as expected by the new() method.
  • params – Params to pass on to the new() method invocation.
  • element_id – Optionally specify an element_id. (one will be generated otherwise)
  • root_id – Optionally specify a different root to create the element under. If not specified, and parent_id is not supplied, the main page root will be used.
  • parent_id – Optionally specify the element to call the new() method on.
  • new_root – Pass True to create the element under a new root.
remove_element(element_id)[source]

Remove an element from the page.

Parameters:element_id – The element id.
new_prop(element_id, name)[source]

Create a new prop child. Equivalent to calling new_prop() on an element.

Parameters:
  • element_id – The element id to call new_prop on.
  • name – The prop name.
update_data(element_id, data)[source]

Update the element data. Equivalent to calling update_data() on an element.

Parameters:
  • element_id – The element id to call update_data on.
  • data – The data to set on the element.
update_props(element_id, props)[source]

Update the element props. Equivalent to calling update_props() on an element.

Parameters:
  • element_id – The element id to call update_props on.
  • props – The props to set on the element.
update_prop(element_id, path, value)[source]

Update an element prop. Equivalent to calling update_prop() on an element.

Parameters:
  • element_id – The element id to call update_prop on.
  • path – The prop path.
  • value – The prop value.
call_method(element_id, method_name, kwargs=None)[source]

Call a method on an element. Useful when working with elements such as a table or a chart that expose methods to modify their internal state.

Parameters:
  • element_id – The element id to call the specified method on.
  • method_name – The method to call.
  • kwargs – Keyword arguments to pass to the method invocation.
get_variables()[source]

Get all variables currently registered.

get_variable(variable_id)[source]

Get a single registered variable.

Parameters:variable_id – The variable id.
new_variable(value, variable_id=None)[source]

Create a new variable.

Parameters:
  • value – The variable’s initial value.
  • variable_id – Optionally, supply a variable id, one will be generated otherwise.
update_variable(variable_id, value)[source]

Update a variable.

Parameters:
  • variable_id – The variable id.
  • value – The new variable value.
call_function(function_id, kwargs=None)[source]

Call a registered function.

Parameters:
  • function_id – The function id.
  • kwargs – Additional keyword arguments to pass to the function invocation.