Skip to main content

zsyncstudio

SDK Python para robôs (RPA) se conectarem ao ZSync Tech Studio: buscar execuções pendentes, reportar o progresso de cada etapa (task) e finalizar a execução — usando o token de API gerado para a instância do robô.

Disponível em duas versões com a mesma interface: zsyncstudio.sync_api (síncrona) e zsyncstudio.async_api (assíncrona, com async/await).

Requisitos

  • Python ≥ 3.13
  • Uma instância do ZSync Tech Studio em execução
  • Token de API do robô, gerado no dashboard da plataforma (formato zst_<instanceId>.<secret>)

Instalação

uv add zsynctech-studio-sdk

ou

pip install zsynctech-studio-sdk

O pacote se chama zsynctech-studio-sdk no PyPI, mas o módulo Python é zsyncstudio — é ele que você importa nos exemplos abaixo.

Guia rápido

from zsyncstudio.sync_api import Client, ExecutionRun

client = Client("https://studio.exemplo.com", api_token)


def run(execution: ExecutionRun) -> None:
    execution.start()  # reivindica a execução: PENDING → RUNNING

    for invoice in invoices:
        task = execution.task(invoice.number)
        try:
            charge(invoice)
        except Exception as exc:
            task.error(str(exc))
        else:
            task.finish()

    execution.error("alguns itens falharam") if execution.had_errors else execution.finish()


if __name__ == "__main__":
    while execution := client.poll_pending_executions():
        run(execution)

O robô fica esperando em poll_pending_executions() até a plataforma disparar uma execução (pelo dashboard ou pela API). Cada task(...) representa um item processado; chame finish(), warning(), error() ou skip() para reportar o resultado. No fim, finish() marca a execução como concluída e error() como falha.

Para reportar progresso no meio de uma execução longa, sem finalizá-la:

execution.update_observation("processando lote 3 de 10")

Robôs que decidem sozinhos quando rodar

Se o robô não depende da plataforma para saber quando executar (por exemplo, dispara pelo agendador do próprio sistema operacional), use client.start_execution() em vez de poll_pending_executions() — a execução já nasce em andamento, então pule o execution.start() e vá direto para as tasks.

Uso assíncrono

from zsyncstudio.async_api import Client, ExecutionRun

client = Client(base_url, api_token)


async def run(execution: ExecutionRun) -> None:
    await execution.start()

    for invoice in invoices:
        task = execution.task(invoice.number)
        try:
            await charge(invoice)
        except Exception as exc:
            await task.error(str(exc))
        else:
            await task.finish()


async def main() -> None:
    while execution := await client.poll_pending_executions():
        await run(execution)

Tratamento de erros

Problemas de comunicação com a plataforma chegam como exceções que você pode capturar:

from zsyncstudio.sync_api import AuthenticationError, ApiError

try:
    client.poll_pending_executions()
except AuthenticationError:
    print("Token inválido ou expirado.")
except ApiError as exc:
    print(f"Erro da plataforma ({exc.status_code}): {exc.message}")

As principais exceções: AuthenticationError (token inválido), NotFoundError (execução/instância inexistente), ConflictError (ex.: tentar finalizar uma execução já encerrada) e ConnectionError (falha de rede). Todas herdam de ApiError ou ZSyncStudioError e podem ser importadas de zsyncstudio.sync_api / zsyncstudio.async_api.

Dentro de uma task, você também pode levantar TaskWarning ou TaskSkipped para marcar o item como aviso ou pulado em vez de erro, sem interromper o processamento dos demais itens.

Metadados do projeto

  • Autor: Rodrigo Zavan
  • Proprietário: ZSync Tech LTDA
  • Requisito de Python: ≥ 3.13

Desenvolvimento

uv sync
uv run pytest
uv run mypy --strict src
uv run ruff check src tests
uv run black src tests

Download files

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

Source Distribution

zsynctech_studio_sdk-1.3.20.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

zsynctech_studio_sdk-1.3.20-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file zsynctech_studio_sdk-1.3.20.tar.gz.

File metadata

  • Download URL: zsynctech_studio_sdk-1.3.20.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zsynctech_studio_sdk-1.3.20.tar.gz
Algorithm Hash digest
SHA256 82d9d2e2fddcd9717a71ca40a75701a2baf95e9528c6212bbca4f1ed9b1e68ae
MD5 45ca8c2a750a39ba3c907af738d1575f
BLAKE2b-256 519b27ab6a5897a80487f16ef50e6f35c28f08b0110b83f82a933042c5ae83bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for zsynctech_studio_sdk-1.3.20.tar.gz:

Publisher: release.yml on zsynctech/zsynctech-studio-sdk

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

File details

Details for the file zsynctech_studio_sdk-1.3.20-py3-none-any.whl.

File metadata

File hashes

Hashes for zsynctech_studio_sdk-1.3.20-py3-none-any.whl
Algorithm Hash digest
SHA256 dfb6071db9dc8e5c3ece370f5948fdbfe440cd39a5e29816534c609a70c81ac3
MD5 d50ce635228cad06a28f6b769c0c1e01
BLAKE2b-256 c0bd71fcca45bc57bc92b926e0b4f5e39c12f1c544801cecf4e9b63c02dd0e2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for zsynctech_studio_sdk-1.3.20-py3-none-any.whl:

Publisher: release.yml on zsynctech/zsynctech-studio-sdk

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