Skip to main content

Serto Python SDK — write integrations in Python that run on the Serto platform

Project description

Serto Python SDK

pip install serto-sdk    # distribution name; the import package is `serto`

Write Serto integrations in Python. An integration is any callable taking a Context:

# main.py
def handler(ctx):
    ctx.logger.info(f"Running in {ctx.execution.environment}")

    order = ctx.payload_json()              # webhook/message body, parsed
    api_key = ctx.secrets["API_KEY"]        # provisioned secret

    # ... do the work ...

    ctx.publish("orders.synced", {"count": 42})   # message other integrations can subscribe to

Declare it in a serto.json next to your code:

{
  "manifestVersion": "1",
  "runtime": "python",
  "integrations": [
    {
      "name": "Sync Orders",
      "slug": "sync-orders",
      "entrypoint": "main.py:handler",
      "triggers": [{ "type": "scheduled", "cron": "0 * * * *" }],
      "requiredSecrets": ["API_KEY"]
    }
  ]
}

How it runs

The Serto agent launches python -m serto in your integration's directory, sends the invocation on stdin, and reads structured events (logs, published messages, the result) from stdout. The protocol is documented in docs/multi-language-runtimes.md. async def handlers are supported.

The Context

member description
ctx.logger .trace/.debug/.info/.warning/.error/.critical — captured into execution history
ctx.secrets dict of secrets provisioned for the environment
ctx.payload / ctx.payload_json() raw / parsed webhook or message body (None for scheduled)
ctx.trigger how the run was triggered (ctx.trigger["type"] + source-specific fields)
ctx.execution .execution_id, .integration_name, .environment, .scheduled_at, …
ctx.publish(subject, body) publish a message; a non-string body is JSON-encoded

Tests

cd sdks/python && python -m unittest discover -s tests

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

serto_sdk-1.5.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

serto_sdk-1.5.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file serto_sdk-1.5.3.tar.gz.

File metadata

  • Download URL: serto_sdk-1.5.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for serto_sdk-1.5.3.tar.gz
Algorithm Hash digest
SHA256 32775e75d55bda0f8d236aef68c6b8518aad4caab6a762a2cd00696ee1d0110c
MD5 c022d44ec7a15b37e6a7bd53eb3d98be
BLAKE2b-256 4ce91ca2b2c47fda5e5e3d28a47b5e84b0b4fc2b20c25557db6095d4ba0a23a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for serto_sdk-1.5.3.tar.gz:

Publisher: publish.yml on neweyc/integration-platform

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

File details

Details for the file serto_sdk-1.5.3-py3-none-any.whl.

File metadata

  • Download URL: serto_sdk-1.5.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for serto_sdk-1.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b5848a4e5f5d5367a78cb12be5a2c63738f7c9908eb15da60a17e3728c05da59
MD5 2fccda4518534732cfeff8f28fbd6721
BLAKE2b-256 e25eb6db149928a93d7079e2c8000c545424f9ae3eb120784b613f28b0d2c2b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for serto_sdk-1.5.3-py3-none-any.whl:

Publisher: publish.yml on neweyc/integration-platform

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