API Test and Main Function