A unified Python ID generator library.
Project description
anyID
A unified Python library for generating a variety of unique identifiers.
anyid provides a simple and consistent interface for generating different kinds of IDs, from classic UUIDs to modern sortable identifiers like ULID and KSUID. It's lightweight, type-annotated, and has minimal dependencies.
Supported Identifiers
| ID Type | Sortable | Length (chars) | URL Safe | Notes |
|---|---|---|---|---|
| CUID | Yes | 25 | Yes | Collision-resistant for horizontal scaling. |
| CUID2 | No | 24 (default) | Yes | An improved, more secure version of CUID. |
| KSUID | Yes | 27 | Yes | K-Sortable Unique Identifier. |
| NanoID | No | 21 (default) | Yes | Secure, URL-friendly, and fast. |
| ShortUUID | No | ~22 | Yes | A shorter, URL-safe version of a standard UUID. |
| Snowflake | Yes | 19 (integer) | No | Twitter's distributed, time-sortable ID generator. |
| ULID | Yes | 26 | Yes | Universally Unique Lexicographically Sortable Identifier. |
| UUID | No | 36 | No | The classic, ubiquitous UUID v4. |
| XID | Yes | 20 | Yes | Globally unique ID that is sortable by time. |
Installation
pip install anyid
Usage
The API is simple and consistent across all ID types.
from anyid import cuid, ulid, uuid
# Generate a CUID
my_cuid = cuid()
print(f"CUID: {my_cuid}")
# Generate a ULID
my_ulid = ulid()
print(f"ULID: {my_ulid}")
# Generate a UUID (v4)
my_uuid = uuid()
print(f"UUID: {my_uuid}")
Contributing
Contributions are welcome! This project uses pytest for testing and ruff and black for linting and formatting. Please feel free to open an issue or submit a pull request.
Credits
- Logo created by Grok
- Thanks Copilot for reviewing my code
- Thanks Gemini CLI for helping me with bug fixes and tests
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anyid-0.4.0.tar.gz.
File metadata
- Download URL: anyid-0.4.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04a4883181a0d656108659d2b53aa5d9f3aed6decc0cee636bedd85b8d0c0be3
|
|
| MD5 |
4c949f3ace10891516ddd1c246fd1c86
|
|
| BLAKE2b-256 |
3520c62cfa6f785a87ac31362a2f8020c236fcb8c11d63cd11f2a70c392cb646
|
Provenance
The following attestation bundles were made for anyid-0.4.0.tar.gz:
Publisher:
publish.yml on adelra/anyid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyid-0.4.0.tar.gz -
Subject digest:
04a4883181a0d656108659d2b53aa5d9f3aed6decc0cee636bedd85b8d0c0be3 - Sigstore transparency entry: 780747518
- Sigstore integration time:
-
Permalink:
adelra/anyid@8bd3e7175797005d42f964c33d8792f9def80c88 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/adelra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8bd3e7175797005d42f964c33d8792f9def80c88 -
Trigger Event:
push
-
Statement type:
File details
Details for the file anyid-0.4.0-py3-none-any.whl.
File metadata
- Download URL: anyid-0.4.0-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3311f8665893c7967daa51afefae339acf384fc90533a0be62b70be426f14051
|
|
| MD5 |
f575cd7ab36d5a20e5292cd14480792a
|
|
| BLAKE2b-256 |
459bc380c570b45babbb57d621fc5506a4e122cf7bcee0ac4ebbceabb08b40be
|
Provenance
The following attestation bundles were made for anyid-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on adelra/anyid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyid-0.4.0-py3-none-any.whl -
Subject digest:
3311f8665893c7967daa51afefae339acf384fc90533a0be62b70be426f14051 - Sigstore transparency entry: 780747519
- Sigstore integration time:
-
Permalink:
adelra/anyid@8bd3e7175797005d42f964c33d8792f9def80c88 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/adelra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8bd3e7175797005d42f964c33d8792f9def80c88 -
Trigger Event:
push
-
Statement type: