api type implemented

not exported yet, put in api2.js just in case we still want to use
api.js