writing rest api