Response

Utilities for working with requests.Response .

tamr_client.response.successful(response)[source]

Ensure response does not contain an HTTP error.

Delegates to requests.Response.raise_for_status()

Return type

Response

Returns

The response being checked.

Raises

requests.exceptions.HTTPError – If an HTTP error is encountered.

tamr_client.response.ndjson(response, **kwargs)[source]

Stream newline-delimited JSON from the response body

Analog to requests.Response.json() but for .ndjson-formatted body.

Recommended: For memory efficiency, use stream=True when sending the request corresponding to this response.

Parameters
  • response (Response) – Response whose body should be streamed as newline-delimited JSON.

  • **kwargs – Keyword arguments passed to underlying requests.Response.iter_lines() call.

Returns

Each line of the response body, parsed as JSON

Example

>>> import tamr_client as tc
>>> s = tc.session.from_auth(...)
>>> r = s.get(..., stream=True)
>>> for data in tc.response.ndjson(r):
...     assert data['my key'] == 'my_value'
Return type

Iterator[Dict[str, Any]]