File size: 6,954 Bytes
e983fbc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# 📚 API Resources Guide
## فایلهای منابع در این پوشه
این پوشه شامل منابع کاملی از **162+ API رایگان** است که میتوانید از آنها استفاده کنید.
---
## 📁 فایلها
### 1. `crypto_resources_unified_2025-11-11.json`
- **200+ منبع** کامل با تمام جزئیات
- شامل: RPC Nodes, Block Explorers, Market Data, News, Sentiment, DeFi
- ساختار یکپارچه برای همه منابع
- API Keys embedded برای برخی سرویسها
### 2. `ultimate_crypto_pipeline_2025_NZasinich.json`
- **162 منبع** با نمونه کد TypeScript
- شامل: Block Explorers, Market Data, News, DeFi
- Rate Limits و توضیحات هر سرویس
### 3. `api-config-complete__1_.txt`
- تنظیمات و کانفیگ APIها
- Fallback strategies
- Authentication methods
---
## 🔑 APIهای استفاده شده در برنامه
برنامه فعلی از این APIها استفاده میکند:
### ✅ Market Data:
```json
{
"CoinGecko": "https://api.coingecko.com/api/v3",
"CoinCap": "https://api.coincap.io/v2",
"CoinStats": "https://api.coinstats.app",
"Cryptorank": "https://api.cryptorank.io/v1"
}
```
### ✅ Exchanges:
```json
{
"Binance": "https://api.binance.com/api/v3",
"Coinbase": "https://api.coinbase.com/v2",
"Kraken": "https://api.kraken.com/0/public"
}
```
### ✅ Sentiment & Analytics:
```json
{
"Alternative.me": "https://api.alternative.me/fng",
"DeFi Llama": "https://api.llama.fi"
}
```
---
## 🚀 چگونه API جدید اضافه کنیم؟
### مثال: اضافه کردن CryptoCompare
#### 1. در `app.py` به `API_PROVIDERS` اضافه کنید:
```python
API_PROVIDERS = {
"market_data": [
# ... موارد قبلی
{
"name": "CryptoCompare",
"base_url": "https://min-api.cryptocompare.com/data",
"endpoints": {
"price": "/price",
"multiple": "/pricemulti"
},
"auth": None,
"rate_limit": "100/hour",
"status": "active"
}
]
}
```
#### 2. تابع جدید برای fetch:
```python
async def get_cryptocompare_data():
async with aiohttp.ClientSession() as session:
url = "https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH&tsyms=USD"
data = await fetch_with_retry(session, url)
return data
```
#### 3. استفاده در endpoint:
```python
@app.get("/api/cryptocompare")
async def cryptocompare():
data = await get_cryptocompare_data()
return {"data": data}
```
---
## 📊 نمونههای بیشتر از منابع
### Block Explorer - Etherscan:
```python
# از crypto_resources_unified_2025-11-11.json
{
"id": "etherscan_primary",
"name": "Etherscan",
"chain": "ethereum",
"base_url": "https://api.etherscan.io/api",
"auth": {
"type": "apiKeyQuery",
"key": "YOUR_KEY_HERE",
"param_name": "apikey"
},
"endpoints": {
"balance": "?module=account&action=balance&address={address}&apikey={key}"
}
}
```
### استفاده:
```python
async def get_eth_balance(address):
url = f"https://api.etherscan.io/api?module=account&action=balance&address={address}&apikey=YOUR_KEY"
async with aiohttp.ClientSession() as session:
data = await fetch_with_retry(session, url)
return data
```
---
### News API - CryptoPanic:
```python
# از فایل منابع
{
"id": "cryptopanic",
"name": "CryptoPanic",
"role": "crypto_news",
"base_url": "https://cryptopanic.com/api/v1",
"endpoints": {
"posts": "/posts/?auth_token={key}"
}
}
```
### استفاده:
```python
async def get_news():
url = "https://cryptopanic.com/api/v1/posts/?auth_token=free"
async with aiohttp.ClientSession() as session:
data = await fetch_with_retry(session, url)
return data["results"]
```
---
### DeFi - Uniswap:
```python
# از فایل منابع
{
"name": "Uniswap",
"url": "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3",
"type": "GraphQL"
}
```
### استفاده:
```python
async def get_uniswap_data():
query = """
{
pools(first: 10, orderBy: volumeUSD, orderDirection: desc) {
id
token0 { symbol }
token1 { symbol }
volumeUSD
}
}
"""
url = "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3"
async with aiohttp.ClientSession() as session:
async with session.post(url, json={"query": query}) as response:
data = await response.json()
return data
```
---
## 🔧 نکات مهم
### Rate Limits:
```python
# همیشه rate limit رو رعایت کنید
await asyncio.sleep(1) # بین درخواستها
# یا از cache استفاده کنید
cache = {"data": None, "timestamp": None, "ttl": 60}
```
### Error Handling:
```python
try:
data = await fetch_api()
except aiohttp.ClientError:
# Fallback به API دیگه
data = await fetch_fallback_api()
```
### Authentication:
```python
# برخی APIها نیاز به auth دارند
headers = {"X-API-Key": "YOUR_KEY"}
async with session.get(url, headers=headers) as response:
data = await response.json()
```
---
## 📝 چکلیست برای اضافه کردن API جدید
- [ ] API را در `API_PROVIDERS` اضافه کن
- [ ] تابع `fetch` بنویس
- [ ] Error handling اضافه کن
- [ ] Cache پیادهسازی کن
- [ ] Rate limit رعایت کن
- [ ] Fallback تعریف کن
- [ ] Endpoint در FastAPI بساز
- [ ] Frontend رو آپدیت کن
- [ ] تست کن
---
## 🌟 APIهای پیشنهادی برای توسعه
از فایلهای منابع، این APIها خوب هستند:
### High Priority:
1. **Messari** - تحلیل عمیق
2. **Glassnode** - On-chain analytics
3. **LunarCrush** - Social sentiment
4. **Santiment** - Market intelligence
### Medium Priority:
1. **Dune Analytics** - Custom queries
2. **CoinMarketCap** - Alternative market data
3. **TradingView** - Charts data
4. **CryptoQuant** - Exchange flows
### Low Priority:
1. **Various RSS Feeds** - News aggregation
2. **Social APIs** - Twitter, Reddit
3. **NFT APIs** - OpenSea, Blur
4. **Blockchain RPCs** - Direct chain queries
---
## 🎓 منابع یادگیری
- [FastAPI Async](https://fastapi.tiangolo.com/async/)
- [aiohttp Documentation](https://docs.aiohttp.org/)
- [API Best Practices](https://restfulapi.net/)
---
## 💡 نکته نهایی
**همه APIهای موجود در فایلها رایگان هستند!**
برای استفاده از آنها فقط کافیست:
1. API را از فایل منابع پیدا کنید
2. به `app.py` اضافه کنید
3. تابع fetch بنویسید
4. استفاده کنید!
---
**موفق باشید! 🚀**
|