keithing: Since this is touch the root `Endpoint` class, would you mind running `tools/smoke_test.py`?
stephen-hoover: @keithing , the smoke test completes successfully (and I merged in master and fixed the CHANGELOG conflicts).
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 061a244..9ee37b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - `civis.io.dataframe_to_file` and `civis.io.json_to_file` convenience functions.
   (#262, #304)
 - Add the user's Python version to the User-Agent string. (#255, #301)
+- Added a `last_response` parameter to the `APIClient` object. (#153, #302)
 
 ### Fixed
 - Fix unintentional dependency on scikit-learn for `parallel` module tests. (#245, #303)
@@ -23,7 +24,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - Surfaced `civis.io.split_schema_tablename` in the Sphinx docs. (#294)
 - Loosen `joblib` version requirement to include v0.13 and add code to
   the Civis joblib backend which newer versions of `joblib` can take
-  advantage of. Also loosed version requirement on `cloudpickle` to
+  advantage of. Also loosened version requirement on `cloudpickle` to
   include v1. (#296, #299)
 
 ## 1.10.0 - 2019-04-09
diff --git a/civis/base.py b/civis/base.py
index 30bc1fc..7b98997 100644
--- a/civis/base.py
+++ b/civis/base.py
@@ -79,10 +79,11 @@ class Endpoint(object):
 
     _lock = threading.Lock()
 
-    def __init__(self, session_kwargs, return_type='civis'):
+    def __init__(self, session_kwargs, client, return_type='civis'):
         self._session_kwargs = session_kwargs
         self._return_type = return_type
         self._base_url = get_base_url()
+        self._client = client
 
     def _build_path(self, path):
         if not path:
@@ -112,12 +113,13 @@ class Endpoint(object):
         iterator = kwargs.pop('iterator', False)
 
         if iterator:
-            return PaginatedResponse(path, params, self)
+            resp = PaginatedResponse(path, params, self)
         else:
             resp = self._make_request(method, path, params, data, **kwargs)
             resp = convert_response_data_type(resp,
                                               return_type=self._return_type)
-            return resp
+        self._client.last_response = resp
+        return resp
 
 
 class CivisAsyncResultBase(futures.Future):
diff --git a/civis/civis.py b/civis/civis.py
index f2c252a..317f86e 100644
--- a/civis/civis.py
+++ b/civis/civis.py
@@ -351,6 +351,7 @@ class APIClient(MetaMixin):
         session_auth_key = get_api_key(api_key)
         self._session_kwargs = {'api_key': session_auth_key,
                                 'max_retries': retry_total}
+        self.last_response = None
 
         # Catch deprecation warnings from generate_classes_maybe_cached and
         # the functions it calls until the `resources` argument is removed.
@@ -364,7 +365,8 @@ class APIClient(MetaMixin):
                                                     api_version,
                                                     resources)
         for class_name, cls in classes.items():
-            setattr(self, class_name, cls(self._session_kwargs, return_type))
+            setattr(self, class_name, cls(self._session_kwargs, client=self,
+                                          return_type=return_type))
 
     @property
     def feature_flags(self):

cache last response
It might be nice to save the last response in the `APIClient` class so that users could retrieve it if they forget to assign it when using the client in a REPL or notebook.

e.g., 

```
> client = civis.APIClient()
> client.scripts.post_containers(...)
> client.last_response
{"id": ..., }
```

This idea came from a comment by @skomanduri.  I can't think of drawbacks to this, but perhaps there are.
diff --git a/civis/tests/test_base.py b/civis/tests/test_base.py
index e788cbe..527a539 100644
--- a/civis/tests/test_base.py
+++ b/civis/tests/test_base.py
@@ -17,6 +17,18 @@ def test_base_url_from_env():
 @mock.patch('civis.base.get_base_url', return_value='https://base.api.url/')
 def test_endpoint_base_url(mock_get_base_url):
     session = mock.MagicMock(spec=requests.Session)
-    endpoint = Endpoint(session)
+    endpoint = Endpoint(session, 'client')
 
     assert endpoint._base_url == 'https://base.api.url/'
+
+
+def test_store_last_response():
+    mock_client = mock.Mock()
+    endpoint = Endpoint({}, client=mock_client, return_type='raw')
+
+    returned_resp = {'value': 'response'}
+    endpoint._make_request = mock.Mock(return_value=returned_resp)
+
+    resp = endpoint._call_api('GET')
+    assert resp == returned_resp
+    assert mock_client.last_response is resp

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==24.2.0
cbor2==5.4.6
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
-e git+https://github.com/civisanalytics/civis-python.git@7166c8782fe7e9bcf164e8365e15a7bb0cfdb79b#egg=civis
Click==7.0
cloudpickle==1.6.0
exceptiongroup==1.2.2
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
joblib==0.13.0
jsonref==0.2
jsonschema==3.0.0
packaging==24.0
pluggy==1.2.0
pubnub==4.8.1
pycryptodomex==3.22.0
pyrsistent==0.19.3
pytest==7.4.4
PyYAML==5.4.1
requests==2.31.0
six==1.17.0
tomli==2.0.1
typing_extensions==4.7.1
urllib3==2.0.7
zipp==3.15.0

name: civis-python
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==24.2.0
      - cbor2==5.4.6
      - charset-normalizer==3.4.1
      - click==7.0
      - cloudpickle==1.6.0
      - exceptiongroup==1.2.2
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - joblib==0.13.0
      - jsonref==0.2
      - jsonschema==3.0.0
      - packaging==24.0
      - pluggy==1.2.0
      - pubnub==4.8.1
      - pycryptodomex==3.22.0
      - pyrsistent==0.19.3
      - pytest==7.4.4
      - pyyaml==5.4.1
      - requests==2.31.0
      - six==1.17.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - zipp==3.15.0
prefix: /opt/conda/envs/civis-python

civis/tests/test_base.py::test_store_last_response
civis/tests/test_base.py::test_base_url_default civis/tests/test_base.py::test_base_url_from_env civis/tests/test_base.py::test_endpoint_base_url
civis/civis.py civis/base.py CHANGELOG.md
civis/civis.py civis/base.py CHANGELOG.md