started work on API. Unfinished.