Factor out getApi and set sandbox into api.