Skip to main content

crafting-sim

crafting_sim is a deterministic Path of Exile 2 crafting simulator: Python bindings for the Rust core that also powers the browser simulator. All crafting game data is embedded in the compiled extension at build time, identified by crafting_sim.DATA_VERSION and crafting_sim.CATALOG_DIGEST. Same seed → same outcomes, so crafts are reproducible and success rates measurable.

Install

pip install optimalexile-crafting-sim

PyPI ships Linux x86_64/aarch64 wheels for Python ≥ 3.13 only (no sdist), so other platforms cannot install from PyPI.

Documentation

python -m crafting_sim docs
python -m crafting_sim docs references/concepts/mechanics.md
python -m crafting_sim docs all

The first command lists the bundled mechanics, worked recipes and measurement guidance; the others read one document or all of them. Start with references/concepts/getting-started.md. Per-operation descriptions, mechanics, Omens and effects come from the catalog. Everything works without network access. crafting_sim.documentation_index() and crafting_sim.read_documentation(path) provide the same lookup API in-process.

Discover, don't memorize

The library explains itself; query it instead of relying on game knowledge.

from crafting_sim import catalog
from crafting_sim.data import Base, Bone, Catalyst, Essence, Family, Liquid, Omen, Socketable

catalog.bases          # every craftable base: id, name, item class, tags
catalog.operations     # every operation: description, mechanics, tier, related Omens
catalog.omens          # Omens with full rule text and operation family
catalog.essences       # per-item-class guaranteed outcomes of each essence
catalog.liquids        # per-jewel guaranteed outcomes of each Delirium liquid
catalog.bones          # desecration rules: item classes, min revealed modifier level
catalog.socketables    # rune effects per item class, and the tags they add
catalog.mod_pool(Base.SAPPHIRE_RING)   # eligible roll contexts for a base
catalog.modifier("FireResist8")        # one modifier: text, families, tags

Every crafting_sim.data enum member carries its in-game description as its docstring — help(Essence.ESSENCE_OF_THE_BODY) or member.__doc__ answers "what does this do?", including what an essence guarantees per item class. To answer it for a specific item class:

by_name = {e.name: e for e in catalog.essences}
effect = by_name["Essence of the Body"].effect_for_item_class("Ring")
effect.text                      # "+(60-69) to maximum Life" style summary
effect.mods                      # guaranteed modifier ids with weights

Core loop

from crafting_sim import Item, Tier, ops
from crafting_sim.data import Base, Family, Omen

item = Item(Base.SOLAR_AMULET, item_level=82, seed=42)
item.transmute().augment().regal().exalt()      # chainable currency verbs
item.chaos(tier=Tier.PERFECT)                   # tiered currencies take a Tier
item.apply_until(                               # bounded engine-native loops
    ops.chaos(Tier.PERFECT),
    family=Family.FIRE_RESISTANCE,
    min_tier=2,
    max_applications=100_000,
)
item.mods, item.prefixes, item.open_suffixes    # inspect state
item.mod_pool()                                 # modeled weights + add_as, per item
item.has_mod(Family.BASE_SPIRIT, tier=1)        # query by family/tier/slot/id;
                                                # min_tier means "or better"

item.can_apply(ops.exalted())                   # validity check, no mutation
dist = item.outcomes(ops.exalted())             # exact next-step distribution
dist.probability(lambda it: it.has_mod(Family.BASE_SPIRIT, tier=1))

item.set_active_omens([Omen.SINISTRAL_EXALTATION])  # omens are item state
branch = item.copy()  # exact clone, including the current random stream
item.undo()           # step back one recorded run
item.reset()          # back to the starting base, same seed
item.reseed(7)        # replay all steps under a different seed
item.currency_used    # Counter of every currency consumed so far

Direct calls remain separate undo steps. Batch a loop that is one logical run, so its repeated operations share a history row and undo boundary:

with item.batch():
    for _ in range(100):
        item.chaos()

Different operations and nested batches keep separate boundaries, and apply_until batches internally. A batch is not a transaction: successful changes remain if the block raises.

Override embedded modifier weights to test corrected or experimental roll data. Changes affect future rolls only and survive replay exports; an empty mapping restores the canonical weights:

item.set_mod_weight_overrides({"FireResist8": 25_000})
item.chaos()
item.set_mod_weight_overrides({})

Every currency has both a verb (item.essence(...)) and an ops constructor (ops.essence(...)) for can_apply/outcomes.

Everything is strongly typed. Small structural values such as Tier, Rarity, and Slot are integer-backed enums; bases, mod families, essences, liquids, omens, and catalysts are generated StrEnums under crafting_sim.data whose values are canonical game-data IDs. Item mutates in place and verbs chain; equal items have the same canonical state. currency_used derives from session history, so failed operations are not counted and copies retain their usage.

Recipes

