|
| 1 | +# rpcnode |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +API: `https://api.rpcnode.dev` |
| 6 | + |
| 7 | +Repo: [github.com/rpcnode/api-sdk-python](https://github.com/rpcnode/api-sdk-python) |
| 8 | + |
| 9 | +## Install |
| 10 | + |
| 11 | +```bash |
| 12 | +pip install "rpcnode @ git+https://github.com/rpcnode/api-sdk-python.git" |
| 13 | +# or: |
| 14 | +git clone git@github.com:rpcnode/api-sdk-python.git |
| 15 | +cd api-sdk-python && pip install -e ".[dev]" |
| 16 | +``` |
| 17 | + |
| 18 | +## Auth |
| 19 | + |
| 20 | +Every request is HMAC-signed. Query string is **not** part of the signature. |
| 21 | + |
| 22 | +| Header | Value | |
| 23 | +|--------|--------| |
| 24 | +| `X-Api-Key` | UUID from the cabinet | |
| 25 | +| `X-Timestamp` | Unix seconds (±300s) | |
| 26 | +| `X-Signature` | `hex(hmac_sha256(secret, canonical))` | |
| 27 | + |
| 28 | +``` |
| 29 | +{timestamp}\n{METHOD}\n{path}\n{sha256_hex(body)} |
| 30 | +``` |
| 31 | + |
| 32 | +Empty body → SHA-256 of `""`. Headers are added by the client. |
| 33 | + |
| 34 | +Rate limit: **10 RPS per API key**. Over it the API returns HTTP 429 and `Rate limit exceeded.` (`Retry-After: 1`). This is not JSON-RPC endpoint RPS. |
| 35 | + |
| 36 | +## Quickstart |
| 37 | + |
| 38 | +```python |
| 39 | +import os |
| 40 | +from rpcnode import RpcNodeClient |
| 41 | + |
| 42 | +client = RpcNodeClient( |
| 43 | + base_url=os.environ.get("PUBLIC_API_BASE", "https://api.rpcnode.dev"), |
| 44 | + api_key=os.environ["PUBLIC_API_KEY"], # UUID |
| 45 | + secret=os.environ["PUBLIC_API_SECRET"], # sk_live_… |
| 46 | +) |
| 47 | + |
| 48 | +account = client.get_account() |
| 49 | +tokens = client.list_network_tokens(network_slug="tron-nile", include_native=True) |
| 50 | +``` |
| 51 | + |
| 52 | +## Methods |
| 53 | + |
| 54 | +| Client | HTTP | |
| 55 | +|--------|------| |
| 56 | +| `get_account()` | `GET /v1/account` | |
| 57 | +| `get_account_usage(days=30)` | `GET /v1/account/usage` | |
| 58 | +| `list_endpoints()` | `GET /v1/endpoints` | |
| 59 | +| `list_available_networks()` | `GET /v1/endpoints/available-networks` | |
| 60 | +| `get_workspace_usage(days=None)` | `GET /v1/endpoints/usage` | |
| 61 | +| `create_endpoint(**body)` | `POST /v1/endpoints` | |
| 62 | +| `get_endpoint_usage(id, days=None)` | `GET /v1/endpoints/{id}/usage` | |
| 63 | +| `update_endpoint_status(id, status)` | `PATCH /v1/endpoints/{id}/status` | |
| 64 | +| `update_endpoint_allowed_ips(id, ips)` | `PATCH /v1/endpoints/{id}/allowed-ips` | |
| 65 | +| `get_address_watch_account()` | `GET /v1/address-watch/account` | |
| 66 | +| `list_addresses(**params)` | `GET /v1/address-watch/addresses` | |
| 67 | +| `add_address(network_slug=, address=)` | `POST /v1/address-watch/addresses` | |
| 68 | +| `delete_address(watch_id)` | `DELETE /v1/address-watch/addresses` | |
| 69 | +| `list_events(**params)` | `GET /v1/address-watch/events` | |
| 70 | +| `get_webhook()` | `GET /v1/address-watch/webhook` | |
| 71 | +| `set_webhook(enabled=, url=, events=)` | `PUT /v1/address-watch/webhook` | |
| 72 | +| `list_payments(**params)` | `GET /v1/payments` | |
| 73 | +| `create_payment(**body)` | `POST /v1/payments` | |
| 74 | +| `get_payment(payment_id)` | `GET /v1/payments/{id}` | |
| 75 | +| `get_payment_by_order_id(order_id)` | `GET /v1/payments/orders/{orderId}` | |
| 76 | +| `list_network_tokens(network_slug=, include_native=)` | `GET /v1/network-tokens` | |
| 77 | + |
| 78 | +## Tests |
| 79 | + |
| 80 | +```bash |
| 81 | +cp .env.example .env # PUBLIC_API_KEY + PUBLIC_API_SECRET for live smokes |
| 82 | +pytest -q |
| 83 | +``` |
| 84 | + |
| 85 | +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`. |
| 86 | + |
| 87 | +## License |
| 88 | + |
| 89 | +MIT |
0 commit comments