js api attempt (not good, have to change server then rewrite)