{"id":5059,"library":"slugid","title":"slugid","description":"slugid is a Python library (version 2.0.0, released 2019) for generating URL-safe Base64 encoded UUID v4 slugs. These 22-character slugs are compact and can be easily embedded in URLs, command-line parameters, or used as identifiers in various systems. It provides methods for generating standard v4 slugs and 'nice' slugs which always start with an alphanumeric character. The library is currently in maintenance mode with its GitHub repository archived, meaning it's no longer actively developed but remains functional.","status":"maintenance","version":"2.0.0","language":"en","source_language":"en","source_url":"https://github.com/taskcluster/slugid.py","tags":["uuid","slug","url-safe","base64","identifier","unique-id","maintenance"],"install":[{"cmd":"pip install slugid","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used internally by slugid for UUID generation; part of Python's standard library.","package":"uuid","optional":false}],"imports":[{"note":"Generates a standard URL-safe v4 UUID slug.","symbol":"v4","correct":"import slugid; slugid.v4()"},{"note":"Generates a 'nice' v4 UUID slug that is guaranteed not to start with '-', suitable for command-line arguments.","symbol":"nice","correct":"import slugid; slugid.nice()"}],"quickstart":{"code":"import slugid\n\n# Generate a standard v4 slug\nstandard_slug = slugid.v4()\nprint(f\"Standard Slug: {standard_slug}\")\n\n# Generate a 'nice' slug (guaranteed not to start with '-')\nnice_slug = slugid.nice()\nprint(f\"Nice Slug: {nice_slug}\")\n\n# Decode a slug back to a UUID string (requires converting to a full UUID object first)\n# For full round-trip, you might need to use the `uuid` library directly or a helper function\nimport uuid\n\ndef decode_slugid(slug):\n    # slugid's internal decode function isn't directly exposed for all use cases\n    # This demonstrates the principle of converting to UUID\n    # Note: slugid itself primarily focuses on *generating* slugs from UUIDs\n    # To decode, you'd typically base64url decode the 22-char string and then reconstruct UUID\n    # The underlying Python `uuid` library handles the canonical UUID representation.\n    # A direct decode function for the slugid string to uuid.UUID object is not directly exposed for Python slugid library itself, \n    # but the concept relies on standard base64url decoding.\n    # For simplicity, if you have a UUID string, you can convert it to a slugid. \n    # Let's show how to convert a UUID string to slugid, and then conceptually, it could be reversed if a direct method was exposed.\n    return uuid.UUID(bytes=uuid.b64decode(slug + '==')) #Conceptual decoding, might need adjustments based on exact implementation\n\n# Example of encoding a UUID to a slug\nsome_uuid = uuid.uuid4()\nencoded_slug = slugid.encode(some_uuid)\nprint(f\"UUID {some_uuid} encoded to slug: {encoded_slug}\")\n\n# While slugid.py doesn't expose a direct `decode` for the slug string to uuid.UUID\n# the underlying principle is base64url decoding, which can be done with `uuid` module's helper functions.\n","lang":"python","description":"Generate both standard and 'nice' URL-safe slugs. The example also briefly touches on the conceptual decoding back to a UUID, though the library primarily focuses on slug generation from UUIDs."},"warnings":[{"fix":"Use `slugid.nice()` if the slug will be used in contexts sensitive to leading hyphens (e.g., command-line arguments). Use `slugid.v4()` for maximum entropy where leading hyphens are not an issue.","message":"Choosing between `slugid.v4()` and `slugid.nice()`: `nice()` slugs are guaranteed not to start with a hyphen (`-`), making them safer for use in command-line arguments. However, this comes at a slight cost of entropy (121 bits for `nice()` vs. 122 bits for `v4()`). Consider your specific use case to decide which method is appropriate.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using the correct library for your task: `slugid` for UUID encoding, or `python-slugify` for general text slugification.","message":"This `slugid` library (for encoding UUIDs) is distinct from `python-slugify` (for slugifying arbitrary text strings). Do not confuse their purposes; `slugid` focuses specifically on compact, URL-safe UUID representations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that active development has ceased. Consider stability and lack of new features when integrating or relying heavily on this library. The core functionality remains solid, but no future updates are expected.","message":"The GitHub repository for the Python `slugid` library (`taskcluster/slugid.py`) has been archived. This indicates that the project is no longer under active development and is in maintenance mode. While it remains functional, new features or significant bug fixes are unlikely.","severity":"deprecated","affected_versions":"2.0.0 and potentially future versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}