{"id":1708,"library":"shortuuid","title":"ShortUUID","description":"Shortuuid is a Python library that generates concise, unambiguous, and URL-safe UUIDs. It provides a simple API to generate UUIDs, encode integers, and decode strings using a customizable alphabet. The current version is 1.0.13, and releases are infrequent but stable, with a focus on maintenance.","status":"active","version":"1.0.13","language":"en","source_language":"en","source_url":"https://github.com/skorokithakis/shortuuid/","tags":["uuid","id generation","shortid","url-safe","unique identifier"],"install":[{"cmd":"pip install shortuuid","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"shortuuid","correct":"import shortuuid"},{"symbol":"ShortUUID (for custom alphabet)","correct":"import shortuuid\nsu = shortuuid.ShortUUID(alphabet='abcdef0123456789')"}],"quickstart":{"code":"import shortuuid\n\n# Generate a standard short UUID (default length 22)\nmy_uuid = shortuuid.uuid()\nprint(f\"Generated UUID: {my_uuid}\")\n\n# Generate a UUID of a specific length\nshort_uuid_10 = shortuuid.uuid(length=10)\nprint(f\"10-char UUID: {short_uuid_10}\")\n\n# Encode an integer to a short UUID string\nencoded_str = shortuuid.encode(123456789)\nprint(f\"Encoded integer: {encoded_str}\")\n\n# Decode a short UUID string back to an integer\ndecoded_int = shortuuid.decode(encoded_str)\nprint(f\"Decoded integer: {decoded_int}\")\n\n# Use a custom alphabet\ncustom_su = shortuuid.ShortUUID(alphabet=\"0123456789abcdef\")\ncustom_uuid = custom_su.uuid()\nprint(f\"Custom alphabet UUID: {custom_uuid}\")\n","lang":"python","description":"This quickstart demonstrates how to generate short UUIDs, specify their length, and encode/decode integers using the default and a custom alphabet."},"warnings":[{"fix":"If you need to decode UUIDs generated with older versions, you must use a `shortuuid` version compatible with their generation. For new projects, ensure all components use 1.0.0+ consistently.","message":"Version 1.0.0 changed the internal byte order for encoding/decoding from Least Significant Byte (LSB) first to Most Significant Byte (MSB) first. This means UUIDs generated with `shortuuid` < 1.0.0 cannot be decoded by `shortuuid` >= 1.0.0, and vice-versa.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Projects requiring Python 2.x must use `shortuuid` < 1.0.0. For new development, ensure Python 3.6+ is used.","message":"Python 2.x support was dropped in version 1.0.0.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Carefully consider the size and character set of your custom alphabet and the desired length. For most use cases, the default settings are sufficient. If generating many IDs, test for collision rates or stick to longer lengths/richer alphabets.","message":"Choosing a custom alphabet or a very short length for generated UUIDs can significantly increase the probability of collisions. The default alphabet and length (22 characters) are chosen for a good balance of brevity and uniqueness.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When using `shortuuid.ShortUUID(alphabet=...)`, double-check that all characters in your custom alphabet are safe for the intended environment or use additional URL/filesystem encoding if necessary.","message":"While the default alphabet is URL-safe, if you provide a custom alphabet, you are responsible for ensuring its characters are safe for your specific URL or filesystem context (e.g., avoiding characters like '/', '?', '&', '=', etc. without proper encoding).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}