When to do an API for my web app?
maxklein: If your application is something for whom an API is useful, then encapsulate the application behind your API. This will allow you deal with the application at a somewhat abstract level, which will lead to better programming practises. So, write your tentative API first, program for the API, test with rough mock-ups, then write the front end.