Sqids (pronounced "squids") is a small, active, and community-maintained Python library that generates short, unique, and URL-safe IDs from non-negative numbers. It's commonly used for link shortening, generating IDs for public URLs or internal systems, and decoding for quicker database lookups. The current version is 0.5.2, and it follows a regular release cadence with ongoing development across various language ports.
pip install sqidsVerified import paths — ran on the pinned version, not inferred.
Initializes the Sqids encoder/decoder and demonstrates basic encoding and decoding of numbers, as well as enforcing a minimum ID length.
After decoding an ID, re-encode the resulting numbers and compare the new ID with the original to ensure canonical representation if required by your application logic.
If upgrading from versions prior to 0.3.0, be aware that existing Sqids will no longer decode to their original numbers using the new algorithm, or vice-versa. Update any stored IDs or decoding logic accordingly. Review the changelog for specific parameter and function changes.
Avoid using Sqids for any data that requires cryptographic security or where the underlying numerical values must remain confidential. Use dedicated encryption libraries for sensitive data.
Instantiate `Sqids()` at the application's startup or as a singleton, and pass the same instance to all parts of your code that need to encode or decode IDs.
Ensure that the numbers passed to `sqids.encode()` are always within a list or tuple, even if it's a single number. For example, `sqids.encode([123])` instead of `sqids.encode(123)`.
When defining a custom `alphabet`, ensure all characters are single-byte ASCII compatible. Remove any emojis or multi-byte Unicode characters from the alphabet string.
No dependency data recorded yet.