Skip to main content

vastlint (Python)

High-performance, in-process VAST XML validation for Python backends.

Rule reference: vastlint.org/docs/rules · Web validator: vastlint.org/validate · Test a live tag URL: vastlint.org/tester · Inspect wrapper chains: vastlint.org/inspect

This package wraps the stable vastlint-ffi C API, backed by the same Rust core used by the CLI, Go binding, Ruby gem, Erlang NIF, MCP server, and web validator. The intended use case is a DSP, SSP, ad server, or trafficking backend that needs to validate VAST XML and return structured linting results to a frontend.

Why this shape

  • No subprocess management in your Python app
  • No network hop to an external validation service
  • Stable JSON-compatible result shape for backend-to-frontend responses
  • Same rule coverage and behavior as the rest of the vastlint ecosystem

Install

The package bundles a platform-matched libvastlint shared library inside the wheel, so no compiler or Rust toolchain is needed at install time.

pip install vastlint

You can also point the package at an explicit shared library with VASTLINT_LIB_PATH:

export VASTLINT_LIB_PATH=/absolute/path/to/libvastlint.dylib

For development in this monorepo, it automatically falls back to the sibling vastlint/target/debug and vastlint/target/release outputs.

Usage

import vastlint

result = vastlint.validate(vast_xml)

if result.valid:
    print("clean tag")
else:
    print(result.summary.errors)
    print(result.issues[0].message)

print(result.to_json())

Shareable report links

Need a link instead of raw output? The vastlint CLI can upload a validation report (rule IDs, severities, and locations; never the input XML) and print a public URL you can paste into Slack, tickets, or PRs:

vastlint check tag.xml --share
# https://vastlint.org/r/<id>

FastAPI / Flask example

from fastapi import FastAPI
from pydantic import BaseModel
import vastlint

app = FastAPI()


class ValidateRequest(BaseModel):
    xml: str
    wrapper_depth: int = 0
    max_wrapper_depth: int = 5
    rule_overrides: dict[str, str] | None = None


@app.post("/validate")
def validate(req: ValidateRequest):
    result = vastlint.validate(
        req.xml,
        wrapper_depth=req.wrapper_depth,
        max_wrapper_depth=req.max_wrapper_depth,
        rule_overrides=req.rule_overrides,
    )
    return result.to_dict()

The response shape is stable and frontend-friendly:

{
  "version": "4.2",
  "issues": [
    {
      "id": "VAST-2.0-inline-impression",
      "severity": "error",
      "message": "<InLine> must contain at least one <Impression>",
      "path": "/VAST/Ad[0]/InLine",
      "spec_ref": "IAB VAST 2.0 §2.2.1",
      "line": 4,
      "col": 3
    }
  ],
  "summary": { "errors": 1, "warnings": 0, "infos": 0, "valid": false }
}

API

vastlint.validate(xml, *, wrapper_depth=0, max_wrapper_depth=5, rule_overrides=None) -> Result
vastlint.version() -> str

xml accepts str or bytes. rule_overrides maps rule IDs to severity levels:

result = vastlint.validate(
    vast_xml,
    rule_overrides={
        "VAST-2.0-mediafile-https": "error",
        "VAST-4.1-mezzanine-recommended": "off",
    },
)

Result exposes .version, .issues (list of Issue), .summary (Summary), .valid, .to_dict(), and .to_json(). All result types are frozen dataclasses.

Performance

Validation runs in-process against the Rust core, so per-tag cost is dominated by the core, not by Python. Numbers below are single-core, single-threaded, and include the full Python round trip (FFI call, JSON result, parse into dataclasses), so they reflect what a caller actually sees.

Tag size Median latency Throughput (1 core)
7 KB 86 µs ~11,000 tags/sec
17 KB 0.36 ms ~2,800 tags/sec
23 KB 0.57 ms ~1,700 tags/sec
44 KB 2.1 ms ~470 tags/sec
347 KB 4.7 ms ~210 tags/sec

Measured on an Apple M4, single core, 200 tags per size bucket, warm. Production tags typically run 17 to 44 KB. Each validation is independent and holds no shared state, so throughput scales close to linearly across cores with a process pool. Reproduce with scripts/bench.py.

Native library layout

Vendored release libraries live at:

  • src/vastlint/native/darwin_arm64/libvastlint.dylib
  • src/vastlint/native/darwin_amd64/libvastlint.dylib
  • src/vastlint/native/linux_arm64/libvastlint.so
  • src/vastlint/native/linux_amd64/libvastlint.so

They come from the vastlint-ffi-* tarballs attached to each vastlint GitHub Release. Refresh them with:

./scripts/fetch-libs.sh v0.4.14

License

Apache 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vastlint-0.8.4.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

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

vastlint-0.8.4-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file vastlint-0.8.4.tar.gz.

File metadata

  • Download URL: vastlint-0.8.4.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for vastlint-0.8.4.tar.gz
Algorithm Hash digest
SHA256 2768b26c5129b3bae77fee28cd8ac34416c4bba4f8cbdf664b7daf0137fbec59
MD5 c4e85514683f3b12e46c3319fe0770d9
BLAKE2b-256 c7fdf250bfa8d5161bed3c8b4b19a7fd614069bad31c44b6f519f411d7940f1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for vastlint-0.8.4.tar.gz:

Publisher: publish-pypi.yml on aleksUIX/vastlint-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vastlint-0.8.4-py3-none-any.whl.

File metadata

  • Download URL: vastlint-0.8.4-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for vastlint-0.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f05c422632a08d4472dd5cf68d94e6e91957a7c9b74e46b7228cd9b86566af45
MD5 85084246b4f02cb77becd55a476db575
BLAKE2b-256 b9aea70c5a617f949a482e6402b89c2b86ce01b587e79d599580cd1212946ae9

See more details on using hashes here.

Provenance

The following attestation bundles were made for vastlint-0.8.4-py3-none-any.whl:

Publisher: publish-pypi.yml on aleksUIX/vastlint-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.13.9

2 files

0.13.8

2 files

0.13.7

2 files

0.13.6

2 files

0.13.5

2 files

0.11.8

2 files

0.11.7

2 files

0.11.6

2 files

0.11.5

2 files

0.11.4

2 files

0.11.3

2 files

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.9.1

2 files

0.9.0

2 files

This release

0.8.4 This release

2 files

0.8.1

2 files

0.8.0

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.4.14

2 files

0.0.1

2 files

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