diff --git a/canvasapi/requester.py b/canvasapi/requester.py
index eff4b3a..c017a42 100644
--- a/canvasapi/requester.py
+++ b/canvasapi/requester.py
@@ -24,6 +24,7 @@ class Requester(object):
         self.base_url = base_url
         self.access_token = access_token
         self._session = requests.Session()
+        self._cache = []
 
     def request(
             self, method, endpoint=None, headers=None, use_auth=True,
@@ -84,6 +85,12 @@ class Requester(object):
         # Call the request method
         response = req_method(full_url, headers, _kwargs)
 
+        # Add response to internal cache
+        if len(self._cache) > 4:
+            self._cache.pop()
+
+        self._cache.insert(0, response)
+
         # Raise for status codes
         if response.status_code == 400:
             raise BadRequest(response.json())

Add a Requester cache for debugging
We should add a cache of requests and responses onto `Requester` to make debugging easier.

This could be as simple as a tuple recording the last request that was sent and the last response received, or we could save several requests and responses.
diff --git a/tests/test_requester.py b/tests/test_requester.py
index d65f2d4..fb582a7 100644
--- a/tests/test_requester.py
+++ b/tests/test_requester.py
@@ -77,6 +77,23 @@ class TestRequester(unittest.TestCase):
         response = self.requester.request('PUT', 'fake_put_request')
         self.assertEqual(response.status_code, 200)
 
+    def test_request_cache(self, m):
+        register_uris({'requests': ['get']}, m)
+
+        response = self.requester.request('GET', 'fake_get_request')
+        self.assertEqual(response, self.requester._cache[0])
+
+    def test_request_cache_clear_after_5(self, m):
+        register_uris({'requests': ['get', 'post']}, m)
+
+        for i in range(5):
+            self.requester.request('GET', 'fake_get_request')
+
+        response = self.requester.request('POST', 'fake_post_request')
+
+        self.assertLessEqual(len(self.requester._cache), 5)
+        self.assertEqual(response, self.requester._cache[0])
+
     def test_request_400(self, m):
         register_uris({'requests': ['400']}, m)
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest flake8 pycodestyle requests_mock
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/ucfopen/canvasapi.git@d05071ddc2e4a37ebd49d162f4f080757befeb4c#egg=canvasapi
certifi==2025.1.31
charset-normalizer==3.4.1
exceptiongroup==1.2.2
flake8==7.2.0
idna==3.10
iniconfig==2.1.0
mccabe==0.7.0
packaging==24.2
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.1
pytest==8.3.5
pytz==2025.2
requests==2.32.3
requests-mock==1.12.1
six==1.17.0
tomli==2.2.1
urllib3==2.3.0

name: canvasapi
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
  - 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=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - exceptiongroup==1.2.2
      - flake8==7.2.0
      - idna==3.10
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - packaging==24.2
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.1
      - pytest==8.3.5
      - pytz==2025.2
      - requests==2.32.3
      - requests-mock==1.12.1
      - six==1.17.0
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/canvasapi

tests/test_requester.py::TestRequester::test_request_cache tests/test_requester.py::TestRequester::test_request_cache_clear_after_5
tests/test_requester.py::TestRequester::test_request_400 tests/test_requester.py::TestRequester::test_request_401_InvalidAccessToken tests/test_requester.py::TestRequester::test_request_401_Unauthorized tests/test_requester.py::TestRequester::test_request_404 tests/test_requester.py::TestRequester::test_request_500 tests/test_requester.py::TestRequester::test_request_delete tests/test_requester.py::TestRequester::test_request_get tests/test_requester.py::TestRequester::test_request_get_datetime tests/test_requester.py::TestRequester::test_request_post tests/test_requester.py::TestRequester::test_request_post_datetime tests/test_requester.py::TestRequester::test_request_put
canvasapi/requester.py
canvasapi/requester.py