Rewrite api structure