Nano ID is a tiny, secure, URL-friendly, unique string ID generator for Python. It provides compact IDs that are safer and shorter than UUIDs by using a larger alphabet and cryptographically strong random APIs. The current stable version is 2.0.0, and it is actively maintained.
pip install nanoidVerified import paths — ran on the pinned version, not inferred.
Quickly generate secure, URL-friendly unique IDs. You can specify the length and a custom alphabet. A faster, non-secure generator is also available for less sensitive use cases.
If migrating from a pre-2.0.0 version, explicitly define the old alphabet and length if consistent ID generation is critical for existing data. Otherwise, IDs generated by v2.0.0 will be different by default.
Always use `generate()` for sensitive applications, which employs cryptographically strong random APIs. Only use `non_secure_generate()` when performance is critical and security is not a concern.
Always use an ID collision probability calculator (often linked in Nano ID documentation for various languages) to determine a safe ID length based on your expected number of IDs and desired collision probability.
Prefer the default URL-friendly alphabet or ensure that custom alphabets avoid problematic characters for URL contexts. If problematic characters are necessary, ensure proper URL encoding.
Avoid using NanoIDs (or UUIDs) as clustered primary keys if insert performance is critical. Consider using them as regular unique identifiers and a separate sequential primary key for clustering, or evaluate the impact on your specific database system.
Install the package using pip: `pip install nanoid`
Import the `generate` function explicitly and call it: `from nanoid import generate; id = generate()`
The correct function to generate an ID is `generate`. Use `from nanoid import generate; id = generate()` or if you must use `import nanoid`, then `id = nanoid.generate()`.
Import the correct function named 'generate': `from nanoid import generate`
No dependency data recorded yet.