Skip to content

Support data streaming #3

@michielhildebrand

Description

@michielhildebrand

Useful for fetching large sets of results

Example code using requests library

  api.fetch(query, {count: count})
  try:
      with requests.get(url, stream=True) as r:
          r.raise_for_status()
          with open(output_file, "wb") as f:
              for chunk in r.iter_content(chunk_size=8192):
                  if chunk:  # filter out keep-alive chunks
                      f.write(chunk)
  except requests.exceptions.HTTPError as e:
      print(f"HTTP error {r.status_code} while downloading {url}")
  except requests.exceptions.RequestException as e:
      print(f"Request failed for {url}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions