Extract method to DRY up API creation knowledge

Last one of these mini pull requests of me chasing the 4.0 from Code Climate - I promise! This should clear the last warning from Code Climate by extracting out the creation of the API object in the CLI into its own method.