Skip to content

Latest commit

 

History

History
87 lines (66 loc) · 3.01 KB

File metadata and controls

87 lines (66 loc) · 3.01 KB

rpcnode

Official Python client for the RpcNode Public API: dedicated fullnode RPC (Ethereum, Solana, Bitcoin, Tron, BNB Chain, Polygon, Arbitrum, Optimism, Base, and more), HMAC-signed merchant HTTP, address watch webhooks, and crypto payments.

API: https://api.rpcnode.dev

Repo: github.com/rpcnode/api-sdk-python

Install

pip install "rpcnode @ git+https://github.com/rpcnode/api-sdk-python.git"
# or:
git clone git@github.com:rpcnode/api-sdk-python.git
cd api-sdk-python && pip install -e ".[dev]"

Auth

Every request is HMAC-signed. Query string is not part of the signature.

Header Value
X-Api-Key Key prefix (pk_live_…)
X-Timestamp Unix seconds (±300s)
X-Signature hex(hmac_sha256(secret, canonical))
{timestamp}\n{METHOD}\n{path}\n{sha256_hex(body)}

Empty body → SHA-256 of "". Headers are added by the client.

Quickstart

import os
from rpcnode import RpcNodeClient

client = RpcNodeClient(
    base_url=os.environ.get("PUBLIC_API_BASE", "https://api.rpcnode.dev"),
    api_key=os.environ["PUBLIC_API_KEY"],       # pk_live_…
    secret=os.environ["PUBLIC_API_SECRET"],     # sk_live_…
)

account = client.get_account()
tokens = client.list_network_tokens(network_slug="tron-nile", include_native=True)

Methods

Client HTTP
get_account() GET /v1/account
get_account_usage(days=30) GET /v1/account/usage
list_endpoints() GET /v1/endpoints
list_available_networks() GET /v1/endpoints/available-networks
get_workspace_usage(days=None) GET /v1/endpoints/usage
create_endpoint(**body) POST /v1/endpoints
get_endpoint_usage(id, days=None) GET /v1/endpoints/{id}/usage
update_endpoint_status(id, status) PATCH /v1/endpoints/{id}/status
update_endpoint_allowed_ips(id, ips) PATCH /v1/endpoints/{id}/allowed-ips
get_address_watch_account() GET /v1/address-watch/account
list_addresses(**params) GET /v1/address-watch/addresses
add_address(network_slug=, address=) POST /v1/address-watch/addresses
delete_address(watch_id) DELETE /v1/address-watch/addresses
list_events(**params) GET /v1/address-watch/events
get_webhook() GET /v1/address-watch/webhook
set_webhook(enabled=, url=, events=) PUT /v1/address-watch/webhook
list_payments(**params) GET /v1/payments
create_payment(**body) POST /v1/payments
get_payment(payment_id) GET /v1/payments/{id}
get_payment_by_order_id(order_id) GET /v1/payments/orders/{orderId}
list_network_tokens(network_slug=, include_native=) GET /v1/network-tokens

Tests

cp .env.example .env   # PUBLIC_API_KEY + PUBLIC_API_SECRET for live smokes
pytest -q

HMAC unit tests run without credentials. Live reads use .env or the environment. Writes: PUBLIC_API_SMOKE_MUTATE=1, PUBLIC_API_SMOKE_CREATE_PAYMENT=1.

License

MIT