Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

Repository files navigation

claw402

PyPI versionLicense: MIT

Typed Python SDK for claw402.ai — pay-per-call data APIs via x402 micropayments.

200+ endpoints covering crypto market data, US stocks, China A-shares, forex, global time-series, and AI (OpenAI/Anthropic/DeepSeek/Qwen). No API key, no signup, no subscription — just a Base wallet with USDC.

Install

pip install git+https://github.com/NoFxAiOS/claw402-python.git

Quick Start

fromclaw402importClaw402client=Claw402(private_key="0xYourPrivateKey")
# Crypto: Fund flow — $0.001/callflow=client.coinank.fund.realtime(product_type="SWAP")
print(flow)
# US Stocks: Latest quote — $0.001/callquote=client.alpaca.quotes.latest(symbols="AAPL,TSLA")
print(quote)
# US Stocks: Market snapshot — $0.002/callsnap=client.polygon.snapshot.all(tickers="AAPL")
print(snap)
# China A-shares — $0.001/callstocks=client.tushare.cn.stock_basic(list_status="L")
print(stocks)
# Forex time-series — $0.001/callts=client.twelvedata.get_time_series(symbol="EUR/USD", interval="1h")
print(ts)
# AI: OpenAI chat — $0.01/callresp=client.openai.openai.chat({"messages": [{"role": "user", "content": "Hello"}]})
print(resp)
# AI: Anthropic Claude — $0.015/callresp=client.anthropic.anthropic.messages({"messages": [{"role": "user", "content": "Hello"}]})
print(resp)

Features

  • Typed methods — every endpoint has a dedicated Python method with keyword arguments
  • Automatic x402 payment — signs EIP-3009 USDC transfers locally, never sends your key
  • 11 provider groups — crypto, US stocks, China stocks, forex, global data, and AI
  • Context managerwith Claw402(...) as client: for automatic cleanup
  • Zero config — just a private key, no API keys or registration
  • Base mainnet — pays USDC per call on Coinbase L2

API Overview

Crypto Market Data

Coinank

ResourceMethodsDescription
coinank.fundrealtime, historyReal-time & historical fund flow
coinank.oiall, agg_chart, symbol_chart, kline, ...Open interest data
coinank.liquidationorders, intervals, agg_history, liq_map, heat_map, ...Liquidation tracking
coinank.funding_ratecurrent, accumulated, hist, weighted, heatmap, ...Funding rate analytics
coinank.longshortrealtime, buy_sell, person, position, ...Long/short ratios
coinank.hypertop_position, top_actionHyperLiquid whale tracking
coinank.etfus_btc, us_eth, us_btc_inflow, us_eth_inflow, hk_inflowETF flow data
coinank.indicatorfear_greed, altcoin_season, btc_multiplier, ahr999, ...Market cycle indicators
coinank.market_ordercvd, agg_cvd, buy_sell_value, ...Taker flow / CVD
coinank.klinelistsOHLCV candlestick data
coinank.pricelastReal-time price
coinank.rankscreener, oi, volume, price, liquidation, ...Rankings & screeners
coinank.newslist, detailCrypto news & alerts

Nofxos (AI Signals)

ResourceMethodsDescription
nofxos.ai500list, statsAI500 high-potential coin signals
nofxos.ai300list, statsAI300 quant model rankings
nofxos.netflowtop_ranking, low_rankingNet capital flow rankings
nofxos.oitop_ranking, low_rankingOI change rankings
nofxos.funding_ratetop, lowExtreme funding rate coins
nofxos.pricerankingPrice change rankings
nofxos.upbithot, netflow_top_ranking, netflow_low_rankingKorean market data

US Stock & Options Market

Alpaca

ResourceMethodsDescription
alpaca.quoteslatest, historyReal-time & historical quotes — $0.001–0.002/call
alpaca.barslatestLatest OHLCV bar — $0.001/call
alpaca.tradeslatest, historyReal-time & historical trades — $0.001–0.002/call
alpaca.optionsbars, quotes_latest, snapshotsOptions chain data — $0.003/call
alpacaget_bars, snapshots, snapshot, movers, most_actives, news, corporate_actionsDirect market endpoints — $0.001–0.002/call
# Latest quotes for multiple symbolsq=client.alpaca.quotes.latest(symbols="AAPL,MSFT,TSLA")
# Historical barsbars=client.alpaca.get_bars(symbols="AAPL", timeframe="1Day", start="2024-01-01")
# Top market moversmovers=client.alpaca.movers(top=10, market_type="stocks")
# Options snapshotsopts=client.alpaca.options.snapshots(symbols="AAPL240119C00150000")

Polygon

