Is it possible to return more results from an API call than what the default limit allows?

Viewed 53

I’m doing an API call that returns a series of parks. There’s I think 466 parks in the system, and the number of results per return has a default of 50. I figured that meant I could just add a “limit=466” to the URL and get more than 50. It turns out that adding a limit of anything more than 50 gives me an IndexError of ‘list index error out of range.’ At the top of my Python code I'm importing urllib.request and json. The URL I'm using looks like this:

https://developer.nps.gov/api/v1/parks?limit=100&API_KEY=apikey

I have a feeling these are beginner problems, but I’m wondering 2 things. How do I get more than 50 parks to come back? And is there a way to just do a sort of “all results” rather than an integer, in case more parks are added to the API in the future?

1 Answers

How do I get more than 50 parks to come back?

If the API doesn't want you to get more than 50 at a time, you can't. You can only do what the API allows you to do.

And is there a way to just do a sort of “all results” rather than an integer

Possibly, if the API provided a way to do that. No way to tell from this example.

Related