finish to implement app.api function