Skip to main content

Institutional-grade Python SDK for the Viper Execution trading API on Hyperliquid.

Project description

Viper Execution Python SDK

Institutional-grade Python client for the Viper Execution trading API on Hyperliquid.

Status: SDK 0.1.0 (beta). Ships the resilient WebSocket client and the resync REST-fetch mapping. The full typed REST client lands in a subsequent release. The SDK version is independent of the API version — this is SDK 0.x against API v1.

Install

pip install viper-execution

Requires Python ≥ 3.10.

Quickstart

import asyncio
from viper import ViperWSClient

async def main():
    client = ViperWSClient(
        api_key_id="vk_...",
        api_secret="...",
        handle="your-handle",
        wallet="0x...",
        on_event=lambda f: print(f["channel"], f.get("event")),
    )
    await client.start()
    await client.subscribe("account.state", "0x...")
    await asyncio.sleep(30)
    await client.close()

asyncio.run(main())

See examples/ for runnable scripts.

What the WebSocket client handles for you

The /v1/ws stream has a number of behaviors a naive client gets wrong. ViperWSClient handles them as a built-in contract:

  • Liveness — transport ping/pong plus a data-staleness watchdog; silent half-open connections are detected and reconnected.
  • Reconnect with resume — on drop, it reconnects with exponential backoff and resubscribes every scope carrying its last_seq cursor, so you resume exactly where you left off (replay from the per-scope ring buffer).
  • Resync recovery — when the server can't satisfy a cursor (buffer_overflow / last_seq_ahead_of_server / scope_not_found), it REST-fetches authoritative current state and resubscribes fresh.
  • Multi-wallet attribution — every data frame is routed by data.wallet, so one socket can carry many wallets without cross-attribution. (Control markers such as hydrated carry no data.wallet; route those by scope_id.)
  • Slow hydrationaccount.state hydration is server-slow (~5s; it gathers balance + HIP-3 collateral across all dexes, then bursts frames). The client does not mistake that for a dead stream, and neither should your application logic.
  • Terminal conditions — credential revocation (close 4013), a handshake auth rejection (HTTP 401/403 — revoked/invalid key or insufficient scope), or an exhausted reconnect budget all stop the loop permanently via on_terminal rather than reconnect-hammering.

Callbacks

Callback Fires on
on_event(frame) Every classified data frame (the main path)
on_meta(frame) _meta frames: welcome + upstream connectivity events
on_terminal(code) Terminal stop. code is the WS close code (4013 = credentials revoked), the handshake HTTP status (401/403), or -1 (reconnect budget exhausted)
on_command_result(frame) Subscribe acks / command errors (no correlation id)
on_raw(frame) Optional advanced tap: every frame pre-classification (audit/metrics)

License

MIT — see 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

viper_execution-0.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

viper_execution-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file viper_execution-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for viper_execution-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dedb08aacc853ebcd6edf29a0e115de244f38f9efdb41d3546f3ae52bfed9cfa
MD5 1f2580ceb16b0727458b68058ba0107d
BLAKE2b-256 a9f72bf4b69b318588960635fc89fa614b7d3db21016a4e6f5cdd2acd697cfc8

See more details on using hashes here.

Provenance

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

Publisher: release.yml on viperexecution/viper-sdk-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 viper_execution-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for viper_execution-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 314a06dda72d62c64f1e48ec04c1ea6c337e7190e5ee043fff6ae1ac2706436f
MD5 776bda4cf6d180f4f711582c44f89da5
BLAKE2b-256 4f0a89144d72ec58fe3462500e7dd19917f816ec7635e04a84bad4535ed3b899

See more details on using hashes here.

Provenance

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

Publisher: release.yml on viperexecution/viper-sdk-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