Skip to main content

Official Python SDK for the Noether decentralized perpetual exchange on Stellar / Soroban.

Project description

noether-sdk

Official Python SDK for Noether — a decentralized perpetual exchange on Stellar / Soroban.

Async-first (httpx + pydantic), typed, mirrors the public surface of @noether/sdk.

Install

pip install noether-sdk
# Optional, only if you want to sign with a Stellar Keypair locally:
pip install "noether-sdk[stellar]"

Quick start — public reads

import asyncio
from noether_sdk import NoetherClient

async def main():
    async with NoetherClient("https://api.noether.exchange") as client:
        markets = await client.markets.list()
        btc = await client.oracle.get_price("BTC")
        print("BTC oracle:", btc.price_float)

asyncio.run(main())

Authed: account info

from noether_sdk.transport import Credentials

async with NoetherClient(
    "https://api.noether.exchange",
    credentials=Credentials("nk_...", "..."),
) as client:
    me = await client.account.me()
    positions = await client.account.positions()

Issue an API key (one-shot)

from stellar_sdk import Keypair

kp = Keypair.from_secret(os.environ["STELLAR_SECRET"])
async with NoetherClient("https://api.noether.exchange") as client:
    issued = await client.keys.create(
        address=kp.public_key,
        signer=lambda data: kp.sign(data),
        label="mm-bot-1",
    )
    print(issued.key_id, issued.secret)  # store immediately

Place an order — execute_trade

from stellar_sdk import Network, TransactionBuilder

def sign_xdr(xdr: str) -> str:
    tx = TransactionBuilder.from_xdr(xdr, Network.TESTNET_NETWORK_PASSPHRASE)
    tx.sign(kp)
    return tx.to_xdr()

prepared, submitted = await authed.execute_trade(
    {
        "op": "open_position",
        "asset": "XLM",
        "collateral": 1_000 * 10_000_000,
        "leverage": 2,
        "direction": "Long",
    },
    sign_xdr,
)
print(submitted.hash, submitted.status)

execute_trade calls orders.prepare → asks your signer for the signed XDR → calls tx.submit and polls until SUCCESS / FAILED / timeout.

Sub-client cheatsheet

Call Auth
client.health.ping() no
client.markets.list() / get(asset) no
client.oracle.get_price(asset) / get_prices() no
client.events.list(topic=, ...) no
client.keys.create({...}) no
client.keys.list() / revoke(id) yes
client.account.me() / events() / positions() / orders() yes
client.orders.prepare({op: ..., ...}) yes
client.tx.submit(signed_xdr=...) yes
client.execute_trade({...}, signer) yes
client.vaults.list() / get(id) / deposits/withdraws/fee_claims(id) no
client.referral.lookup_code(code) no
client.referral.me() / trades() / claims() yes

WebSocket

from noether_sdk.ws import WsClient

ws = WsClient("wss://api.noether.exchange/v1/ws")
await ws.connect()
await ws.subscribe("ticker.BTC", lambda data, ch: print(ch, data["priceFloat"]))

WsClient reconnects automatically with exponential backoff and replays your active subscriptions on every reconnect.

Errors

from noether_sdk import (
    AuthError, RateLimitError, BadRequestError, ServerError,
)

try:
    await client.markets.get("DOGE")
except BadRequestError as err:
    print("bad request:", err.body)
except RateLimitError as err:
    print("retry in", err.retry_after_sec)

Examples

Dev

pip install -e ".[dev,stellar]"
pytest

Publish (maintainers)

# From sdk-py/ — do not put npm pack tarballs in dist/ (breaks twine).
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=pypi-...   # scope: entire account or project noether-sdk
./scripts/publish_pypi.sh

Status

Phase 7 v0 — REST surface complete + WS sub-client + 11 unit tests. Mirror of the TypeScript SDK shape so cross-language services can be written in either language without translation cost.

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

noether_sdk-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

noether_sdk-0.1.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file noether_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: noether_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for noether_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 026d9b1de575e797e0f0248adf0eacf28f16433b34d17daf4a3ca2362dcaad9c
MD5 ee96e77fbf87bcfbe1020244ddaacbc6
BLAKE2b-256 8ddc1b88e5ae1c27f47e54bf3b298cd839ff04a8f9d106db2e011728280883b4

See more details on using hashes here.

File details

Details for the file noether_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: noether_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for noether_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f5e7b6e3bcb48fe294f5dcc0ae570856aacbad69890ddd8d48b89b3689ff086
MD5 fe96f9acf587d3efa6f03619b8740885
BLAKE2b-256 045005708f7b18705e9b5a380d1ea09e67834744a9d6cd4ccca7a4c4bc708f14

See more details on using hashes here.

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