pybeerxml
A simple BeerXML parser and serializer for Python
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83527754db76300af927b4e5fdb6fda63c4a3381207034235648d852e21349fb
|
|
| MD5 |
5415b9d2b9cdb64b683a0487159ed976
|
|
| BLAKE2b-256 |
29d60ed562c733f4154883bd1cabb73c2b01c28ecf18630d3c12ec8170cd998f
|
Provenance
The following attestation bundles were made for pybeerxml-3.0.0.tar.gz:
Publisher:
publish_pypi.yml on hotzenklotz/pybeerxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybeerxml-3.0.0.tar.gz -
Subject digest:
83527754db76300af927b4e5fdb6fda63c4a3381207034235648d852e21349fb - Sigstore transparency entry: 2207588845
- Sigstore integration time:
-
Permalink:
hotzenklotz/pybeerxml@fb77711ce8dbc45932527ab1dad695950df2e6ef -
Branch / Tag:
refs/tags/v3.0.0rc1 - Owner: https://github.com/hotzenklotz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@fb77711ce8dbc45932527ab1dad695950df2e6ef -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e07e3eeb3bde085d9b0cd7ddc0b56fc2f008d5f82d1fe7ec4d360a747eef1f69
|
|
| MD5 |
be5861d2b54c38a5e0f5682c33ad70dc
|
|
| BLAKE2b-256 |
55ac9d018c92c88abe5308d1c6247e6ae4b7ad42f9652bcba2492f20397ceede
|
Provenance
The following attestation bundles were made for pybeerxml-3.0.0-py3-none-any.whl:
Publisher:
publish_pypi.yml on hotzenklotz/pybeerxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybeerxml-3.0.0-py3-none-any.whl -
Subject digest:
e07e3eeb3bde085d9b0cd7ddc0b56fc2f008d5f82d1fe7ec4d360a747eef1f69 - Sigstore transparency entry: 2207588876
- Sigstore integration time:
-
Permalink:
hotzenklotz/pybeerxml@fb77711ce8dbc45932527ab1dad695950df2e6ef -
Branch / Tag:
refs/tags/v3.0.0rc1 - Owner: https://github.com/hotzenklotz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@fb77711ce8dbc45932527ab1dad695950df2e6ef -
Trigger Event:
release
-
Statement type: