(examples)=

{fa}laptop-code,style=fas Examples

This section contains some complete examples that demonstrate the main features of requests-cache.

Articles

Some articles and blog posts that discuss requests-cache:

Scripts

The following scripts can also be found in the examples/ folder on GitHub.

Basic usage (with sessions)

:start-line: 3
:end-line: 4

:::{admonition} Example: basic_sessions.py :class: toggle

:lines: 6-

:::

Basic usage (with patching)

:start-line: 3
:end-line: 4

:::{admonition} Example: basic_patching.py :class: toggle

:lines: 6-

:::

Cache expiration

:start-line: 2
:end-line: 3

:::{admonition} Example: expiration.py :class: toggle

:lines: 5-

:::

URL patterns

:start-line: 3
:end-line: 4

:::{admonition} Example: url_patterns.py :class: toggle

:lines: 6-

:::

Multi-threaded requests

:start-line: 2
:end-line: 4

:::{admonition} Example: threads.py :class: toggle

:lines: 6-

:::

Logging requests

:start-line: 2
:end-line: 3

:::{admonition} Example: log_requests.py :class: toggle

:lines: 5-

:::

External configuration

:start-line: 2
:end-line: 8

:::{admonition} Example: external_config.py :class: toggle

:lines: 10-

:::

Cache speed test

:start-line: 2
:end-line: 8

:::{admonition} Example: benchmark.py :class: toggle

:lines: 10-

:::

Converting an old cache

:start-line: 2
:end-line: 4

:::{admonition} Example: convert_cache.py :class: toggle

:lines: 6-

:::

(custom_keys)=

Custom request matcher

:start-line: 2
:end-line: 15

:::{admonition} Example: custom_request_matcher.py :class: toggle

:lines: 17-

:::

Backtesting with time-machine

:start-line: 2
:end-line: 4

:::{admonition} Example: time_machine_backtesting.py :class: toggle

:lines: 6-

:::

VCR Export

:start-line: 2
:end-line: 5

:::{admonition} Example: vcr.py :class: toggle

:lines: 7-

:::