turned yesterday's example CLI into API + CLI using that API.
small changes from Tom's code review; removing obsolete example code