reorganising and centralising javascript api roughwork to date