typeid-python


Nametypeid-python JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/akhundMurad/typeid-python
SummaryPython implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
upload_time2024-06-16 13:20:13
maintainerNone
docs_urlNone
authorMurad Akhundov
requires_python<4,>=3.8
licenseMIT
keywords typeid uuid uuid6 guid
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TypeID Python

<a href="https://github.com/akhundMurad/typeid-python/actions?query=setup%3ACI%2FCD+event%3Apush+branch%3Amain" target="_blank">
    <img src="https://github.com/akhundMurad/typeid-python/actions/workflows/setup.yml/badge.svg?event=push&branch=main" alt="Test">
</a>
<a href="https://pepy.tech/project/typeid-python" target="_blank">
    <img src="https://static.pepy.tech/personalized-badge/typeid-python?period=total&units=international_system&left_color=black&right_color=red&left_text=downloads" alt="Downloads">
</a>
<a href="https://pypi.org/project/typeid-python" target="_blank">
    <img src="https://img.shields.io/pypi/v/typeid-python?color=red&labelColor=black" alt="Package version">
</a>
<a href="https://pypi.org/project/typeid-python" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/typeid-python.svg?color=red&labelColor=black" alt="Supported Python versions">
</a>

## A Python implementation of [TypeIDs](https://github.com/jetpack-io/typeid) using Python

