|
| 1 | +# claw402 |
| 2 | + |
| 3 | +[](https://pypi.org/project/claw402/) |
| 4 | +[](LICENSE) |
| 5 | + |
| 6 | +Typed Python SDK for [claw402.ai](https://claw402.ai) — pay-per-call crypto data APIs via [x402](https://www.x402.org/) micropayments. |
| 7 | + |
| 8 | +**96+ endpoints** covering fund flow, liquidations, ETF flows, AI trading signals, whale tracking, funding rates, open interest, and more. No API key, no signup, no subscription — just a Base wallet with USDC. |
| 9 | + |
| 10 | +## Install |
| 11 | + |
| 12 | +```bash |
| 13 | +pip install claw402 |
| 14 | +``` |
| 15 | + |
| 16 | +## Quick Start |
| 17 | + |
| 18 | +```python |
| 19 | +from claw402 import Claw402 |
| 20 | + |
| 21 | +client = Claw402(private_key="0xYourPrivateKey") |
| 22 | + |
| 23 | +# Fund flow — $0.001 per call |
| 24 | +flow = client.coinank.fund.realtime(product_type="SWAP") |
| 25 | +print(flow) |
| 26 | + |
| 27 | +# AI trading signals |
| 28 | +signals = client.nofxos.netflow.top_ranking(limit=20, duration="1h") |
| 29 | +print(signals) |
| 30 | + |
| 31 | +# Fear & Greed Index |
| 32 | +sentiment = client.coinank.indicator.fear_greed() |
| 33 | +print(sentiment) |
| 34 | +``` |
| 35 | + |
| 36 | +## Features |
| 37 | + |
| 38 | +- **Typed methods** — every endpoint has a dedicated Python method with keyword arguments |
| 39 | +- **Automatic x402 payment** — signs EIP-3009 USDC transfers locally, never sends your key |
| 40 | +- **Two resource groups** — `client.coinank.*` (market data) and `client.nofxos.*` (AI signals) |
| 41 | +- **Context manager** — `with Claw402(...) as client:` for automatic cleanup |
| 42 | +- **Zero config** — just a private key, no API keys or registration |
| 43 | +- **Base mainnet** — pays $0.001 USDC per call on Coinbase L2 |
| 44 | + |
| 45 | +## API Overview |
| 46 | + |
| 47 | +### Coinank (Market Data) |
| 48 | + |
| 49 | +| Resource | Methods | Description | |
| 50 | +|----------|---------|-------------| |
| 51 | +| `coinank.fund` | `realtime`, `history` | Real-time & historical fund flow | |
| 52 | +| `coinank.oi` | `all`, `agg_chart`, `symbol_chart`, `kline`, ... | Open interest data | |
| 53 | +| `coinank.liquidation` | `orders`, `intervals`, `agg_history`, `liq_map`, `heat_map`, ... | Liquidation tracking | |
| 54 | +| `coinank.funding_rate` | `current`, `accumulated`, `hist`, `weighted`, `heatmap`, ... | Funding rate analytics | |
| 55 | +| `coinank.longshort` | `realtime`, `buy_sell`, `person`, `position`, ... | Long/short ratios | |
| 56 | +| `coinank.hyper` | `top_position`, `top_action` | HyperLiquid whale tracking | |
| 57 | +| `coinank.etf` | `us_btc`, `us_eth`, `us_btc_inflow`, `us_eth_inflow`, `hk_inflow` | ETF flow data | |
| 58 | +| `coinank.indicator` | `fear_greed`, `altcoin_season`, `btc_multiplier`, `ahr999`, ... | Market cycle indicators | |
| 59 | +| `coinank.market_order` | `cvd`, `agg_cvd`, `buy_sell_value`, ... | Taker flow / CVD | |
| 60 | +| `coinank.kline` | `lists` | OHLCV candlestick data | |
| 61 | +| `coinank.price` | `last` | Real-time price | |
| 62 | +| `coinank.rank` | `screener`, `oi`, `volume`, `price`, `liquidation`, ... | Rankings & screeners | |
| 63 | +| `coinank.news` | `list`, `detail` | Crypto news & alerts | |
| 64 | + |
| 65 | +### Nofxos (AI Signals) |
| 66 | + |
| 67 | +| Resource | Methods | Description | |
| 68 | +|----------|---------|-------------| |
| 69 | +| `nofxos.ai500` | `list`, `stats` | AI500 high-potential coin signals | |
| 70 | +| `nofxos.ai300` | `list`, `stats` | AI300 quant model rankings | |
| 71 | +| `nofxos.netflow` | `top_ranking`, `low_ranking` | Net capital flow rankings | |
| 72 | +| `nofxos.oi` | `top_ranking`, `low_ranking` | OI change rankings | |
| 73 | +| `nofxos.funding_rate` | `top`, `low` | Extreme funding rate coins | |
| 74 | +| `nofxos.price` | `ranking` | Price change rankings | |
| 75 | +| `nofxos.upbit` | `hot`, `netflow_top_ranking`, `netflow_low_ranking` | Korean market data | |
| 76 | + |
| 77 | +## Configuration |
| 78 | + |
| 79 | +```python |
| 80 | +# Custom base URL |
| 81 | +client = Claw402( |
| 82 | + private_key="0x...", |
| 83 | + base_url="https://custom.gateway", |
| 84 | +) |
| 85 | +``` |
| 86 | + |
| 87 | +## How Payment Works |
| 88 | + |
| 89 | +1. SDK sends a GET request to the endpoint |
| 90 | +2. Server responds with `402 Payment Required` + payment details in header |
| 91 | +3. SDK signs an EIP-3009 `TransferWithAuthorization` for USDC on Base |
| 92 | +4. SDK retries the request with the `PAYMENT-SIGNATURE` header |
| 93 | +5. Server verifies payment on-chain and returns the data |
| 94 | + |
| 95 | +Your private key **never leaves your machine** — it only signs the payment locally. |
| 96 | + |
| 97 | +## Requirements |
| 98 | + |
| 99 | +- Python 3.9+ |
| 100 | +- A wallet with USDC on [Base mainnet](https://base.org) |
| 101 | +- Get USDC on Base: [bridge.base.org](https://bridge.base.org) |
| 102 | + |
| 103 | +## License |
| 104 | + |
| 105 | +MIT |
0 commit comments