Refactor/api/separate file

move a few things into their own file, especially the API definition.
This should make it easier to deal with, in the brain.