Skip to main content

pybeerxml

A simple BeerXML parser and serializer for Python

PyPi Version Build Status Code Style Docs

Parses all recipes within a BeerXML file and returns Recipe objects containing all ingredients, style information and metadata. OG, FG, ABV and IBU are calculated from the ingredient list. (your milage may vary). Recipes can also be serialized back to BeerXML. All models are built on pydantic and pydantic-xml.

Installation

pip install pybeerxml

Usage

Full documentation is available at pybeerxml.onrender.com.

from pybeerxml import Parser

path_to_beerxml_file = "/tmp/SimcoeIPA.beerxml"

parser = Parser()
recipes = parser.parse(path_to_beerxml_file)

for recipe in recipes:

    # some general recipe properties
    print(recipe.name)
    print(recipe.brewer)

    # calculated properties
    print(recipe.og)
    print(recipe.fg)
    print(recipe.ibu)
    print(recipe.abv)

    # iterate over the ingredients
    for hop in recipe.hops:
        print(hop.name)

    for fermentable in recipe.fermentables:
        print(fermentable.name)

    for yeast in recipe.yeasts:
        print(yeast.name)

    for misc in recipe.miscs:
        print(misc.name)

Serialization

Write recipes back to BeerXML with the Serializer class. Only values stored in the XML-backed fields are written — calculated properties (og_calculated, og_plato, etc.) are never serialized. The stored values for OG, FG, IBU, ABV and color live in the trailing-underscore fields og_, fg_, ibu_, abv_ and color_.

from pybeerxml import Parser, Serializer

parser = Parser()
recipes = parser.parse("/tmp/SimcoeIPA.beerxml")

serializer = Serializer()

# serialize to a string
xml_string = serializer.serialize(recipes)

# or write to a file
serializer.write(recipes, "/tmp/SimcoeIPA-copy.beerxml")

Since all models are pydantic models, you can also build recipes programmatically:

from pybeerxml import Serializer
from pybeerxml.recipe import Recipe
from pybeerxml.hop import Hop

recipe = Recipe(name="My IPA", batch_size=20.0)
recipe.hops.append(Hop(name="Simcoe", alpha=13.0, amount=0.05, use="boil", time=60))

print(recipe.og_calculated)

xml_string = recipe.to_xml_string()

Testing

Unit tests can be run with pytest:

uv run pytest

Contributing / Development

Community contributions are welcome.

Install uv, then sync dependencies:

uv sync

Make sure to test, lint, format, and type-check your code before sending a pull request:

uv run pytest
uv run ruff format .
uv run ruff check .
uv run ty check pybeerxml

License

MIT

Download files

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

Source Distribution

pybeerxml-3.0.0.tar.gz (119.6 kB view details)

Uploaded Source

Built Distribution

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

pybeerxml-3.0.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file pybeerxml-3.0.0.tar.gz.

File metadata

  • Download URL: pybeerxml-3.0.0.tar.gz
  • Upload date:
  • Size: 119.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pybeerxml-3.0.0.tar.gz
Algorithm Hash digest
SHA256 83527754db76300af927b4e5fdb6fda63c4a3381207034235648d852e21349fb
MD5 5415b9d2b9cdb64b683a0487159ed976
BLAKE2b-256 29d60ed562c733f4154883bd1cabb73c2b01c28ecf18630d3c12ec8170cd998f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybeerxml-3.0.0.tar.gz:

Publisher: publish_pypi.yml on hotzenklotz/pybeerxml

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

File details

Details for the file pybeerxml-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: pybeerxml-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pybeerxml-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e07e3eeb3bde085d9b0cd7ddc0b56fc2f008d5f82d1fe7ec4d360a747eef1f69
MD5 be5861d2b54c38a5e0f5682c33ad70dc
BLAKE2b-256 55ac9d018c92c88abe5308d1c6247e6ae4b7ad42f9652bcba2492f20397ceede

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybeerxml-3.0.0-py3-none-any.whl:

Publisher: publish_pypi.yml on hotzenklotz/pybeerxml

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

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 files

2.2.0

2 files

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

1 file

1.0

1 file

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