File size: 4,525 Bytes
d6d843f |
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 |
# 🚀 تست سریع API
## تست آنلاین (فوری)
همین الان میتوانید API را تست کنید:
### 1. در مرورگر
برو به:
```
https://really-amin-datasourceforcryptocurrency.hf.space/health
```
### 2. با curl در Terminal
```bash
# Health Check
curl https://really-amin-datasourceforcryptocurrency.hf.space/health
# System Info
curl https://really-amin-datasourceforcryptocurrency.hf.space/info
# OHLCV Data (نمودار شمعی بیتکوین)
curl "https://really-amin-datasourceforcryptocurrency.hf.space/api/ohlcv?symbol=BTCUSDT&interval=1h&limit=50"
# قیمت 5 ارز برتر
curl "https://really-amin-datasourceforcryptocurrency.hf.space/api/crypto/prices/top?limit=5"
# بررسی کلی بازار
curl "https://really-amin-datasourceforcryptocurrency.hf.space/api/crypto/market-overview"
# سیگنالهای معاملاتی
curl "https://really-amin-datasourceforcryptocurrency.hf.space/api/analysis/signals?symbol=BTCUSDT"
```
### 3. تست خودکار همه Endpointها
```bash
# در workspace خود
chmod +x TEST_ENDPOINTS.sh
./TEST_ENDPOINTS.sh
```
یا:
```bash
bash TEST_ENDPOINTS.sh
```
## نتیجه مورد انتظار
✅ همه endpointها باید HTTP 200 برگردانند
✅ دادههای JSON معتبر
✅ زمان پاسخ کمتر از 1 ثانیه
## اگر خطا دیدی
1. **چک کن که Space روشن باشه**:
```
https://really-amin-datasourceforcryptocurrency.hf.space/health
```
2. **مستندات تعاملی را ببین**:
```
https://really-amin-datasourceforcryptocurrency.hf.space/docs
```
3. **Logها را بررسی کن**:
```
curl https://really-amin-datasourceforcryptocurrency.hf.space/api/logs
```
## استفاده در کد
### Python
```python
import requests
# Simple
r = requests.get("https://really-amin-datasourceforcryptocurrency.hf.space/api/crypto/prices/top?limit=5")
print(r.json())
# With error handling
try:
r = requests.get(
"https://really-amin-datasourceforcryptocurrency.hf.space/api/ohlcv",
params={"symbol": "BTCUSDT", "interval": "1h", "limit": 100},
timeout=10
)
r.raise_for_status()
data = r.json()
print(f"Got {data['count']} candles")
except Exception as e:
print(f"Error: {e}")
```
### JavaScript/Node.js
```javascript
const axios = require('axios');
// Simple
axios.get('https://really-amin-datasourceforcryptocurrency.hf.space/api/crypto/prices/top?limit=5')
.then(res => console.log(res.data));
// With async/await
async function getOHLCV() {
try {
const response = await axios.get(
'https://really-amin-datasourceforcryptocurrency.hf.space/api/ohlcv',
{
params: {
symbol: 'BTCUSDT',
interval: '1h',
limit: 100
}
}
);
console.log(`Got ${response.data.count} candles`);
return response.data;
} catch (error) {
console.error('Error:', error.message);
}
}
```
## مثال کاربردی: نمایش قیمت BTC
```python
import requests
import time
def get_btc_price():
r = requests.get("https://really-amin-datasourceforcryptocurrency.hf.space/api/crypto/price/BTC")
data = r.json()
if 'price' in data:
price_data = data['price']
return price_data.get('price', 0)
return None
# نمایش قیمت هر 10 ثانیه
while True:
price = get_btc_price()
if price:
print(f"BTC Price: ${price:,.2f}")
time.sleep(10)
```
## چکلیست تست
- [ ] `/health` - سلامت سیستم
- [ ] `/info` - اطلاعات API
- [ ] `/api/ohlcv` - داده OHLCV
- [ ] `/api/crypto/prices/top` - قیمتهای برتر
- [ ] `/api/crypto/price/{symbol}` - قیمت تکی
- [ ] `/api/crypto/market-overview` - بررسی بازار
- [ ] `/api/market/prices` - قیمتهای چندتایی
- [ ] `/api/analysis/signals` - سیگنالهای معاملاتی
- [ ] `/api/analysis/smc` - تحلیل SMC
- [ ] `/api/scoring/snapshot` - امتیازدهی
- [ ] `/api/sentiment` - احساسات بازار
---
✅ **همه چیز آماده است!**
🎉 **API شما در HuggingFace Space فعال و کار میکند!**
📖 برای جزئیات بیشتر: [HUGGINGFACE_API_GUIDE.md](./HUGGINGFACE_API_GUIDE.md)
|