Skip to main content

Strapi Client

PyPI Python CI Docs

Interact with Strapi from Python using the REST API

Requirements

  • Python 3.11+
  • A running Strapi instance (public or self-hosted)

Installation

From PyPI:

pip install strapi-client

or

uv add strapi-client

Documentation

Full API Reference

Examples

Quick start (sync version):

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):

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

import asyncio
from strapi_client import LocalizedSmartDocument, MediaImageDocument, SmartDocument, StrapiClientAsync


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


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


class Article(LocalizedSmartDocument):
    title: str


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)

        # Localized documents keep their locale for refresh, update, and delete operations
        article = await Article.get_document(client, document_id="YOUR_DOCUMENT_ID", locale="fr")
        await article.update_document(client, {"title": "Bonjour"})


asyncio.run(main())

Quick start with ActiveDocument ORM (experimental)

Relations and upserts are supported in experimental mode.

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.

Update documentation

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

Metadata

Release files for strapi-client 5.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strapi-client 5.2.0
File Size Uploaded
strapi_client-5.2.0.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for strapi-client 5.2.0
File Interpreter ABI Platform
strapi_client-5.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.1 kB

Release files / strapi_client-5.2.0.tar.gz

Download URL strapi_client-5.2.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d04026c48b56c208367fc5ed289df9701e0ea6805d1e753ffc6c3acc38f904f2
BLAKE2b-256 checksum
How to use checksums
b6ce19d0654bc7ab54cbb840494a8438ae2c6f5a0b8c2d0d8562d03db1a7f27f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / strapi_client-5.2.0-py3-none-any.whl

Download URL strapi_client-5.2.0-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b98871aaf295cbd7ae30565130fc4fdba8e97c5b26f09148cf81930a2f41fa1d
BLAKE2b-256 checksum
How to use checksums
cec1ee6994a5c118fb9e1bbc465217fbae93316838232af9dd922fe877943f30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release history Release notifications | RSS feed

5.2.1

2 release files

This release

5.2.0 This release

2 release files

5.1.0

2 release files

5.0.6

2 release files

5.0.5

2 release files

5.0.4

2 release files

5.0.3

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.6

2 release files

4.1.5

2 release files

4.1.4

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.10.1

2 release files

3.10.0

2 release files

3.9.0

2 release files

3.8.0

2 release files

3.7.4

2 release files

3.7.3

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.1

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.3

2 release files

3.0.2

2 release files

2.9.1

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page