Estimate success odds and cost empirically. Deterministic seeds turn any strategy function into a measurable experiment:

from collections import Counter
from crafting_sim import Item, ops
from crafting_sim.data import Base, Family
from crafting_sim.pricing import poe2_currency_rates_from_env, value_currency_usage

rates = poe2_currency_rates_from_env()  # None unless OPTIMALEXILE_PRICES is set
used, hits, trials = Counter(), 0, 500
for seed in range(trials):
    item = Item(Base.SAPPHIRE_RING, item_level=82, seed=seed)
    item.alchemy()
    spent = item.apply_until(
        ops.chaos(), family=Family.FIRE_RESISTANCE, tier=1, max_applications=10_000
    )
    if spent is not None:
        hits += 1
    used.update(item.currency_used)
print(hits / trials, value_currency_usage(used, rates).total_divines)

Start from a real item, then keep crafting it:

# The primary path: this library's own export JSON round-trips exactly.
payload = item.export_item()                # canonical JSON to persist/share
ingame = item.export_ingame_text()          # advanced text for Path of Building
item = Item.from_paste(payload, seed=7)     # restore and keep crafting
item = Item.from_text(game_text)            # in-game copy (Ctrl+Alt+C) format
item = Item.from_trade_listing(trade_json)  # trade-site listing JSON
# from_paste auto-detects all three; export_replay/from_replay additionally
# reproduce the full crafting history, not just the final state.
item.uncorrupt().unsanctify()               # free edits; uncorrupt drops corruption mods
item.exalt()

Screenshot and other partial adapters can submit source-neutral evidence without manufacturing clipboard text:

item, report = Item.from_evidence({
    "base": {"name": "Gold Amulet", "item_class": "Amulet"},
    "rarity": "Rare",
    "item_level": {"assumed": 100},
    "implicits": [["18% increased Rarity of Items found"]],
    "modifiers": [
        {"affix": "Suffix", "tier": 1,
         "lines": ["+3 to Level of all Projectile Skills"]},
    ],
    "unrevealed_desecrated": ["Prefix"],
})

An observed item level is written directly as a number. null raises EvidenceImportError with kind MissingItemLevel; assumptions are always returned in report.assumptions.

Imports start a fresh session from the supplied seed (no history, usage, or Omens carry over). Exports record their source data version for provenance, but compatible canonical IDs keep importing across versions, and the same payload round-trips with the browser simulator's Copy item button.

Hand a session to the browser — crafting_sim.share uploads a replay to the same Cloudflare share service used by the website:

from crafting_sim.share import create_share, share_url

code = create_share(item.export_replay())
print(share_url(code))  # https://craft.optimalexile.com/s/...

Item.from_paste(code)  # or read a shared code back, history included

Opening that URL resumes the exact session in the browser simulator. Creating or loading a share requires network access; direct replay and item imports remain fully local.

The worked strategies and the mechanics behind them live in the bundled documentation (python -m crafting_sim docs). The distinctive API corners:

Delirium liquids — replace one modifier on a Rare Basic or Time-Lost Jewel with the jewel-specific Crafted modifier described by catalog.liquids:

item = Item(Base.RUBY, item_level=82, seed=3).alchemy()
item.liquid(Liquid.POTENT_LIQUID_CONTEMPT)
# The Crafted result grants one additional prefix or suffix slot.
# Potent Liquid Ferocity instead scales explicit prefixes or suffixes.

Flux — transform every eligible resistance modifier while keeping other modifiers and implicits intact:

from crafting_sim import Item, Rarity
from crafting_sim.data import Base, Flux

item = Item(Base.CRIMSON_AMULET, item_level=82, rarity=Rarity.RARE, seed=3)
item.add_mod("FireResist8").flux(Flux.VOID)

Desecration pools without rolling an offer — compose a bone's bounded application outcomes with desecration_reveal_pool:

for outcome, probability in item.outcomes(ops.desecration(Bone.ANCIENT_COLLARBONE)):
    (slot,) = outcome.unrevealed_slots
    pool = outcome.desecration_reveal_pool(slot)
    abyssal = sum(
        candidate.weight
        for candidate in pool.candidates
        if candidate.pool is DesecrationCandidatePool.ABYSSAL
    )
    print(probability, len(pool.candidates), abyssal)

Catalysts — one catalyst() call takes the quality straight to the cap and spends a catalyst per point, so switching type later costs no more than the first application. A catalyst already at the cap is refused (can_apply returns False, catalyst() raises).

Socketables — socket() consumes the currency; the set_socketable/ add_socket edits reshape sockets for free when modeling an item instead:

item = Item(Base.SIRENSCALE_GLOVES, item_level=82, seed=4)
item.add_socket()                          # free edit: create the socket first
item.socket(Socketable.IRON_RUNE, slot=0)  # consumes the rune currency
item.set_socketable(Socketable.DESERT_RUNE, slot=0)  # free swap when modeling

