Skip to main content

A transparent, persistent cache for the requests library

Project description

Requests-Cache

Build Coverage Documentation PyPI PyPI - Python Versions PyPI - Format Code Shelter

Summary

requests-cache is a transparent, persistent HTTP cache for the python requests library. It's a convenient tool to use with web scraping, consuming REST APIs, slow or rate-limited sites, or any other scenario in which you're making lots of requests that are expensive and/or likely to be sent more than once.

See full project documentation at: https://requests-cache.readthedocs.io

Features

Quickstart

First, install with pip:

pip install requests-cache

Next, use requests_cache.CachedSession to send and cache requests. To quickly demonstrate how to use it:

This takes ~1 minute:

import requests

session = requests.Session()
for i in range(60):
    session.get('http://httpbin.org/delay/1')

This takes ~1 second:

import requests_cache

session = requests_cache.CachedSession('demo_cache')
for i in range(60):
    session.get('http://httpbin.org/delay/1')

The URL in this example adds a delay of 1 second, simulating a slow or rate-limited website. With caching, the response will be fetched once, saved to demo_cache.sqlite, and subsequent requests will return the cached response near-instantly.

If you don't want to manage a session object, requests-cache can also be installed globally:

requests_cache.install_cache('demo_cache')
requests.get('http://httpbin.org/delay/1')

Next Steps

To find out more about what you can do with requests-cache, see:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests-cache-0.7.5.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

requests_cache-0.7.5-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

Details for the file requests-cache-0.7.5.tar.gz.

File metadata

  • Download URL: requests-cache-0.7.5.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0a2 CPython/3.9.6 Linux/5.4.0-1056-azure

File hashes

Hashes for requests-cache-0.7.5.tar.gz
Algorithm Hash digest
SHA256 08102daab3b06fb8c0de14a297e44ed5dfe44ccf0e2ba8c858a0f12aa32b109f
MD5 7c3333ff27e79da7fb6283f72a65f656
BLAKE2b-256 641f0ab7191793f991bc17cf453106838b39b1924312021ae89a1574de6cf151

See more details on using hashes here.

File details

Details for the file requests_cache-0.7.5-py3-none-any.whl.

File metadata

  • Download URL: requests_cache-0.7.5-py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0a2 CPython/3.9.6 Linux/5.4.0-1056-azure

File hashes

Hashes for requests_cache-0.7.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3189cad997359f6a57e3c305ca8ab313f359626cbd15426570dd48711d02930f
MD5 72d1c1fc6e1f424384990059edce2a6d
BLAKE2b-256 9a8b1a0edf935b70df1be64c5b2988e0322b14a697f89a7818dc12cae3d327f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page