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.108.tar.gz (23.1 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.108-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cored_sdk-0.28.108.tar.gz
  • Upload date:
  • Size: 23.1 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.108.tar.gz
Algorithm Hash digest
SHA256 342626faf0f730f6338bcade91bc984a28e592578551cc794f31de223e8cc242
MD5 4dfbdd8c474e6b8bb3f148f9466ad1d4
BLAKE2b-256 2bb99ed2c22647ac49ed2a4ac2a613115e5f2ffe14e5d3ddbc1e76feac09ffad

See more details on using hashes here.

Provenance

The following attestation bundles were made for cored_sdk-0.28.108.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.108-py3-none-any.whl.

File metadata

  • Download URL: cored_sdk-0.28.108-py3-none-any.whl
  • Upload date:
  • Size: 29.5 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.108-py3-none-any.whl
Algorithm Hash digest
SHA256 d65bf377ad15071c535c157c399f53226484ef83e655479fb88ed5647adffbf1
MD5 82d3c925404b51d67a1333f5a879cea3
BLAKE2b-256 c76530836cae162f730e864855a9d7c100e31f6b980310f99ec6d2dd98a1829e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cored_sdk-0.28.108-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