draft of rest api

Tranlated from the new api commands. Not 100 percent sure it works perfectly. serve as the base for the discussion of rest apis.