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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: noether_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 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.0.tar.gz
Algorithm Hash digest
SHA256 e2f88989c7c0096ade028e027aa2f05e24d0f50c47071e6211730ca6dcf0e206
MD5 85027bd7b0b5fd146a9db45cccdb2e72
BLAKE2b-256 8922ad80caaa451b94dafc0442773e08849efab1ae829cc0b8062643f7d981fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: noether_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6208b16d65b0a61f62754a9b8c0ae6d7a1a6373d2663cd6e3bcf4b8f9ed05bb
MD5 9bc72f109e983b1b55358709bd7e0a2e
BLAKE2b-256 bf78d8cc880a1af5b279ebd075c8c379c798f444b77edf885f506882b54fb754

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