# Interdomain communication
- by exposing an instance of a Python class to the
create_window. All the callable methods of the class will be exposed to the JS domain as
pywebview.api.method_namewith correct parameter signatures. Method name must not start with an underscore. See an example.
- by passing your function(s) to window object's
expose(func). This will expose a function or functions to the JS domain as
pywebview.api.func_name. Unlike JS API,
exposecan expose functions dynamically at runtime. If there is a name clash between JS API and functions exposed this way, the latter takes precedence. See an example.
Error object. Stacktrace is available via
error.stack. Functions are executed in separate threads and are not thread-safe.
window.pywebview.api is not guaranteed to be available on
window.onload. Subscribe to
window.pywebviewready instead to make sure that
window.pywebview.api is ready. Example.