Change api.service to use a class, fix validations in api

Change-Id: Ib5a957a82238b18548ff470ea9c2905b389d026e