finish the api