db API refactor

Refactored api into a method that can recreate it on demand.

Now when set Options is called, createAPI will remove restricted methods
based on options provided.