0

I'm trying to sort an API query by size of students, but I can't figure out how to get the API to accept the &sort parameter. Can someone provide me an example? I'm referring to the documentation here but it isn't very clear (to me, a noob at API's). I've already tried the following:

let collegeDataAPIoptions = {
    url: 'https://api.data.gov/ed/collegescorecard/v1/schools.json' +
        '?school.' +
        'operating=0,1' +
        '&_fields=' +
        'id,' +
        'school.name,' +
        '2019.student.size,' +
        '2019.academics.program_percentage.education' +
        '&sort=2019.student.size' +
        '&api_key=[redacted]'
}

This is the error I'm getting:

StatusCodeError: 400 - "{\"error\":{\"error\":\"unknown_column\",\"message\":\"Only select columns are available for filtering. 
Please see the data documentation column \\\"INDEX\\\" to find out which ones are allowed.\",\"input\":\"Unknown column '2019_student_size' in 'order clause'\"}}"

1 Answer 1

0

Ok after more debugging it looks like it works if the field (in &sort=[field]) doesn't start with a number. If I start it with 'latest' then it works just fine, even though in this case 'latest' and 2019 should be interchangeable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.