add serialize method for api