Skip to content

Instantly share code, notes, and snippets.

@ewistrand
Created October 10, 2023 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ewistrand/74c4e27cc5424b6501cda265921b9e27 to your computer and use it in GitHub Desktop.
Save ewistrand/74c4e27cc5424b6501cda265921b9e27 to your computer and use it in GitHub Desktop.
Loop through paged request with Python
import requests
resp = requests.get('https://url.com/api/endpoint').json()
data = resp['data']
while resp['next_page_url']:
resp = requests.get(resp['next_page_url']).json()
data.extend(resp['data'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment