Skip to main content

Official Cored OpenAPI SDK for Python

Project description

Cored IM OpenAPI SDK - Python

PyPI version CI Python License

English | 中文

Cored is a secure, self-hosted productivity platform for teams, integrating instant messaging, organizational structures, video conferencing, and file storage.

This is the official Python SDK for Cored server, used to interact with the Cored server via OpenAPI. You need to deploy the Cored server before using this SDK. See the Quick Deploy Guide for setup instructions.

Installation

pip install cored-sdk

Quick Start

import asyncio
from cored import CoredClient, SendMessageReq, MessageContent, MessageText, MessageType_TEXT

async def main():
    client = await CoredClient.create(
        "https://your-backend-url.com",
        "your-app-id",
        "your-app-secret",
    )

    # Optional: preheat fetches access token and syncs server time upfront,
    # reducing latency on the first API call
    await client.preheat()

    # Call API
    resp = await client.im.message.send_message(SendMessageReq(
        chat_id="chat-id",
        message_type=MessageType_TEXT,
        message_content=MessageContent(text=MessageText(content="Cored new version released!")),
    ))
    print(resp.message_id)

    # Close when done
    await client.close()

asyncio.run(main())

Configuration

CoredClient.create() accepts optional keyword arguments to configure client behavior:

from cored import CoredClient, LogLevel

client = await CoredClient.create(
    "https://your-backend-url.com",
    "your-app-id",
    "your-app-secret",
    log_level=LogLevel.DEBUG,         # Log level (default: INFO)
    request_timeout=30.0,             # Request timeout in seconds (default: 60.0)
    enable_encryption=False,          # Enable request encryption (default: True)
)

Event Subscription

Receive real-time events via WebSocket:

from cored import EventMessageReceive

def on_message(event: EventMessageReceive):
    print("Message received:", event.body)

client.im.message.event.on_message_receive(on_message)

# Unsubscribe
client.im.message.event.off_message_receive(on_message)

Context Manager

Supports async with syntax for automatic cleanup:

async with await CoredClient.create(...) as client:
    resp = await client.im.message.send_message(SendMessageReq(...))

Requirements

  • Python 3.9+

Links

License

Apache-2.0 License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cored_sdk-0.28.107.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cored_sdk-0.28.107-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file cored_sdk-0.28.107.tar.gz.

File metadata

  • Download URL: cored_sdk-0.28.107.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cored_sdk-0.28.107.tar.gz
Algorithm Hash digest
SHA256 ef1dc860b5476fc7e4278e41bc1c2a3dd33f44b7163b79f853d5ad223390d493
MD5 91b5413c6eb6c0b972526e0ffc9b95f6
BLAKE2b-256 fb16ec23e3c7fcdc9a0d72d79a665a119c7f194104aec58980f655ea1928f43d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cored_sdk-0.28.107.tar.gz:

Publisher: publish.yaml on cored-im/openapi-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cored_sdk-0.28.107-py3-none-any.whl.

File metadata

  • Download URL: cored_sdk-0.28.107-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cored_sdk-0.28.107-py3-none-any.whl
Algorithm Hash digest
SHA256 2b7e33f17fab618ac4e93a2c3201ae320d265bc843b1d598647e014b1d09049b
MD5 c4264b3d0ba98a30bccfa88913264bf0
BLAKE2b-256 ae8460eb07e96bd81734925f0a32ea567ae05662bf4ad287f6c0713d0262273d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cored_sdk-0.28.107-py3-none-any.whl:

Publisher: publish.yaml on cored-im/openapi-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page