typeid-python


Nametypeid-python JSON
Version 0.3.0 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-04-19 13:32:31
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/95/b8/e8642b7d43caa0e68975705636d6e301275e4af82d55b1919b26bb836564/typeid_python-0.3.0.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.0",
    "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": "d1faf36c0712cda5c4a3d623a7479cda873541c39ed503a0b80f65b4e448aa07",
                "md5": "dd290fb30e17e3e240a5a392fbb7886b",
                "sha256": "7d059b3b29028fd2d870014ea3e3c5b2538656b38f509c1898adafcfbeb09087"
            },
            "downloads": -1,
            "filename": "typeid_python-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd290fb30e17e3e240a5a392fbb7886b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 7026,
            "upload_time": "2024-04-19T13:32:30",
            "upload_time_iso_8601": "2024-04-19T13:32:30.054989Z",
            "url": "https://files.pythonhosted.org/packages/d1/fa/f36c0712cda5c4a3d623a7479cda873541c39ed503a0b80f65b4e448aa07/typeid_python-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "95b8e8642b7d43caa0e68975705636d6e301275e4af82d55b1919b26bb836564",
                "md5": "cfec4fea98df01ebf57911e7d480e5a8",
                "sha256": "2ad7c5c03bb42ca926ec015a168b3546769c7769d35d73aefd3ff7bc329e669d"
            },
            "downloads": -1,
            "filename": "typeid_python-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cfec4fea98df01ebf57911e7d480e5a8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 5853,
            "upload_time": "2024-04-19T13:32:31",
            "upload_time_iso_8601": "2024-04-19T13:32:31.745416Z",
            "url": "https://files.pythonhosted.org/packages/95/b8/e8642b7d43caa0e68975705636d6e301275e4af82d55b1919b26bb836564/typeid_python-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 13:32:31",
    "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: 0.26737s