Skip to main content

Python client for the Arker virtual computer platform.

Project description

Arker — Python SDK

Single-file Python client for the Arker virtual computer platform. Spawn isolated Linux sandboxes, run shell / Python / Node code in them, read and write files. Zero runtime dependencies (stdlib urllib).

Install

pip install arker

Or, while in alpha:

pip install git+https://github.com/arker-ai/arker-python@v0.2.0

Quickstart

from arker import Arker, ArkerError

arker  = Arker(api_key="ark_live_...")
vm     = arker.vm("arkuntu").fork(name="hello")     # fresh VM from base image
result = vm.run("python3 -c 'print(2+2)'")
print(result.stdout.decode())                        # → "4\n"

vm.sync.write_file("/home/user/data.csv", b"a,b\n1,2\n")
data = vm.sync.read_file("/home/user/data.csv")      # → b"a,b\n1,2\n"

child = vm.fork(name="branch")                       # constant-time copy-on-write
child.delete()
vm.delete()

List your VMs:

page = arker.list(limit=10, sort="-created_at")
print(f"{page.total} total")
for summary in page:                                 # iterable; also page.items
    print(summary.vm_id, summary.name, summary.region, summary.created_at)

API

Arker(api_key, base_url=None)
    .vm(vm_id) -> Computer                          # open handle (no network call)
    .list(*, limit=25, offset=0, q=None, sort=None) -> VmList

Computer
    .id, .delete()
    .fork(*, name=, is_public=, region=) -> Computer
    .run(command, *, session_id=, timeout=) -> RunResult
    .sync.read_file(path) -> bytes
    .sync.write_file(path, data: bytes | str)

RunResult: stdout, stderr (bytes), exit_code, duration_ms, session_id, cwd
VmSummary: vm_id, name, base_image, region, created_at (ISO 8601)
VmList: items (list[VmSummary]), total (int);  iterable, len()-able

ArkerError(code, message, status)                   # one exception type for everything

Routing

fork, run, sync, delete go to the regional ALB (default https://aws-us-west-2.burst.arker.ai) — fastest path, no Cloudflare hop.

list always goes through https://arker.ai (Cloudflare → PlanetScale) regardless of base_url, because the data lives in the global database rather than per-VM regional state.

Public base-image names like "arkuntu" resolve to a ULID client-side (see SOURCE_ALIASES in computer.py), so a.vm("arkuntu").fork() works on the default ALB path with no extra round-trip. Override base_url or set ARKER_BASE_URL only if you want to point at a different region or a self-hosted stack.

Errors

Every server-side error becomes an ArkerError:

try:
    vm.sync.read_file("/home/user/missing")
except ArkerError as err:
    print(err.code)      # "not_found"
    print(err.message)   # "file not found: /home/user/missing"
    print(err.status)    # 404

code is a stable enum: bad_request, unauthorized, payment_required, forbidden, not_found, conflict, payload_too_large, internal, not_implemented, vm_busy, unsupported_*, command_not_found.

What the SDK does for you

Hidden behind these six methods:

  • Write strategy: small files go in one call; larger files use a direct upload bypass so the bytes don't traverse the API layer. write_file always returns once the bytes are durably stored.
  • Read coalescing: read_file always returns raw bytes, regardless of whether the server inlined the content or returned a presigned URL.
  • Idempotent retry: transient errors are retried with exponential backoff. Writes are server-side idempotent on upload_id, so retries never produce duplicate writes.
  • Path validation: only /home/user/... paths accepted; .. rejected.

Demo / smoke test

Run the full surface against a live deployment:

ARKER_API_KEY=ark_live_... python -m arker.tests.demo

It exercises every method (list, vm, fork, run, sync.write_file, sync.read_file, error path, child fork, delete) and prints what each call hits on the wire — useful as living documentation.

License

Apache-2.0.

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

arker-0.2.1.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

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

arker-0.2.1-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file arker-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for arker-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c8b484b5ed4747640e8a585537dedd1950222b19a1153d4fb5df1567f056c63e
MD5 401465c2ebc255fb5f07ed1e3966c020
BLAKE2b-256 df5d1f248b79f42aa70bf5e65432517fad93124ba68758f79324701dd7740c6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for arker-0.2.1.tar.gz:

Publisher: publish-python.yml on ArkerHQ/arker-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 arker-0.2.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for arker-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f57521bce280957ddf4a0b113285847d127c041680f931fb88f0fc68dcbd7b4
MD5 c353119ff5ff8099c6680bf5abff12c5
BLAKE2b-256 36942f24a2f047e2b74636bcfb086e2a7cbe4ff93fc642fcbcab872154af4d2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for arker-0.2.1-py3-none-any.whl:

Publisher: publish-python.yml on ArkerHQ/arker-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