Fast Nano ID

0.4.3 · active · verified Fri Apr 17

Fastnanoid is a tiny, secure, URL-friendly, and highly performant unique string ID generator for Python, leveraging a Rust implementation via PyO3. It provides a drop-in replacement for other Nano ID implementations with a focus on speed. The current version is 0.4.3, with a release cadence that has seen several minor updates and performance improvements over the past year.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `nanoid` function and generate IDs with default settings, a specified length, or a custom alphabet.

from fastnanoid import nanoid

# Generate a default Nano ID
id_default = nanoid()
print(f"Default ID: {id_default}")

# Generate a Nano ID with a specific length
id_short = nanoid(size=10)
print(f"Short ID:   {id_short}")

# Generate a Nano ID with a custom alphabet and length
id_numeric = nanoid(alphabet="0123456789", size=8)
print(f"Numeric ID: {id_numeric}")

view raw JSON →