Skip to main content
A zero-dependency Python client with the same scope as @ravnexchange/sdk: quote, execute, submit-signature, status, tokens, and chains, snake_cased. This is for a plain, non-agent Python backend that wants a typed wrapper instead of hand-rolling POST/GET calls against the JSON API.
Building an AI agent instead of a backend service? Use RAVN’s MCP server rather than this package, it’s free, already speaks the agent’s tool-calling protocol, and covers this same surface plus more.

Setup

str
Self-serve or enterprise key. Omit for the anonymous tier: it works immediately, at a lower rate limit. See Authentication.
str
Default https://app.ravn.exchange/api/v1.
callable
Swap in your own opener for tests or an unusual runtime. Defaults to urllib.request.urlopen. Built on the stdlib urllib.request, not requests, so installing this package adds nothing to your dependency tree.

Full example

Request fields are still the camelCase keys the API expects (inputChainId, not input_chain_id), the client is a typed wrapper, not a schema translator. Only the method names themselves are snake_case.

Methods

Every method returns the unwrapped data from the response envelope, and raises RavnApiError on anything else. Field meanings match the API Reference pages linked from each method.

get_quote

Wraps POST /quote. Omitting destinationAddress/refundAddress returns a preview-only quote, so check quote["executable"] before calling execute. Supports sandbox: True the same as the raw API, see Sandbox Mode.

execute

Wraps POST /execute. This client doesn’t sign or send anything for you, branch on executionType exactly as in the Quickstart.

submit_signature

Wraps POST /submit-signature. Only for SIGNATURE-type executions. Returns {"statusRef": ...} to poll get_status with.

get_status

Wraps GET /status. ref is the statusRef from execute (for DEPOSIT) or from submit_signature (for SIGNATURE). Once terminal, a venue that reports it adds deliveredAmount and txHash to the result.

get_tokens

Wraps GET /tokens for the given chain.

get_chains

Wraps GET /chains. Static, safe to cache client-side.

Errors

Every non-2xx response, or a 2xx body that still carries an error field, raises RavnApiError:
str
The stable, machine-readable code. See Errors for the full table.
Any
Present on some codes, for example the failed fields on INVALID_REQUEST.
dict
requestId and version, when the API returned an envelope at all.
The human-readable message isn’t a separate .message attribute (Python’s base Exception doesn’t give you one for free); read it with str(e) instead, same value the TS client’s err.message carries.