Skip to main content

harfile

CI Coverage Version Python versions License

This package provides a zero-dependency writer for building HAR (HTTP Archive) files in Python.

NOTES:

  • The writer assumes a single-threaded environment.
  • Pages are not supported.
  • add_entry writes each entry to the file right away. If the with block raises, the file keeps the entries written so far and stays valid.
  • add_entry raises ValueError on a closed file and on NaN or Infinity numbers.
  • Naive datetime values count as local time.

Installation

pip install harfile

Usage

import datetime
import io

import harfile


# Write to a file
with harfile.open("filename.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,
        ),
    )


# Write to a string buffer
buffer = io.StringIO()
with harfile.open(buffer) as har:
    pass

License

The code in this project is licensed under MIT license. By contributing to harfile, you agree that your contributions will be licensed under its MIT license.

Metadata

Release files for harfile 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for harfile 0.7.0
File Size Uploaded Provenance Actions
harfile-0.7.0.tar.gz 11.9 kB With provenance Details for harfile-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for harfile 0.7.0
File Interpreter ABI Platform Actions
harfile-0.7.0-py3-none-any.whl Python 3 none any Details for harfile-0.7.0-py3-none-any.whl

Total release size: 19.6 kB

Release files / harfile-0.7.0.tar.gz

Download URL harfile-0.7.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
133e7fd1b8e5222d5052779307e8527906363e368971e134ae77f4f7d07d8b23
BLAKE2b-256 checksum
How to use checksums
29d3fedaa647efc81b75681dcfeb3d50619b46e6dfa2c2fa6f39d6e4f3ff4ef5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / harfile-0.7.0-py3-none-any.whl

Download URL harfile-0.7.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c81fe1da5ffdabe7627cdea545e3a6c91bc0bd62a10df53d240036c1d00e0a0
BLAKE2b-256 checksum
How to use checksums
1c7d7c2430d32d71a205aa9a57bdbcbbc77300cd02a41a1040d6f75854f33476
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for harfile 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for harfile-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page