API functions, state, listener and scripts