complete code for API's