write script, json API. WIP