typeid-python is a Python implementation of TypeIDs, offering type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs. It is actively maintained with frequent releases, focusing on performance, robustness, and developer experience.
pip install typeid-pythonVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to generate a new TypeID, extract its components, convert it to and from its string representation, and compare TypeID objects.
Upgrade your Python environment to version 3.10 or later. For example, `pyenv install 3.10.12 && pyenv local 3.10.12`.
Ensure all TypeID prefixes conform to the regex `[a-z]{0,63}` (lowercase alphanumeric, max 63 characters).No direct fix is typically needed as the library handles fallbacks. However, for optimal performance, ensure a compatible environment for Rust-powered wheels. Check documentation for specific platform build troubleshooting if performance is critical and seems suboptimal.
Upgrade to `typeid-python` version 0.3.9 or later to ensure correct Pydantic JSON schema generation for FastAPI/OpenAPI integrations.
Install the library using pip: `pip install typeid-python`. Then import using `from typeid import TypeID`.
Ensure the input string is a valid TypeID format. Implement error handling with a `try-except ValueError` block for robustness.
Convert the `TypeID` object to its string representation using `str(typeid_obj)` or `typeid_obj.typeid` before JSON serialization.
Ensure the prefix consists only of lowercase ASCII letters (a-z) and has a maximum length of 63 characters.