Add documentation to API controller index action, and improve readability of build_query private method.