TypeID Python

0.3.10 · active · verified Wed Apr 15

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.

Warnings

Install

Imports

Quickstart

This example demonstrates how to generate a new TypeID, extract its components, convert it to and from its string representation, and compare TypeID objects.

from typeid import TypeID

# Generate a new TypeID with a prefix (uses a new UUIDv7 internally)
user_id = TypeID("user")
print(f"Generated TypeID: {user_id}")
print(f"Prefix: {user_id.prefix}")
print(f"UUID: {user_id.uuid}") # Raw UUID object

# Get the string representation
user_id_str = str(user_id)
print(f"String representation: {user_id_str}")

# Parse a TypeID from a string
parsed_id = TypeID.from_string(user_id_str)
print(f"Parsed TypeID: {parsed_id}")

# Compare TypeIDs
assert user_id == parsed_id

view raw JSON →