skillfed

harfile

Writer for HTTP Archive (HAR) files

harfile v0.5.0 2.7M downloads/30d#2,909 on PyPI2
Permissive license MIT Active released

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 on this page — 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

harfile on PyPI

pip

pip install harfile

uv

uv add harfile

poetry

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 the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 77 days since the last release
Last repo commit
First released
Downloads 2,744,639/month — #2,909 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: harfile-0.5.0-py3-none-any.whl

Keywords: har, http, testing

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Testing

Tags

HAR file writerHTTP archive generationHAR format Pythonwrite HTTP requests responsesHAR entry builder
har-formathttp-testing

More Testing packages