Affixes gated by socketables — warping runes like Kolr's Hunt add an item tag (here marksman) while socketed, and that tag unlocks an extra affix pool the base cannot otherwise roll:

item = Item(Base.SIRENSCALE_GLOVES, item_level=81, rune_sockets=2, seed=6)
item.socket(Socketable.KOLR_S_HUNT, slot=0)   # adds the "marksman" tag
item.transmute().augment().regal()
# influence mods roll like any explicit mod — chaos, exalt, reveals, fracturing
item.apply_until(ops.chaos(), id="MarksmanInfluenceProjectileSpeed3", max_applications=10_000)
item.set_socketable(None, slot=0)
item.has_mod(id="MarksmanInfluenceProjectileSpeed3")  # True: rolled mods stay

catalog.mod_pool(Base.SIRENSCALE_GLOVES) lists these MarksmanInfluence* mods. Without the rune's tag, item.mod_pool() reports their effective_weight as zero — entry.unlock_tag marks them, and catalog.socketables says which rune supplies the tag for a given item class.

Complete worked crafts ship inside the package — run them, or read their source for the full multi-stage patterns (fracture restarts, omen dances, reveal loops, blocker modifiers):

python -m crafting_sim.examples.kurgal_solar_amulet
python -m crafting_sim.examples.kolrs_hunt_gloves
python -m crafting_sim.examples.thunder_dueling_wand

Each run prints a mean currency cost table and, below it, a share link that reopens the last craft in the browser simulator with its full history.

Gotchas

  • Pricing sources: the package ships no prices, so value_currency_usage requires an explicit rates argument. With rates=None every entry is reported in valuation.missing and total_divines is None, rather than valued against stale numbers. Real rates come from poe2_currency_rates_from_env(), which reads OPTIMALEXILE_PRICES — live to fetch, or a path to a JSON file holding the complete live API response — together with POE2_LEAGUE. Unset returns None; loading errors propagate instead of silently falling back.
  • Omens are item state, set via set_active_omens/toggle_omen, not per-call arguments; they persist until cleared or consumed.
  • ImportError mentioning DATA_VERSION/API_VERSION means the generated enums and compiled core are out of sync — only relevant when building from the repo (just dev, just gen-enums).
  • Free edits (add_mod, set_rarity, uncorrupt, unsanctify, socket edits) bypass crafting rules by design; use currency verbs when simulating legitimate crafts.

Everything below applies only to developing this package inside the optimalexile monorepo — not to using the installed library.

Development

crates/crafting-sim-api/docs/ is the documentation source shared by the Python and browser bindings. The Markdown is embedded in both compiled artifacts.

just dev        # rebuild the extension into the uv venv after Rust changes
just test       # pytest
just lint       # ruff + mypy
just gen-enums  # regenerate crafting_sim/data/_generated.py after a data update

The extension crate lives at crates/crafting-sim-py and consumes the same crafting-sim-api catalog, import, replay, and query contract as the WebAssembly binding. Queries such as has_mod execute in Rust.

Releases

.github/workflows/python-release.yml publishes the manylinux x86_64 and aarch64 abi3 wheels; no sdist. To cut a release: bump version in pyproject.toml and [workspace.package] version in the root Cargo.toml to the same value, then push a vX.Y.Z tag — CI fails if the three disagree.

Metadata

Release files for optimalexile-crafting-sim 0.5.7

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

Built distributions (wheels)

Table of built distributions (wheels) for optimalexile-crafting-sim 0.5.7
File Interpreter ABI Platform Actions
optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_x86_64.whl CPython 3.13 abi3 Linux glibc 2.28+ x86-64 Details for optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_x86_64.whl
optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_aarch64.whl CPython 3.13 abi3 Linux glibc 2.28+ ARM64 Details for optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_aarch64.whl

Total release size: 8.1 MB

Release files / optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_x86_64.whl

Download URL optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
000c7a393e4fa9f3214825b940efb276bd8228c9a135d393105706513bad7ac4
BLAKE2b-256 checksum
How to use checksums
2e0953ef50dc27f3774f0b84b699a3e8fd6c17c389462ea7c66ae01c4fbdd57f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 11, 2026.

Transparency log

Release files / optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_aarch64.whl

Download URL optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_aarch64.whl
Size 3.8 MB
Tags CPython 3.13 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a7f7422879b14e7fd678f6dcb94c3b690854fd44c20552cde367b2fc893adadb
BLAKE2b-256 checksum
How to use checksums
624ba3027d41d40c5d4ff44932b2d7eaded826e819957833fb5ef36f6e15b138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 11, 2026.

Transparency log

Security for optimalexile-crafting-sim 0.5.7

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 optimalexile_crafting_sim-0.5.7-cp313-abi3-manylinux_2_28_x86_64.whl

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 Aug 11, 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