Metadata-Version: 2.4
Name: coinrebate-sdk
Version: 0.1.0
Summary: CoinRebate Python SDK — Get the best crypto exchange fees in 3 lines of code.
Author-email: CoinRebate <dev@coinrebate.vip>
License: MIT
Project-URL: Homepage, https://www.coinrebate.vip
Project-URL: Documentation, https://www.coinrebate.vip/api-docs.html
Project-URL: Repository, https://github.com/skheman2026-sketch/coinrebate
Project-URL: Bug Tracker, https://github.com/skheman2026-sketch/coinrebate/issues
Keywords: crypto,exchange,fees,referral,ccxt,trading,ai-agent
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28
Provides-Extra: ccxt
Requires-Dist: ccxt>=4.0; extra == "ccxt"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: responses>=0.23; extra == "dev"
Dynamic: license-file

# 🦀 CoinRebate SDK — CoinRebate Python SDK

> **3 行代码获取全网最优交易所费率。为 AI Agent 和量化交易者而生。**

[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## ⚡ Quick Start

```python
from coinrebate_sdk import CoinRebateClient

client = CoinRebateClient()
best = client.get_best_exchange(purpose="futures")
print(f"Use {best['name']} — {best['fee_discount']}")
# → Use Bybit — 20% OFF
```

## 📦 Installation

```bash
# 基础安装
pip install -e .

# 带 CCXT 集成
pip install -e ".[ccxt]"
```

## 🔧 API Reference

### CoinRebateClient

```python
client = CoinRebateClient(
    base_url="https://www.coinrebate.vip",  # 可选
    timeout=10,       # 请求超时（秒）
    max_retries=3,    # 最大重试
    retry_delay=1.0,  # 重试间隔
)
```

### 核心方法

| 方法 | 说明 | 返回 |
|------|------|------|
| `health_check()` | API 健康检查 | `{"status": "ok", ...}` |
| `get_best_exchange(purpose, kyc)` | 获取推荐交易所 | 交易所 dict |
| `get_all_exchanges(purpose, kyc)` | 获取全部交易所 | list[dict] |
| `get_exchange(slug)` | 查询指定交易所 | 交易所 dict |
| `get_full_response(...)` | 获取完整 API 响应 | 完整 JSON |
| `get_ccxt_instance(slug, purpose)` | 创建 CCXT 实例 | ccxt.Exchange |
| `print_fee_table()` | 终端打印费率对比表 | None |

### 参数说明

- **purpose**: `"futures"` 或 `"spot"` — 按用途筛选推荐
- **kyc**: `False` — 只返回免 KYC 的 DEX（AI Agent 首选）
- **slug**: 交易所标识 — `binance`, `okx`, `bybit`, `bitget`, `gate`, `hyperliquid`, `aster`

## 🤖 AI Agent 场景

```python
# AI Agent 不能做 KYC → 只看 DEX
client = CoinRebateClient()
dex = client.get_best_exchange(kyc=False)
print(f"→ {dex['name']}: {dex['signup_url']}")
# → Hyperliquid: https://www.coinrebate.vip/go/hyperliquid
```

## 📊 CCXT 集成

```python
# 自动创建带 referral code 的 CCXT 实例
client = CoinRebateClient()
exchange = client.get_ccxt_instance("binance")

# 直接获取行情
ticker = exchange.fetch_ticker("BTC/USDT")
print(f"BTC/USDT: {ticker['last']}")
```

## 🖥️ 终端费率表

```python
client = CoinRebateClient()
client.print_fee_table()
```

```
══════════════════════════════════════════════════════════════════════════
          CoinRebate Fee Comparison Table
══════════════════════════════════════════════════════════════════════════
  Exchange         Type  Discount       KYC   CCXT ID
────────────────────────────────────────────────────────────────────────
  币安 Binance     CEX   20% OFF        Yes   binance
  欧意 OKX        CEX   20% OFF        Yes   okx
  Bybit            CEX   20% OFF        Yes   bybit
  ...
══════════════════════════════════════════════════════════════════════════
```

## 🔗 Links

- **API Docs**: https://www.coinrebate.vip/api-docs.html
- **OpenAPI Spec**: https://www.coinrebate.vip/openapi.json
- **Website**: https://www.coinrebate.vip

## ⚖️ Legal

CoinRebate provides fee comparison only. We do NOT custody funds or provide investment advice. NFA.
