0

The following request:

https://api.data.gov/ed/collegescorecard/v1/schools?fields=school.name,school.city,school.state,school.zip,school.carnegie_size_setting

Returns just 20, how can I get all 7175?

{
  "metadata": {
    "total": 7175,
    "page": 0,
    "per_page": 100
  },
  "results": [
   ....
1
  • 1
    Something is missing in your request: a question mark, ampersand? Please edit
    – user4293
    Commented Oct 29, 2018 at 21:55

1 Answer 1

1

From Open Data Maker HTTP API:

By default, results are returned in pages of 20 records at a time. To retrieve pages after the first, set the _page option parameter to the number of the page you wish to retrieve. Page numbers start at zero; so, to return records 21 through 40, use _page=1. Remember that the total number of records available for a given query is given in the total field of the top-level metadata object.

You can also change the number of records returned per page using the _per_page option parameter, up to a maximum of 100 records. Bear in mind, however, that large result pages will increase the amount of JSON returned and reduce the performance of the API.

Thus, your request should be:

https://api.data.gov/ed/collegescorecard/v1/schools?_per_page=100&_page=0&api_key=DEMO_KEY&fields=school.name,school.city,school.state,school.zip,school.carnegie_size_setting

Then change _page to 1 etc.

You could use e.g. cURL globbing, but note that the DEMO_KEY API key has harder rate limits.


You could also download CSV dumps: https://catalog.data.gov/dataset/college-scorecard

0

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.