enh: moved api into its own file

The main aim of this PR is to move the toplevel objects and modules into an api module.