ajax and api rewrite