--- id: harfile version: "0.5.0" license: MIT license_treatment: permissive maintenance: active --- # harfile — Writer for HTTP Archive (HAR) files License: permissive · Maintenance: active · Downloads: 2.7M/mo ## What it is and what it does harfile is a minimal, zero-dependency library for programmatically writing HTTP Archive (HAR) files in Python. It provides a context manager interface to build HAR files by adding individual HTTP request/response entries with timing data, suitable for recording network activity in test scenarios or debugging workflows. The package is designed for single-threaded use and does not support HAR's page grouping feature. It accepts entries via a simple API that takes request, response, timing, and metadata objects, then serializes them to standard HAR format. With no external dependencies and support for modern Python versions (3.8 through 3.14), it integrates easily into testing and monitoring pipelines. Use it for: - Record HTTP interactions during integration tests and save them as HAR files for analysis or replay - Generate HAR archives from captured network traffic in debugging or performance profiling workflows - Export request/response logs from a test suite in a standardized format for sharing with other tools ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Writes HTTP Archive (HAR) files in Python with zero external dependencies, supporting single-threaded entry recording without page grouping. Yes, for test and debugging workflows that need HAR output. The zero-dependency design, permissive license, and active maintenance make it a low-risk choice. The single-threaded constraint and lack of page support are acceptable trade-offs for most recording use cases; verify that your HAR field requirements match the library's scope before adopting. ## Install pip install harfile uv add harfile poetry add harfile ## Installing harfile Before you install: Low friction: pure Python wheel with no runtime dependencies. Active maintenance with a recent release (77 days ago) and current repository activity. License in practice: MIT permissive license allows commercial and private use with minimal restrictions; attribution required. Quickstart: import datetime import harfile with harfile.open("output.har") as har: har.add_entry( startedDateTime=datetime.datetime.now(datetime.timezone.utc), time=42, request=harfile.Request(method="GET", url="http://example.com", httpVersion="HTTP/1.1"), response=harfile.Response(status=200, statusText="OK", httpVersion="HTTP/1.1"), timings=harfile.Timings(send=0, wait=0, receive=0), ) Single-threaded environment only; pages are not supported. Verify before relying: - Whether the package handles all HAR specification fields or only a subset - Performance characteristics with large numbers of entries - Validation of HAR output against the official HAR specification ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 2.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags HAR file writer, HTTP archive generation, HAR format Python, write HTTP requests responses, HAR entry builder, har-format, http-testing [View on SkillFed](https://skillfed.io/packages/harfile) · [View on PyPI](https://pypi.org/project/harfile/)