Skip to main content

Modern, type-safe, and extensible library for parsing, transforming, and analyzing HAR (HTTP Archive) files.

Project description

Hario Core — Type-safe HAR Model & Transform

PyPI version Build Status Code style: black codecov

A modern, extensible, and type-safe Python library for parsing, transforming, and analyzing HAR (HTTP Archive) files. Built on Pydantic, Hario-Core provides robust validation, flexible transformation, and easy extension for custom HAR formats.

Features

  • Type-Safe Parsing: Validates HAR files using Pydantic models, catching errors early.
  • Transformers: Apply built-in or custom transformations to each HAR entry (e.g., flatten, normalizations).
  • Normalization: Ensures all numeric fields (sizes, timings) are non-negative, so you can safely sum, aggregate, and analyze data without errors from negative values. This is crucial for analytics and reporting.
  • Deterministic & Random IDs: Generate unique or deterministic IDs for each entry. Deterministic IDs ensure that the same request always gets the same ID—useful for deduplication, comparison, and building analytics pipelines.
  • Extensible: Register your own entry models to support browser-specific or proprietary HAR extensions (e.g., Chrome DevTools, Safari).
  • Composable Pipelines: Chain any number of transformers and ID strategies for flexible data processing.

Installation

pip install hario-core

Quickstart

1. Parse and validate a HAR file

from hario_core import parse

har_log = parse("example.har")
entries = har_log.model_dump()["entries"]  # list of dicts

2. Transform entries with a pipeline

from hario_core.transform import Pipeline, flatten, set_id, by_field

pipeline = Pipeline([
    set_id(by_field(["request.url", "startedDateTime"]))
])
results = pipeline.process(entries)

3. Custom entry models (extensions)

from hario_core.parse import register_entry_model
from hario_core.models import Entry

def is_custom_entry(entry: dict) -> bool:
    return "x-custom" in entry

class CustomEntry(Entry):
    x_custom: str

register_entry_model(is_custom_entry, CustomEntry)

Public API

Parsing and validation

  • parse(path_or_bytes_or_filelike) -> HarLog
  • validate(har_dict: dict) -> HarLog
  • register_entry_model(detector: Callable, model: Type[Entry])
  • entry_selector(entry_dict: dict) -> Type[Entry]

Models

  • Entry, HarLog, DevToolsEntry (and all standard HAR 1.2 models)

Transform

  • Pipeline, flatten, normalize_sizes, normalize_timings, set_id, by_field, uuid, json_array_handler

Documentation

License

MIT License. See LICENSE.

Supported Python Versions

  • Python 3.10+

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

hario_core-0.4.1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hario_core-0.4.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file hario_core-0.4.1.tar.gz.

File metadata

  • Download URL: hario_core-0.4.1.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Darwin/23.6.0

File hashes

Hashes for hario_core-0.4.1.tar.gz
Algorithm Hash digest
SHA256 94b407471ee2e2c09652638e59e91edc402747aa3fbb8c60ccee07726f0fec4a
MD5 d8c19035a7735a42fa54fb84eaee282d
BLAKE2b-256 a67f019e0dffdb65b771cb245c8b922f2d54698ebaff89be3a048fed024f325c

See more details on using hashes here.

File details

Details for the file hario_core-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: hario_core-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Darwin/23.6.0

File hashes

Hashes for hario_core-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15edc545c8a6a82db54e26ff1103ad3274689dd260cc9bb8d72ff0308a64ca1a
MD5 cf3189a14fe0b91fb8c43900bb890066
BLAKE2b-256 4849fcb48e073f25567d7c1deb1b420ee528576f8e81b1b10f13e734bd963be5

See more details on using hashes here.

Supported by

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