rewrote apiname and ensure_apiname()