strapi-client


Namestrapi-client JSON
Version 4.1.6 PyPI version JSON
download
home_pageNone
SummaryInteract with Strapi from Python using the REST API
upload_time2025-07-27 00:48:29
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
```

## Documentation

[Full API Reference](https://roslovets-inc.github.io/strapi-client/reference/)

## Examples

### Quick start (sync version):

```python
from strapi_client 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'})
```

### Quick start (async version):

```python
import asyncio
from strapi_client 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 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 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",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "strapi, cms, api, rest",
    "author": null,
    "author_email": "Pavel Roslovets <p.v.roslovets@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/52/6d/d207a696ec0e236508f49520e82a027ac95dee7776f72e2176a0765b4b9d/strapi_client-4.1.6.tar.gz",
    "platform": null,
    "description": "# Strapi Client\n\n[![PyPI - Version](https://img.shields.io/pypi/v/strapi-client)](https://pypi.org/project/strapi-client/)\n\nInteract with Strapi from Python using the REST API\n\n## Install\n\n```bash\npip install strapi-client\n```\n\n## Documentation\n\n[Full API Reference](https://roslovets-inc.github.io/strapi-client/reference/)\n\n## Examples\n\n### Quick start (sync version):\n\n```python\nfrom strapi_client import StrapiClient\n\nwith StrapiClient(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\n    # await strapi.authorize(identifier='user_identifier', password='user_password')  # Optional\n    users = client.get_documents('users', filters={'username': {'$eq': 'Pavel'}})\n    user_id = users.data[0]['documentId']\n    client.update_document('users', user_id, data={'username': 'Mark'})\n```\n\n### Quick start (async version):\n\n```python\nimport asyncio\nfrom strapi_client import StrapiClientAsync\n\n\nasync def main():\n    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\n        # await strapi.authorize(identifier='user_identifier', password='user_password')  # Optional\n        users = await client.get_documents('users', filters={'username': {'$eq': 'Pavel'}})\n        user_id = users.data[0]['documentId']\n        await client.update_document('users', user_id, data={'username': 'Mark'})\n\n\nasyncio.run(main())\n```\n\n### Quick start with SmartDocument ORM\n\n```python\nimport asyncio\nfrom strapi_client import StrapiClientAsync, SmartDocument, MediaImageDocument\n\n\nclass User(SmartDocument):\n    __singular_api_id__ = 'user'\n    username: str\n    first_name: str\n    photo: MediaImageDocument\n\n\nclass Session(SmartDocument):\n    uid: str\n    user: User | None\n\n\nasync def main():\n    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\n        # Get with relations and media by ID\n        user1 = await User.get_document(client, document_id='YOUR_DOCUMENT_ID')\n        print(user1.photo)\n\n        # List documents with automatic population\n        sessions = await Session.get_documents(client, sort=['created_at'])\n        for session in sessions:\n            print(session.user.photo if session.user else 'No user')\n\n        # Find one document\n        user1 = await User.get_first_document(client, filters={'username': 'Mark'})\n        if user1:\n            print(user1)\n\n\nasyncio.run(main())\n```\n\n### Quick start with ActiveDocument ORM (experimental)\n\nRelations and upserts are supported in experimental mode.\n\n```python\nimport asyncio\nfrom strapi_client import StrapiClientAsync, ActiveDocument, DocumentField\n\n\nclass User(ActiveDocument):\n    username: str = DocumentField(unique=True)\n    first_name: str\n\n\nclass Session(ActiveDocument):\n    uid: str = DocumentField(unique=True)\n    user: User | None = DocumentField(default=None, relation=True)\n\n\nasync def main():\n    async with StrapiClientAsync(base_url='YOUR_STRAPI_URL', token='YOUR_STRAPI_TOKEN') as client:\n        # Update existing document\n        user1 = await User.get_document(client, document_id='YOUR_DOCUMENT_ID')\n        user1.first_name = 'Mark'\n        await user1.update_document(client)\n\n        # Create or update document with relation\n        session1 = await Session(uid='123', user=user1).upsert_document(client)\n        await session1.refresh(client)  # populate fields from Strapi\n\n        # Create and delete document\n        user2 = await User(username='pavel', first_name='Pavel').create_document(client)\n        await user2.delete_document(client)\n\n\nasyncio.run(main())\n```\n\n## Development\n\n### Create new release\n\nPush changes to 'main' branch following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).\n\n### Update documentation\n\n`docs` folder is being updated automatically by GitHub Actions when source files are changed.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Interact with Strapi from Python using the REST API",
    "version": "4.1.6",
    "project_urls": {
        "Changelog": "https://github.com/Roslovets-Inc/strapi-client/blob/main/CHANGELOG.md",
        "Documentation": "https://roslovets-inc.github.io/strapi-client/",
        "Homepage": "https://github.com/Roslovets-Inc/strapi-client",
        "Issues": "https://github.com/Roslovets-Inc/strapi-client/issues",
        "Repository": "https://github.com/Roslovets-Inc/strapi-client"
    },
    "split_keywords": [
        "strapi",
        " cms",
        " api",
        " rest"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "625fc59082e55bbdcfdc53cb6edc52b7bc3f781260ec6002e1eacca239d88f93",
                "md5": "d43fe62d2a39420fbae9fc7b46b7e1af",
                "sha256": "39685c1445ddea649918254740400acabbb733fc4e767635f3ea3b9d8771a649"
            },
            "downloads": -1,
            "filename": "strapi_client-4.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d43fe62d2a39420fbae9fc7b46b7e1af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 21834,
            "upload_time": "2025-07-27T00:48:28",
            "upload_time_iso_8601": "2025-07-27T00:48:28.362213Z",
            "url": "https://files.pythonhosted.org/packages/62/5f/c59082e55bbdcfdc53cb6edc52b7bc3f781260ec6002e1eacca239d88f93/strapi_client-4.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "526dd207a696ec0e236508f49520e82a027ac95dee7776f72e2176a0765b4b9d",
                "md5": "afadeec3c8540725bd203f1edb36febc",
                "sha256": "b543b6b43818b1cbc18b644f700a658f782b9bdb099a5e7804a2eb0ae4e51eb5"
            },
            "downloads": -1,
            "filename": "strapi_client-4.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "afadeec3c8540725bd203f1edb36febc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 17283,
            "upload_time": "2025-07-27T00:48:29",
            "upload_time_iso_8601": "2025-07-27T00:48:29.660740Z",
            "url": "https://files.pythonhosted.org/packages/52/6d/d207a696ec0e236508f49520e82a027ac95dee7776f72e2176a0765b4b9d/strapi_client-4.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-27 00:48:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Roslovets-Inc",
    "github_project": "strapi-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "strapi-client"
}
        
Elapsed time: 0.58640s