ResourceMethodsDescription
polygon.aggsaggs, grouped_daily, daily_open_close, previous_closeAggregates / OHLCV bars — $0.001/call
polygon.snapshotsall_tickers, single_ticker, gainers_losers, universal_snapshot, options_chainFull market snapshots — $0.002/call
polygon.tradestrades, last_trade, quotes, last_quoteTrade & quote tick data — $0.002/call
polygonticker_details, market_status, ticker_types, exchanges, conditions, sma, ema, rsi, macdReference & technical indicators — $0.001–0.003/call
# OHLCV barsbars=client.polygon.aggs.aggs(
stocksTicker="AAPL", multiplier=1, timespan="day",
from_="2024-01-01", to="2024-12-31"
)
# RSI indicatorrsi=client.polygon.rsi(stocksTicker="AAPL", timespan="day", window=14)
# Options chainchain=client.polygon.snapshots.options_chain(underlyingAsset="AAPL")

Alpha Vantage

ResourceMethodsDescription
alphavantage.usquote, search, daily, daily_adjusted, intraday, weekly, monthly, overview, earnings, income, balance_sheet, cash_flow, movers, news, rsi, macd, bbands, sma, emaComprehensive financial data — $0.001–0.003/call
# Real-time quotequote=client.alphavantage.us.quote(symbol="AAPL")
# Daily OHLCVdaily=client.alphavantage.us.daily(symbol="AAPL", outputsize="compact")
# Top movers (no params)movers=client.alphavantage.us.movers()
# News sentimentnews=client.alphavantage.us.news(tickers="AAPL")

China A-Shares

Tushare

ResourceMethodsDescription
tushare.cnstock_basic, daily, weekly, monthly, daily_basic, trade_cal, income, balance_sheet, cash_flow, dividend, northbound, moneyflow, margin, margin_detail, top_list, top_instChina A-share market data — $0.001–0.003/call
# Stock liststocks=client.tushare.cn.stock_basic(list_status="L")
# Daily OHLCVdaily=client.tushare.cn.daily(ts_code="000001.SZ", start_date="20240101", end_date="20240131")
# Money flowflow=client.tushare.cn.moneyflow(ts_code="000001.SZ", start_date="20240101")
# Northbound capitalnorth=client.tushare.cn.northbound(trade_date="20240101")

Global Time-Series & Forex

Twelve Data

ResourceMethodsDescription
twelvedata.time_seriescomplex (POST)Complex multi-symbol/indicator query — $0.005/call
twelvedata.indicatorsma, ema, rsi, macd, bbands, atrTechnical indicators — $0.002/call
twelvedata.metalsprice, time_seriesPrecious metals prices — $0.001/call
twelvedata.indiceslist_, quoteGlobal index data — $0.001/call
twelvedataget_time_series, price, quote, eod, exchange_rate, forex_pairs, economic_calendarDirect endpoints — $0.001/call
# Time series (use get_time_series, NOT time_series — time_series is the sub-resource)ts=client.twelvedata.get_time_series(symbol="EUR/USD", interval="1h", outputsize=3)
# Technical indicatorsrsi=client.twelvedata.indicator.rsi(symbol="AAPL", interval="1day", time_period=14, outputsize=3)
# Real-time priceprice=client.twelvedata.price(symbol="BTC/USD")
# Metalsgold=client.twelvedata.metals.price(symbol="XAU/USD")

AI Providers

OpenAI

ResourceMethodsDescription
openai.openaichat, chat_mini, embeddings, embeddings_large, images, modelsOpenAI API — $0.001–0.05/call
# Chat (GPT-4o)resp=client.openai.openai.chat({
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Analyze AAPL stock trend"}]
})
# Embeddingsemb=client.openai.openai.embeddings({
"input": "crypto market sentiment",
"model": "text-embedding-3-small"
})

Anthropic

ResourceMethodsDescription
anthropic.anthropicmessages, messages_extended, count_tokensAnthropic Claude API — $0.01–0.015/call
# Claude messagesresp=client.anthropic.anthropic.messages({
"model": "claude-opus-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this earnings report: ..."}]
})

DeepSeek

ResourceMethodsDescription
deepseek.deepseekchat, chat_reasoner, completions, modelsDeepSeek chat, reasoning, beta completions, model listing — $0.001–0.005/call
resp=client.deepseek.deepseek.chat({
"messages": [{"role": "user", "content": "Explain BTC basis trade"}]
})

Qwen

ResourceMethodsDescription
qwen.qwenchat_max, chat_plus, chat_turbo, chat_flash, chat_coder, chat_vlQwen chat, coder, and vision models — $0.002–0.01/call
resp=client.qwen.qwen.chat_max({
"messages": [{"role": "user", "content": "Write a Go HTTP middleware"}]
})

Configuration

# Custom base URLclient=Claw402(
private_key="0x...",
base_url="https://custom.gateway",
)

How Payment Works

  1. SDK sends a GET/POST request to the endpoint
  2. Server responds with 402 Payment Required + payment details in header
  3. SDK signs an EIP-3009 TransferWithAuthorization for USDC on Base
  4. SDK retries the request with the PAYMENT-SIGNATURE header
  5. Server verifies payment on-chain and returns the data

Your private key never leaves your machine — it only signs the payment locally.

Requirements

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages