Skip to main content

Python SDK for Replicated customer, metrics, and instance insights

Project description

Replicated Python SDK

A Python SDK for embedding Replicated customer, custom metrics, and instance insights data in your applications.

Installation

Install the SDK via pip:

pip install --upgrade replicated

Usage

Sync Example

from replicated import ReplicatedClient, InstanceStatus

client = ReplicatedClient(
    publishable_key="replicated_pk_...", 
    app_slug="my-app"
)

# Create a customer (or fetch an existing one)
customer = client.customer.get_or_create(email_address="xxx@yyy.com")

# Get or create the associated instance
instance = customer.get_or_create_instance()

# Use the instance for metrics and status reporting
instance.send_metric("cpu_usage", 0.83)
instance.set_status(InstanceStatus.RUNNING)
instance.set_version("1.2.0")

Custom State Directory

By default, the SDK stores state in platform-specific directories. You can override this for testing, containerization, or custom deployments:

from replicated import ReplicatedClient

# Use a custom directory (supports ~ and relative paths)
client = ReplicatedClient(
    publishable_key="replicated_pk_...",
    app_slug="my-app",
    state_directory="/var/lib/my-app/replicated-state"
)

# Or use a relative path (will be resolved to absolute)
client = ReplicatedClient(
    publishable_key="replicated_pk_...",
    app_slug="my-app",
    state_directory="./local-state"
)

When to use custom state directories:

  • Testing with temporary directories
  • Docker containers with mounted volumes
  • Multi-tenant applications requiring isolated state
  • Development with project-local state

Async Example

from replicated import AsyncReplicatedClient, InstanceStatus

async def main():
    async with AsyncReplicatedClient(
        publishable_key="replicated_pk_...", 
        app_slug="my-app"
    ) as client:
        customer = await client.customer.get_or_create(email_address="xxx@yyy.com")
        instance = await customer.get_or_create_instance()

        await instance.send_metric("cpu_usage", 0.83)
        await instance.set_status(InstanceStatus.RUNNING)
        await instance.set_version("1.2.0")

Documentation

For detailed documentation, visit docs.replicated.com/sdk/python.

License

MIT 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

replicated-0.1.0a1.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

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

replicated-0.1.0a1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file replicated-0.1.0a1.tar.gz.

File metadata

  • Download URL: replicated-0.1.0a1.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for replicated-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 31a20281b2decaa235261479e05a006af72666d1af9b1f439c4698c046078b2e
MD5 7ed2a9ab6a0c13b20601f9d76a9d597c
BLAKE2b-256 056747bd0e33bb2a14e9ab3715eaadda9db3751f581ad58c1956f41bc4adeae3

See more details on using hashes here.

Provenance

The following attestation bundles were made for replicated-0.1.0a1.tar.gz:

Publisher: publish.yml on replicatedhq/replicated-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 replicated-0.1.0a1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for replicated-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 0aa34b61107dfe85766e58f7a8b8dc883385a7355c60530eab7bf2e52ef72d3e
MD5 8f8b722b42c20e4fa05f03d11cc5fa9e
BLAKE2b-256 d0a469198b88f6fe15a83853dcd37d3e57ee0425a179ffadf4a70fd6d47c87bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for replicated-0.1.0a1-py3-none-any.whl:

Publisher: publish.yml on replicatedhq/replicated-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