TypeIDs are a modern, **type-safe**, globally unique identifier based on the upcoming
UUIDv7 standard. They provide a ton of nice properties that make them a great choice
as the primary identifiers for your data in a database, APIs, and distributed systems.
Read more about TypeIDs in their [spec](https://github.com/jetpack-io/typeid).

This particular implementation provides an pip package that can be used by any Python project.

## Installation

- PyPI:

    ```console
    pip install typeid-python
    ```

- Poetry:

    ```console
    poetry add typeid-python
    ```

## Usage

### Basic

- Create TypeID Instance:

    ```python
    from typeid import TypeID

    typeid = TypeID()

    print(typeid.prefix)  # ""
    print(typeid.suffix)  # "01h45ytscbebyvny4gc8cr8ma2" (encoded uuid7 instance)

    typeid = TypeID(prefix="user")

    print(typeid.prefix)  # "user"
    print(str(typeid))  # "user_01h45ytscbebyvny4gc8cr8ma2"
    ```

- Create TypeID from string:

    ```python
    from typeid import TypeID

    typeid = TypeID.from_string("user_01h45ytscbebyvny4gc8cr8ma2")

    print(str(typeid))  # "user_01h45ytscbebyvny4gc8cr8ma2"
    ```

- Create TypeID from uuid7:

    ```python
    from typeid import TypeID
    from uuid6 import uuid7

    uuid = uuid7()  # UUID('01890bf0-846f-7762-8605-5a3abb40e0e5')
    prefix = "user"

    typeid = TypeID.from_uuid(prefix=prefix, suffix=uuid)

    print(str(typeid))  # "user_01h45z113fexh8c1at7axm1r75"
    ```

### CLI-tool

- Install dependencies:

    ```console
    pip install typeid-python[cli]
    ```

- To generate a new TypeID, run:

    ```console
    $ python3 -m typeid.cli new -p prefix
    prefix_01h2xcejqtf2nbrexx3vqjhp41
    ```

- To decode an existing TypeID into a UUID run:

    ```console
    $ python3 -m typeid.cli decode prefix_01h2xcejqtf2nbrexx3vqjhp41
    type: prefix
    uuid: 0188bac7-4afa-78aa-bc3b-bd1eef28d881
    ```

- And to encode an existing UUID into a TypeID run:

    ```console
    $ python3 -m typeid.cli encode 0188bac7-4afa-78aa-bc3b-bd1eef28d881 --prefix prefix
    prefix_01h2xcejqtf2nbrexx3vqjhp41
    ```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/akhundMurad/typeid-python",
    "name": "typeid-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": "typeid, uuid, uuid6, guid",
    "author": "Murad Akhundov",
    "author_email": "akhundov1murad@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/25/c3/4d4cfcdc4a568e50b0f4702fafac66e01934ded5efc4f822ed4d38d29780/typeid_python-0.3.1.tar.gz",
    "platform": null,
    "description": "# TypeID Python\n\n<a href=\"https://github.com/akhundMurad/typeid-python/actions?query=setup%3ACI%2FCD+event%3Apush+branch%3Amain\" target=\"_blank\">\n    <img src=\"https://github.com/akhundMurad/typeid-python/actions/workflows/setup.yml/badge.svg?event=push&branch=main\" alt=\"Test\">\n</a>\n<a href=\"https://pepy.tech/project/typeid-python\" target=\"_blank\">\n    <img src=\"https://static.pepy.tech/personalized-badge/typeid-python?period=total&units=international_system&left_color=black&right_color=red&left_text=downloads\" alt=\"Downloads\">\n</a>\n<a href=\"https://pypi.org/project/typeid-python\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/v/typeid-python?color=red&labelColor=black\" alt=\"Package version\">\n</a>\n<a href=\"https://pypi.org/project/typeid-python\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/pyversions/typeid-python.svg?color=red&labelColor=black\" alt=\"Supported Python versions\">\n</a>\n\n## A Python implementation of [TypeIDs](https://github.com/jetpack-io/typeid) using Python\n\nTypeIDs are a modern, **type-safe**, globally unique identifier based on the upcoming\nUUIDv7 standard. They provide a ton of nice properties that make them a great choice\nas the primary identifiers for your data in a database, APIs, and distributed systems.\nRead more about TypeIDs in their [spec](https://github.com/jetpack-io/typeid).\n\nThis particular implementation provides an pip package that can be used by any Python project.\n\n## Installation\n\n- PyPI:\n\n    ```console\n    pip install typeid-python\n    ```\n\n- Poetry:\n\n    ```console\n    poetry add typeid-python\n    ```\n\n## Usage\n\n### Basic\n\n- Create TypeID Instance:\n\n    ```python\n    from typeid import TypeID\n\n    typeid = TypeID()\n\n    print(typeid.prefix)  # \"\"\n    print(typeid.suffix)  # \"01h45ytscbebyvny4gc8cr8ma2\" (encoded uuid7 instance)\n\n    typeid = TypeID(prefix=\"user\")\n\n    print(typeid.prefix)  # \"user\"\n    print(str(typeid))  # \"user_01h45ytscbebyvny4gc8cr8ma2\"\n    ```\n\n- Create TypeID from string:\n\n    ```python\n    from typeid import TypeID\n\n    typeid = TypeID.from_string(\"user_01h45ytscbebyvny4gc8cr8ma2\")\n\n    print(str(typeid))  # \"user_01h45ytscbebyvny4gc8cr8ma2\"\n    ```\n\n- Create TypeID from uuid7:\n\n    ```python\n    from typeid import TypeID\n    from uuid6 import uuid7\n\n    uuid = uuid7()  # UUID('01890bf0-846f-7762-8605-5a3abb40e0e5')\n    prefix = \"user\"\n\n    typeid = TypeID.from_uuid(prefix=prefix, suffix=uuid)\n\n    print(str(typeid))  # \"user_01h45z113fexh8c1at7axm1r75\"\n    ```\n\n### CLI-tool\n\n- Install dependencies:\n\n    ```console\n    pip install typeid-python[cli]\n    ```\n\n- To generate a new TypeID, run:\n\n    ```console\n    $ python3 -m typeid.cli new -p prefix\n    prefix_01h2xcejqtf2nbrexx3vqjhp41\n    ```\n\n- To decode an existing TypeID into a UUID run:\n\n    ```console\n    $ python3 -m typeid.cli decode prefix_01h2xcejqtf2nbrexx3vqjhp41\n    type: prefix\n    uuid: 0188bac7-4afa-78aa-bc3b-bd1eef28d881\n    ```\n\n- And to encode an existing UUID into a TypeID run:\n\n    ```console\n    $ python3 -m typeid.cli encode 0188bac7-4afa-78aa-bc3b-bd1eef28d881 --prefix prefix\n    prefix_01h2xcejqtf2nbrexx3vqjhp41\n    ```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs",
    "version": "0.3.1",
    "project_urls": {
        "Homepage": "https://github.com/akhundMurad/typeid-python",
        "Repository": "https://github.com/akhundMurad/typeid-python"
    },
    "split_keywords": [
        "typeid",
        " uuid",
        " uuid6",
        " guid"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4a63929b4574b02541a07b3fd61f6d2757eb263dcf606ecfb71b63d504cfd08",
                "md5": "f7ea8d307edb459d6174a869b19cd4f4",
                "sha256": "62a6747933b3323d65f0bf91c8e8c7768b0292eaf9c176fb0c934ff3a61acce5"
            },
            "downloads": -1,
            "filename": "typeid_python-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7ea8d307edb459d6174a869b19cd4f4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 7013,
            "upload_time": "2024-06-16T13:20:12",
            "upload_time_iso_8601": "2024-06-16T13:20:12.486653Z",
            "url": "https://files.pythonhosted.org/packages/f4/a6/3929b4574b02541a07b3fd61f6d2757eb263dcf606ecfb71b63d504cfd08/typeid_python-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25c34d4cfcdc4a568e50b0f4702fafac66e01934ded5efc4f822ed4d38d29780",
                "md5": "0c137d7dc7aeced99b2c7f7fce02d9e8",
                "sha256": "f96a78c5dc6d8df1d058b72598bcc2c1c5bb8d8343f53f910e074dae01458417"
            },
            "downloads": -1,
            "filename": "typeid_python-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0c137d7dc7aeced99b2c7f7fce02d9e8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 5861,
            "upload_time": "2024-06-16T13:20:13",
            "upload_time_iso_8601": "2024-06-16T13:20:13.768348Z",
            "url": "https://files.pythonhosted.org/packages/25/c3/4d4cfcdc4a568e50b0f4702fafac66e01934ded5efc4f822ed4d38d29780/typeid_python-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-16 13:20:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "akhundMurad",
    "github_project": "typeid-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "typeid-python"
}
        
Elapsed time: 4.15057s