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.0a2.tar.gz (44.1 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.0a2-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: replicated-0.1.0a2.tar.gz
  • Upload date:
  • Size: 44.1 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.0a2.tar.gz
Algorithm Hash digest
SHA256 7a54909336e65b85c7e1331639b8d5f800752a7581178267e20acb34f18943e9
MD5 8eedce66ed5f3e1f8d0e7d7e30c06a90
BLAKE2b-256 48ae5802db7f75fd1c16091a1fe4e4649ad2c5345d7434603b61263c76bdf313

See more details on using hashes here.

Provenance

The following attestation bundles were made for replicated-0.1.0a2.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.0a2-py3-none-any.whl.

File metadata

  • Download URL: replicated-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c32ce586a272202f213c168f02b46d40f136fc401050c408ec89687904e4cc0
MD5 6bc9a80481907b801aa644f91a85792b
BLAKE2b-256 5ac7b7220b55884e0c1a3a7bf7df9097569d5b9c210821dfe3d6559ee5c2ebd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for replicated-0.1.0a2-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