sorted API to rails app