vcrpy
VCR.py is a Python testing library that records HTTP interactions during test runs and replays them on subsequent runs, eliminating the need for live API calls. This speeds up tests, enables offline testing, and ensures deterministic behavior by using cached YAML cassette files.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | kevin1024/vcrpy |
| Owner | kevin1024 |
| Primary language | Python |
| License | MIT — OSI-approved |
| Stars | 3k |
| Forks | 426 |
| Open issues | 145 |
| Latest release | v8.3.0 (2026-07-04) |
| Last updated | 2026-07-04 |
| Source | https://github.com/kevin1024/vcrpy |
What vcrpy is
VCR.py intercepts HTTP requests made through supported Python libraries, serializes requests/responses to YAML cassettes on first run, and replays recorded interactions on subsequent runs to avoid network I/O. The library supports context managers and decorator patterns for flexible test integration.
Get the vcrpy source
Clone the repository and explore it locally.
git clone https://github.com/kevin1024/vcrpy.gitcd vcrpy# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Cassette files must be committed to version control; establish clear practices for sanitizing sensitive data (API keys, auth tokens) before commit.
- Configure request matching logic carefully (URI, method, body) to avoid false cassette hits when APIs add optional fields or when test inputs vary legitimately.
- Plan cassette regeneration workflow when external APIs change; automate deletion and re-recording to prevent stale cassettes masking real API issues.
- Test the fallback behavior: ensure tests fail gracefully or re-record when cassettes are missing, rather than hanging or returning misleading results.
- Consider YAML vs. alternative serialization formats if cassettes become unwieldy; VCR.py supports pluggable serializers.
When to avoid it — and what to weigh
- Real-Time Data Requirements — If tests must validate against live, changing data (e.g., stock prices, weather), cassette playback will return stale recorded values and mislead test results.
- Binary/Large Payload APIs — YAML serialization is inefficient for binary content or large responses. Cassettes become verbose and slow to deserialize; consider custom serializers or alternative tools.
- Strict Request/Response Validation at Scale — Managing cassette files across hundreds of endpoints with frequent API changes becomes operationally burdensome. Cassette diffs and merge conflicts complicate team workflows.
- Security-Sensitive Credentials in Tests — Cassettes store recorded request/response data as plain YAML by default. Sensitive tokens, API keys, or PII embedded in payloads require careful sanitization before committing to version control.
License & commercial use
MIT License permits commercial use, modification, and distribution with permissive terms. Attribution and license notice required in distributed binaries/source.
MIT is a permissive OSI-approved license; commercial use is permitted. However, audit cassette files for embedded credentials or third-party data before deploying any tests to production or proprietary environments.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
Cassettes store unencrypted YAML containing request/response bodies. Any sensitive data (API keys, tokens, PII, credentials) recorded in interactions must be sanitized before committing to version control. VCR.py does not provide built-in encryption or PII masking; implement scrubbers in your cassette configuration or CI/CD pipeline to redact secrets.
Alternatives to consider
responses (Python)
Lightweight in-memory HTTP mocking library. Better for simple, single-endpoint mocking; less suitable for capturing and replaying complex multi-step API workflows.
httpretty (Python)
Lower-level HTTP mocking at socket level. More control over edge cases; steeper learning curve and less developer-friendly than VCR.py's cassette abstraction.
Prism (multi-language)
API mocking server with OpenAPI/Swagger integration. Better for mocking stateless APIs at infrastructure level; overkill for unit test isolation, requires separate service.
Build on vcrpy with DEV.co software developers
Ready to eliminate flaky API tests and speed up your CI/CD pipeline? Integrate VCR.py today to record API interactions once and replay them reliably. Reach out to our team to discuss test architecture optimization.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
vcrpy FAQ
How do I update cassettes when an API changes?
Can I use VCR.py with async/await code?
What if I have sensitive credentials in cassettes?
Does VCR.py work with external services like AWS, Stripe, etc.?
Work with a software development agency
From first prototype to production, DEV.co delivers software development services around tools like vcrpy. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source testing and beyond.
Accelerate Your Python Tests with VCR.py
Ready to eliminate flaky API tests and speed up your CI/CD pipeline? Integrate VCR.py today to record API interactions once and replay them reliably. Reach out to our team to discuss test architecture optimization.