strapi-client-enhanced


Namestrapi-client-enhanced JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryInteract with Strapi from Python using the REST API
upload_time2025-10-23 03:12:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords strapi cms api rest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Strapi Client

[![PyPI - Version](https://img.shields.io/pypi/v/strapi-client)](https://pypi.org/project/strapi-client/)

Interact with Strapi from Python using the REST API

## Install

```bash
pip install strapi-client-enhanced
```

## Documentation

[Full API Reference](https://github.com/zpzxgcr/strapi-client/)

## Examples

### Quick start (sync version):

```python
from strapi_client_enhanced import StrapiClient

with StrapiClient(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:
    # await strapi.authorize(identifier='user_identifier', password='user_password')  # Optional
    users = client.get_documents('users', filters={'username': {'$eq': 'Pavel'}})
    user_id = users.data[0]['documentId']
    client.update_document('users', user_id, data={'username': 'Mark'})
    # support  upsert
    response = await client.upsert_document(
                plural_api_id="users", 
                data=data,
                unique_value="slug"
                unique_value="just"
            )
```

### Quick start (async version):

```python
import asyncio
from strapi_client_enhanced import StrapiClientAsync


async def main():
    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:
        # await strapi.authorize(identifier='user_identifier', password='user_password')  # Optional
        users = await client.get_documents('users', filters={'username': {'$eq': 'Pavel'}})
        user_id = users.data[0]['documentId']
        await client.update_document('users', user_id, data={'username': 'Mark'})


asyncio.run(main())
```

### Quick start with SmartDocument ORM

```python
import asyncio
from strapi_client_enhanced import StrapiClientAsync, SmartDocument, MediaImageDocument


class User(SmartDocument):
    __singular_api_id__ = 'user'
    username: str
    first_name: str
    photo: MediaImageDocument


class Session(SmartDocument):
    uid: str
    user: User | None


async def main():
    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:
        # Get with relations and media by ID
        user1 = await User.get_document(client, document_id='YOUR_DOCUMENT_ID')
        print(user1.photo)

        # List documents with automatic population
        sessions = await Session.get_documents(client, sort=['created_at'])
        for session in sessions:
            print(session.user.photo if session.user else 'No user')

        # Find one document
        user1 = await User.get_first_document(client, filters={'username': 'Mark'})
        if user1:
            print(user1)


asyncio.run(main())
```

### Quick start with ActiveDocument ORM (experimental)

Relations and upserts are supported in experimental mode.

```python
import asyncio
from strapi_client_enhanced import StrapiClientAsync, ActiveDocument, DocumentField


class User(ActiveDocument):
    username: str = DocumentField(unique=True)
    first_name: str


class Session(ActiveDocument):
    uid: str = DocumentField(unique=True)
    user: User | None = DocumentField(default=None, relation=True)


async def main():
    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:
        # Update existing document
        user1 = await User.get_document(client, document_id='YOUR_DOCUMENT_ID')
        user1.first_name = 'Mark'
        await user1.update_document(client)

        # Create or update document with relation
        session1 = await Session(uid='123', user=user1).upsert_document(client)
        await session1.refresh(client)  # populate fields from Strapi

        # Create and delete document
        user2 = await User(username='pavel', first_name='Pavel').create_document(client)
        await user2.delete_document(client)


asyncio.run(main())
```

## Development

### Create new release

Push changes to 'main' branch following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).

### Update documentation

`docs` folder is being updated automatically by GitHub Actions when source files are changed.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "strapi-client-enhanced",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "strapi, cms, api, rest",
    "author": null,
    "author_email": "Just <zpzxgcr@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c2/1b/b51f5588d9a0e57a1efe6747938054c8509771522ed83f3d7b7e418f6cb6/strapi_client_enhanced-1.0.2.tar.gz",
    "platform": null,
    "description": "# Strapi Client\r\n\r\n[![PyPI - Version](https://img.shields.io/pypi/v/strapi-client)](https://pypi.org/project/strapi-client/)\r\n\r\nInteract with Strapi from Python using the REST API\r\n\r\n## Install\r\n\r\n```bash\r\npip install strapi-client-enhanced\r\n```\r\n\r\n## Documentation\r\n\r\n[Full API Reference](https://github.com/zpzxgcr/strapi-client/)\r\n\r\n## Examples\r\n\r\n### Quick start (sync version):\r\n\r\n```python\r\nfrom strapi_client_enhanced import StrapiClient\r\n\r\nwith StrapiClient(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\r\n    # await strapi.authorize(identifier='user_identifier', password='user_password')  # Optional\r\n    users = client.get_documents('users', filters={'username': {'$eq': 'Pavel'}})\r\n    user_id = users.data[0]['documentId']\r\n    client.update_document('users', user_id, data={'username': 'Mark'})\r\n    # support  upsert\r\n    response = await client.upsert_document(\r\n                plural_api_id=\"users\", \r\n                data=data,\r\n                unique_value=\"slug\"\r\n                unique_value=\"just\"\r\n            )\r\n```\r\n\r\n### Quick start (async version):\r\n\r\n```python\r\nimport asyncio\r\nfrom strapi_client_enhanced import StrapiClientAsync\r\n\r\n\r\nasync def main():\r\n    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\r\n        # await strapi.authorize(identifier='user_identifier', password='user_password')  # Optional\r\n        users = await client.get_documents('users', filters={'username': {'$eq': 'Pavel'}})\r\n        user_id = users.data[0]['documentId']\r\n        await client.update_document('users', user_id, data={'username': 'Mark'})\r\n\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n### Quick start with SmartDocument ORM\r\n\r\n```python\r\nimport asyncio\r\nfrom strapi_client_enhanced import StrapiClientAsync, SmartDocument, MediaImageDocument\r\n\r\n\r\nclass User(SmartDocument):\r\n    __singular_api_id__ = 'user'\r\n    username: str\r\n    first_name: str\r\n    photo: MediaImageDocument\r\n\r\n\r\nclass Session(SmartDocument):\r\n    uid: str\r\n    user: User | None\r\n\r\n\r\nasync def main():\r\n    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\r\n        # Get with relations and media by ID\r\n        user1 = await User.get_document(client, document_id='YOUR_DOCUMENT_ID')\r\n        print(user1.photo)\r\n\r\n        # List documents with automatic population\r\n        sessions = await Session.get_documents(client, sort=['created_at'])\r\n        for session in sessions:\r\n            print(session.user.photo if session.user else 'No user')\r\n\r\n        # Find one document\r\n        user1 = await User.get_first_document(client, filters={'username': 'Mark'})\r\n        if user1:\r\n            print(user1)\r\n\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n### Quick start with ActiveDocument ORM (experimental)\r\n\r\nRelations and upserts are supported in experimental mode.\r\n\r\n```python\r\nimport asyncio\r\nfrom strapi_client_enhanced import StrapiClientAsync, ActiveDocument, DocumentField\r\n\r\n\r\nclass User(ActiveDocument):\r\n    username: str = DocumentField(unique=True)\r\n    first_name: str\r\n\r\n\r\nclass Session(ActiveDocument):\r\n    uid: str = DocumentField(unique=True)\r\n    user: User | None = DocumentField(default=None, relation=True)\r\n\r\n\r\nasync def main():\r\n    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\r\n        # Update existing document\r\n        user1 = await User.get_document(client, document_id='YOUR_DOCUMENT_ID')\r\n        user1.first_name = 'Mark'\r\n        await user1.update_document(client)\r\n\r\n        # Create or update document with relation\r\n        session1 = await Session(uid='123', user=user1).upsert_document(client)\r\n        await session1.refresh(client)  # populate fields from Strapi\r\n\r\n        # Create and delete document\r\n        user2 = await User(username='pavel', first_name='Pavel').create_document(client)\r\n        await user2.delete_document(client)\r\n\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n## Development\r\n\r\n### Create new release\r\n\r\nPush changes to 'main' branch following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).\r\n\r\n### Update documentation\r\n\r\n`docs` folder is being updated automatically by GitHub Actions when source files are changed.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Interact with Strapi from Python using the REST API",
    "version": "1.0.2",
    "project_urls": {
        "Changelog": "https://github.com/zpzxgcr/strapi-client/blob/main/CHANGELOG.md",
        "Documentation": "https://roslovets-inc.github.io/strapi-client/",
        "Homepage": "https://github.com/zpzxgcr/strapi-client",
        "Issues": "https://github.com/zpzxgcr/strapi-client/issues",
        "Repository": "https://github.com/zpzxgcr/strapi-client"
    },
    "split_keywords": [
        "strapi",
        " cms",
        " api",
        " rest"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2694a54887b2e83a8b1bdbff1f5f8161c2b8739a36b57e154735c9e06ebcadb3",
                "md5": "e6d1a129ad6dee9a229b7941d6790295",
                "sha256": "68290160c2cd0bf9f5d13661893aebecd70dde10527da08432d36e9b6b7be9fc"
            },
            "downloads": -1,
            "filename": "strapi_client_enhanced-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e6d1a129ad6dee9a229b7941d6790295",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 25535,
            "upload_time": "2025-10-23T03:12:31",
            "upload_time_iso_8601": "2025-10-23T03:12:31.890948Z",
            "url": "https://files.pythonhosted.org/packages/26/94/a54887b2e83a8b1bdbff1f5f8161c2b8739a36b57e154735c9e06ebcadb3/strapi_client_enhanced-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c21bb51f5588d9a0e57a1efe6747938054c8509771522ed83f3d7b7e418f6cb6",
                "md5": "9cb7e64f442ff6e6be8284e9d35ce943",
                "sha256": "5ab51b0ae2f1b5af377552cad68dbfe9529a5f8d57dd47acad36bef16b0caf6c"
            },
            "downloads": -1,
            "filename": "strapi_client_enhanced-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9cb7e64f442ff6e6be8284e9d35ce943",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 26924,
            "upload_time": "2025-10-23T03:12:33",
            "upload_time_iso_8601": "2025-10-23T03:12:33.684852Z",
            "url": "https://files.pythonhosted.org/packages/c2/1b/b51f5588d9a0e57a1efe6747938054c8509771522ed83f3d7b7e418f6cb6/strapi_client_enhanced-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-23 03:12:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zpzxgcr",
    "github_project": "strapi-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "strapi-client-enhanced"
}
        
Elapsed time: 1.08592s