Refactor the getdataused api function.