File size: 76,709 Bytes
8b7b267
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
<!DOCTYPE html>
<html lang="en" dir="ltr" data-theme="light">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="Permissions-Policy" content="accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()">
  <meta name="description" content="Help & Setup Guide for Crypto Monitor ULTIMATE on Hugging Face">
  <title>Help | Crypto Monitor ULTIMATE</title>

  <link rel="icon" type="image/svg+xml" href="/static/assets/icons/favicon.svg">

  <!-- Shared CSS -->
  <link rel="stylesheet" href="/static/shared/css/design-system.css">
  <link rel="stylesheet" href="/static/shared/css/global.css">
  <link rel="stylesheet" href="/static/shared/css/components.css">
  <link rel="stylesheet" href="/static/shared/css/layout.css">
  <link rel="stylesheet" href="/static/shared/css/utilities.css">
  <link rel="stylesheet" href="/static/shared/css/enhanced-resolution.css">

  <!-- Page-specific CSS -->
  <link rel="stylesheet" href="/static/pages/help/help.css">
    <!-- API Configuration - Smart Fallback System -->
    <script src="/static/js/api-config.js"></script>
    <script>
        // Initialize API client
        window.apiReady = new Promise((resolve) => {
            if (window.apiClient) {
                console.log('✅ API Client ready');
                resolve(window.apiClient);
            } else {
                console.error('❌ API Client not loaded');
            }
        });
    </script>

</head>
<body>
  <div class="app-container">
    <aside id="sidebar-container"></aside>

    <main class="main-content">
      <header id="header-container"></header>

      <div class="page-content">
        <div class="page-header">
          <div class="page-title">
            <h1>
              <span class="page-icon">
                <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>
              </span>
              Help & Setup (Hugging Face)
            </h1>
            <p class="page-subtitle">
              Quick guide for configuring API keys, endpoints, and troubleshooting on Hugging Face Spaces.
              <br>
              <strong>Space URL:</strong> 
              <a href="https://huggingface.co/spaces/Really-amin/Datasourceforcryptocurrency-2" 
                 target="_blank" 
                 style="color: var(--color-primary); text-decoration: underline;">
                https://huggingface.co/spaces/Really-amin/Datasourceforcryptocurrency-2
              </a>
              <br>
              <strong>API Base:</strong> <code>https://Really-amin-Datasourceforcryptocurrency-2.hf.space</code>
            </p>
          </div>
        </div>

        <section class="help-section" id="connect-service">
          <h2>1. Connecting to the Service</h2>
          <p>
            The app needs a running FastAPI backend (locally or on Hugging Face) with all required
            routes and environment variables configured.
          </p>
          <ul class="help-list">
            <li><strong>Start server locally</strong>:
              <code>python -m uvicorn production_server:app --host 0.0.0.0 --port 7860</code>
              or
              <code>python -m uvicorn hf_unified_server:app --host 0.0.0.0 --port 7860</code>.
            </li>
            <li><strong>HF Spaces</strong>: configure the Space command to start <code>hf_unified_server:app</code>
              and set API keys in <strong>Settings → Variables and secrets</strong>.</li>
            <li><strong>Required model routes</strong>:
              <code>/api/models/list</code>, <code>/api/models/status</code>,
              <code>/api/models/health</code>, <code>/api/models/reinit-all</code>.
            </li>
          </ul>
          <p class="help-note">
            Open <code>/docs</code> (Swagger UI) to confirm these routes exist and respond with HTTP 200.
          </p>
        </section>

        <section class="help-section" id="api-keys">
          <h2>2. Environment Variables & API Keys</h2>
          <p>
            System uses <strong>55 functional resources</strong> with <strong>11 active API keys</strong>.
            Many features use external services with automatic fallback to backup providers.
          </p>
          <div class="resources-summary">
            <h3>Available Resources:</h3>
            <ul class="help-list">
              <li><strong>Total Functional Resources:</strong> 55 (87.3% success rate)</li>
              <li><strong>Total API Keys:</strong> 11 active keys</li>
              <li><strong>Total Endpoints:</strong> 200+ endpoints</li>
              <li><strong>Market Data:</strong> 13 providers (3 with keys, 10 free)</li>
              <li><strong>News:</strong> 10 providers (2 with keys, 8 free)</li>
              <li><strong>Sentiment:</strong> 6 providers (all free)</li>
              <li><strong>Analytics:</strong> 13 providers (all free)</li>
              <li><strong>Block Explorers:</strong> 6 providers (5 with keys)</li>
            </ul>
          </div>
          <h3>API Keys Configuration:</h3>
          <ul class="help-list">
            <li><strong>HF Inference</strong>: <code>HF_TOKEN</code> or <code>HF_API_TOKEN</code></li>
            <li><strong>CoinMarketCap</strong>: <code>COINMARKETCAP_KEY_1</code>, <code>COINMARKETCAP_KEY_2</code></li>
            <li><strong>NewsAPI</strong>: <code>NEWSAPI_KEY</code></li>
            <li><strong>CryptoCompare</strong>: <code>CRYPTOCOMPARE_KEY</code></li>
            <li><strong>Alpha Vantage</strong>: <code>ALPHA_VANTAGE_KEY</code></li>
            <li><strong>Etherscan</strong>: <code>ETHERSCAN_KEY</code>, <code>ETHERSCAN_BACKUP_KEY</code></li>
            <li><strong>BscScan</strong>: <code>BSCSCAN_KEY</code></li>
            <li><strong>TronScan</strong>: <code>TRONSCAN_KEY</code></li>
          </ul>
          <p class="help-note">
            System automatically uses fallback providers if primary source fails. After changing variables on Hugging Face, restart the Space.
          </p>
        </section>

        <section class="help-section" id="dashboard-usage">
          <h2>3. Dashboard & Prices</h2>
          <p>
            The Dashboard pulls real-time data from endpoints like
            <code>/api/status</code>, <code>/api/resources</code>,
            <code>/api/trending</code>, <code>/api/coins/top</code>,
            and <code>/api/sentiment/global</code>.
          </p>
          <ul class="help-list">
            <li><strong>Top coins</strong>:
              <code>GET /api/coins/top?limit=50</code> returns prices, market cap and volume.</li>
            <li><strong>Global sentiment</strong>:
              <code>GET /api/sentiment/global</code> returns overall market mood and history.</li>
            <li><strong>No sentiment / categories data</strong>:
              check the Network tab for these endpoints and ensure they return non-empty JSON.</li>
          </ul>
        </section>

        <section class="help-section" id="models-usage">
          <h2>4. Models, AI Analyst & Sentiment Testing</h2>
          <p>
            The Models and AI Analyst pages use backend AI routes for model management,
            sentiment analysis and trading decisions.
          </p>
          <ul class="help-list">
            <li><strong>Re-initialize models</strong>:
              <code>POST /api/models/reinit-all</code> (triggered by the “Re-initialize All” button).</li>
            <li><strong>List & health</strong>:
              <code>GET /api/models/list</code>, <code>/api/models/status</code>,
              <code>/api/models/health</code> power the model cards and health monitor.</li>
            <li><strong>Sentiment analysis</strong>:
              <code>POST /api/sentiment/analyze</code> with a payload such as
              <code>{"text": "...", "mode": "crypto", "model_key": "CryptoBERT"}</code>.</li>
            <li><strong>AI Analyst decisions</strong>:
              <code>POST /api/ai/decision</code> returns structured buy / sell / hold style
              recommendations with confidence, signals, risks and price targets for the
              AI Analyst page.</li>
            <li><strong>WebSocket (OPTIONAL) vs HTTP (Recommended)</strong>:
              <ul>
                <li><strong>HTTP REST API (Recommended):</strong> All data is available via HTTP endpoints. 
                  This is the primary and most reliable method. Use endpoints like 
                  <code>GET /api/market</code>, <code>GET /api/models/status</code>, etc.</li>
                <li><strong>WebSocket (Optional Alternative):</strong> Provided as an optional alternative for 
                  users who prefer real-time streaming. Not required - HTTP works perfectly.</li>
                <li>If WebSocket is unavailable or blocked, the app automatically uses HTTP polling (30s intervals).</li>
                <li>All features work identically with HTTP - WebSocket is just a different transport method.</li>
              </ul>
            </li>
            <li><strong>WebSocket Connection Issues (Non-Critical)</strong>:
              If you see WebSocket errors (403, connection refused, etc.), this is expected and non-critical:
              <ul>
                <li>HuggingFace Spaces may limit WebSocket connections - this is normal</li>
                <li>Network/firewall may block WebSocket - use HTTP instead</li>
                <li>The application automatically falls back to HTTP polling - no action needed</li>
                <li><strong>All functionality works via HTTP endpoints - WebSocket is completely optional</strong></li>
              </ul>
            </li>
          </ul>
        </section>

        <section class="help-section" id="providers-usage">
          <h2>5. Providers & Resources</h2>
          <p>
            System has <strong>55 functional resources</strong> organized in backup providers.
            All resources are automatically loaded from <code>functional_backup_resources.py</code>.
          </p>
          <ul class="help-list">
            <li><strong>List providers</strong>:
              <code>GET /api/providers</code> returns configured data sources and their status.</li>
            <li><strong>Resources stats</strong>:
              <code>GET /api/resources/stats</code> returns total resources, API keys count, and success rate.</li>
            <li><strong>Automatic Fallback</strong>: System automatically switches to backup providers if primary fails.</li>
            <li><strong>Error Handling</strong>: All endpoints have timeout (10s) and fallback mechanisms.</li>
            <li>Use the UI Providers page to inspect availability, auth requirements, and categories.</li>
          </ul>
          <h3>Available Endpoints:</h3>
          <ul class="help-list">
            <li><code>GET /api/ohlcv?symbol=BTC&timeframe=1h&limit=500</code> - OHLCV data (Binance + cache)</li>
            <li><code>GET /api/klines?symbol=BTCUSDT&interval=1h&limit=500</code> - Alias to OHLCV</li>
            <li><code>GET /api/historical?symbol=BTC&days=30</code> - Historical data</li>
            <li><code>GET /api/signals</code> - Trading signals (empty array, client-side generation)</li>
            <li><code>GET /api/fear-greed</code> - Fear & Greed Index (alias to sentiment)</li>
            <li><code>GET /api/whale</code> - Whale transactions (from cache)</li>
            <li><code>GET /api/market?limit=100</code> - Market data (with fallback providers)</li>
            <li><code>GET /api/news?limit=20</code> - News articles (with fallback providers)</li>
          </ul>
        </section>

        <section class="help-section" id="troubleshooting">
          <h2>6. Troubleshooting</h2>
          <ol class="help-steps">
            <li><strong>WebSocket Connection Errors</strong>: If you see WebSocket connection failures:
              <ul>
                <li>This is <strong>expected and non-critical</strong> on Hugging Face Spaces</li>
                <li>The application automatically falls back to HTTP polling (30s intervals)</li>
                <li>All features work perfectly without WebSocket - no action needed</li>
                <li>See <code>docs/WEBSOCKET_TROUBLESHOOTING.md</code> for detailed information</li>
              </ul>
            </li>
            <li>If you see 404 or 500, confirm the server process (production or unified) is running
              and that the endpoint appears in <code>/docs</code>.</li>
            <li>If a page shows "No data", open DevTools → Network and inspect failing calls such as
              <code>/api/resources</code>, <code>/api/sentiment/global</code>, or model routes.</li>
            <li>If responses are empty, verify your API keys and upstream providers, then restart the server or Space.</li>
            <li><strong>Model Loading Failures</strong>: If models fail to load with "not a valid model identifier" errors:
              <ul>
                <li>Verify the model exists on Hugging Face Hub (check the model page URL)</li>
                <li>For private/gated models, ensure <code>HF_TOKEN</code> or <code>HF_API_TOKEN</code> is set</li>
                <li>Some models may require authentication even if marked as public</li>
                <li>The system will use fallback lexical analysis if models fail to load</li>
              </ul>
            </li>
            <li>Hard-refresh the browser (<code>Ctrl+Shift+R</code>) to bypass stale caches.</li>
            <li>Warnings about <code>ambient-light-sensor</code> or <code>battery</code> can be ignored unless features visibly break.</li>
          </ol>
        </section>

        <section class="help-section" id="websocket-config">
          <h2>7. WebSocket (Optional) - Alternative Data Retrieval Method</h2>
          <p class="help-note" style="margin-bottom: var(--space-4); padding: var(--space-3); background: var(--surface-elevated); border-left: 4px solid var(--color-primary);">
            <strong>⚠️ IMPORTANT:</strong> WebSocket is <strong>completely optional</strong>. All data can be retrieved via HTTP REST API endpoints.
            WebSocket is just an alternative method for users who prefer real-time streaming. If WebSocket is unavailable or you prefer HTTP,
            the application automatically uses HTTP polling (30-second intervals) and all features work perfectly.
          </p>
          <p>
            The system supports WebSocket connections as an <strong>optional alternative</strong> for real-time data streaming.
            WebSocket is <strong>not required</strong> - the application automatically falls back to HTTP polling if WebSocket is unavailable.
            This is just another option users can choose if they prefer real-time updates over polling.
          </p>
          
          <h3>Available WebSocket Endpoints (Optional - Use HTTP if Preferred):</h3>
          <p class="help-note">
            <strong>For HuggingFace Space:</strong> <code>wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/...</code>
            <br><strong>Note:</strong> WebSocket may be limited on HuggingFace Spaces. HTTP endpoints are recommended and work perfectly.
          </p>
          <ul class="help-list">
            <li><strong>Master Endpoint</strong>: <code>wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/master</code>
              <ul>
                <li>Access to all services (market data, news, sentiment, monitoring, HuggingFace)</li>
                <li>Supports subscription/unsubscription to specific services</li>
                <li>Send JSON messages: <code>{"action": "subscribe", "service": "market_data"}</code></li>
                <li><strong>Alternative HTTP:</strong> Use <code>GET /api/market</code>, <code>GET /api/news</code>, etc.</li>
              </ul>
            </li>
            <li><strong>Live Data</strong>: <code>wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/live</code>
              <ul>
                <li>Real-time price updates, market snapshots, and OHLCV data</li>
                <li>Automatic heartbeat/ping-pong for connection health</li>
                <li><strong>Alternative HTTP:</strong> Use <code>GET /api/ohlcv</code> with polling (30s intervals)</li>
              </ul>
            </li>
            <li><strong>AI Data</strong>: <code>wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/ai/data</code>
              <ul>
                <li>Real-time AI model status, sentiment analysis results</li>
                <li>HuggingFace model loading/unloading notifications</li>
                <li><strong>Alternative HTTP:</strong> Use <code>GET /api/models/status</code> with polling</li>
              </ul>
            </li>
            <li><strong>Data Collection</strong>: <code>wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/data</code>
              <ul>
                <li>Market data, news, sentiment, whale tracking streams</li>
                <li><strong>Alternative HTTP:</strong> Use <code>GET /api/market</code>, <code>GET /api/news</code>, etc.</li>
              </ul>
            </li>
            <li><strong>Monitoring</strong>: <code>wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/monitoring</code>
              <ul>
                <li>Health checks, pool manager status, scheduler status</li>
                <li><strong>Alternative HTTP:</strong> Use <code>GET /api/status</code>, <code>GET /api/resources/stats</code></li>
              </ul>
            </li>
            <li><strong>Integration</strong>: <code>wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/integration</code>
              <ul>
                <li>HuggingFace integration status, persistence updates</li>
                <li><strong>Alternative HTTP:</strong> Use <code>GET /api/resources/stats/combined</code></li>
              </ul>
            </li>
          </ul>
          
          <h3>WebSocket Usage Example (Optional):</h3>
          <pre class="code-block"><code>// OPTIONAL: WebSocket connection for real-time updates
// If WebSocket fails, use HTTP endpoints instead (recommended)

const ws = new WebSocket('wss://Really-amin-Datasourceforcryptocurrency-2.hf.space/ws/master');

ws.onopen = () => {
  console.log('WebSocket connected (optional)');
  // Subscribe to market data
  ws.send(JSON.stringify({
    action: 'subscribe',
    service: 'market_data'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Real-time update:', data);
};

ws.onerror = (error) => {
  console.warn('WebSocket error (non-critical):', error);
  // Fallback to HTTP polling
  setInterval(() => {
    fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/market')
      .then(r => r.json())
      .then(data => console.log('HTTP poll result:', data));
  }, 30000);
};

// ALTERNATIVE: Use HTTP polling (recommended, works everywhere)
setInterval(async () => {
  const response = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/market?limit=100');
  const data = await response.json();
  console.log('Market data:', data);
}, 30000); // Poll every 30 seconds
</code></pre>

          <h3>WebSocket Error Handling:</h3>
          <ul class="help-list">
            <li><strong>Automatic Reconnection</strong>: Client automatically reconnects with exponential backoff (1s → 16s max)</li>
            <li><strong>Connection State Management</strong>: Tracks connection status (connecting, connected, disconnected)</li>
            <li><strong>Error Logging</strong>: All WebSocket errors are logged with client ID and timestamp</li>
            <li><strong>Graceful Degradation</strong>: If WebSocket fails, app falls back to HTTP polling (30s intervals)</li>
            <li><strong>Timeout Handling</strong>: 30-second timeout for WebSocket operations</li>
            <li><strong>Message Validation</strong>: Invalid JSON messages are caught and logged without crashing</li>
            <li><strong>Connection Cleanup</strong>: Proper cleanup on disconnect prevents memory leaks</li>
          </ul>

          <h3>WebSocket Configuration:</h3>
          <ul class="help-list">
            <li><strong>Protocol Detection</strong>: Automatically uses <code>wss://</code> for HTTPS and <code>ws://</code> for HTTP</li>
            <li><strong>Heartbeat</strong>: Ping messages every 30 seconds to keep connection alive</li>
            <li><strong>Max Connections</strong>: No hard limit, but rate limiting applies per client</li>
            <li><strong>CORS</strong>: WebSocket connections respect CORS settings from main server</li>
            <li><strong>Authentication</strong>: Optional - can require <code>HF_TOKEN</code> for protected endpoints</li>
          </ul>

          <h3>Troubleshooting WebSocket Issues:</h3>
          <ol class="help-steps">
            <li><strong>Connection Refused (403/404)</strong>:
              <ul>
                <li>Check if WebSocket endpoint exists in <code>/docs</code></li>
                <li>Verify server is running and WebSocket routes are registered</li>
                <li>On Hugging Face Spaces, WebSocket may be limited - this is normal and non-critical</li>
              </ul>
            </li>
            <li><strong>Connection Timeout</strong>:
              <ul>
                <li>Check network connectivity</li>
                <li>Verify firewall/proxy allows WebSocket connections</li>
                <li>Application will automatically fall back to HTTP polling</li>
              </ul>
            </li>
            <li><strong>Message Parsing Errors</strong>:
              <ul>
                <li>Ensure messages are valid JSON</li>
                <li>Check message format matches expected schema</li>
                <li>Errors are logged but don't crash the connection</li>
              </ul>
            </li>
            <li><strong>High Memory Usage</strong>:
              <ul>
                <li>Connection manager automatically cleans up disconnected clients</li>
                <li>Event logs are limited to last 100 events per client</li>
                <li>Old connections are removed after timeout</li>
              </ul>
            </li>
          </ol>

          <p class="help-note" style="margin-top: var(--space-4);">
            <strong>📌 Summary:</strong> WebSocket is <strong>completely optional</strong> and just an alternative method.
            All features work perfectly via HTTP REST API endpoints. WebSocket is only useful if you prefer
            real-time streaming over HTTP polling. For HuggingFace Spaces, HTTP endpoints are recommended
            as they are more reliable and work in all environments.
          </p>
          
          <h3>Recommended Approach:</h3>
          <ul class="help-list">
            <li><strong>Primary Method (Recommended):</strong> Use HTTP REST API endpoints with polling (30s intervals)</li>
            <li><strong>Optional Alternative:</strong> Use WebSocket for real-time streaming (if available and preferred)</li>
            <li><strong>Automatic Fallback:</strong> Application automatically uses HTTP if WebSocket fails</li>
            <li><strong>No Configuration Needed:</strong> Both methods work out of the box - choose what you prefer</li>
          </ul>
        </section>

        <section class="help-section" id="huggingface-data">
          <h2>8. Retrieving Data from HuggingFace</h2>
          <p>
            This application runs on Hugging Face Spaces and provides multiple ways to retrieve data
            from the backend API. All endpoints are accessible via HTTP REST API.
          </p>

          <h3>Base URL Configuration:</h3>
          <ul class="help-list">
            <li><strong>Local Development</strong>: <code>http://localhost:7860</code></li>
            <li><strong>Hugging Face Space (Production)</strong>: 
              <code>https://huggingface.co/spaces/Really-amin/Datasourceforcryptocurrency-2</code>
              <br>API Base: <code>https://Really-amin-Datasourceforcryptocurrency-2.hf.space</code>
            </li>
            <li><strong>Custom Domain</strong>: Your configured domain URL</li>
          </ul>
          <p class="help-note">
            <strong>Note:</strong> The application automatically detects the environment and uses the correct base URL.
            When running on HuggingFace Spaces, it uses relative URLs for seamless operation.
          </p>

          <h3>How to Retrieve Data:</h3>
          
          <h4>1. Market Data & Prices:</h4>
          <pre class="code-block"><code>// JavaScript/TypeScript
// Using HuggingFace Space URL
const response = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/market?limit=100');
const data = await response.json();
// Returns: { success: true, items: [{symbol, name, price, change_24h, ...}] }

// Or use relative URL when on the same domain
const response = await fetch('/api/market?limit=100');
const data = await response.json();

// Python
import requests
response = requests.get('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/market?limit=100')
data = response.json()
</code></pre>

          <h4>2. OHLCV/Candlestick Data:</h4>
          <pre class="code-block"><code>// Get OHLCV data for charting
const response = await fetch(
  'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/ohlcv?symbol=BTC&timeframe=1h&limit=500'
);
const data = await response.json();
// Returns: { success: true, data: [{t, o, h, l, c, v}, ...] }

// Historical data
const historical = await fetch(
  'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/historical?symbol=BTC&days=30'
);
</code></pre>

          <h4>3. News Articles:</h4>
          <pre class="code-block"><code>const response = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/news?limit=20');
const data = await response.json();
// Returns: { success: true, articles: [{title, content, source, ...}] }
</code></pre>

          <h4>4. Sentiment Analysis:</h4>
          <pre class="code-block"><code>// Global sentiment
const global = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/sentiment/global');
const globalData = await global.json();

// Analyze text
const analysis = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/sentiment/analyze', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    text: 'Bitcoin is going to the moon!',
    mode: 'crypto'
  })
});
const sentimentData = await analysis.json();
// Returns: { ok: true, label: 'bullish', score: 0.85, ... }
</code></pre>

          <h4>5. HuggingFace Models Status:</h4>
          <pre class="code-block"><code>// Get all models
const models = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/models/list');
const modelsData = await models.json();

// Get model status
const status = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/models/status');
const statusData = await status.json();
// Returns: { models_loaded: 8, hf_mode: 'public', models: {...} }

// Get resources stats (includes HF models)
const resources = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/resources/stats/combined');
const resourcesData = await resources.json();
</code></pre>

          <h4>6. Resources & Providers:</h4>
          <pre class="code-block"><code>// Get resources statistics
const stats = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/resources/stats');
const statsData = await stats.json();
// Returns: { success: true, data: { total_functional: 55, total_api_keys: 11, ... } }

// Get all functional APIs
const apis = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/resources/apis');
const apisData = await apis.json();
</code></pre>

          <h4>7. AI Analysis & Trading Signals:</h4>
          <pre class="code-block"><code>// Get AI trading decision
const decision = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/ai/decision', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    timeframe: '1h'
  })
});
const decisionData = await decision.json();

// Get trading signals
const signals = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/signals');
const signalsData = await signals.json();
</code></pre>

          <h3>Authentication (Optional):</h3>
          <p>
            Most endpoints work without authentication. For protected endpoints or HuggingFace model access,
            include the token in headers:
          </p>
          <pre class="code-block"><code>const response = await fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/protected-endpoint', {
  headers: {
    'Authorization': `Bearer ${HF_TOKEN}`,
    'Content-Type': 'application/json'
  }
});
</code></pre>

          <h3>Error Handling:</h3>
          <ul class="help-list">
            <li><strong>404 Not Found</strong>: Endpoint doesn't exist - check URL and server routes</li>
            <li><strong>503 Service Unavailable</strong>: Backend service is down or rate limited</li>
            <li><strong>500 Internal Server Error</strong>: Server error - check logs</li>
            <li><strong>Timeout</strong>: Request took too long - increase timeout or check network</li>
            <li><strong>CORS Errors</strong>: Cross-origin requests blocked - ensure CORS is enabled</li>
          </ul>

          <h3>Best Practices:</h3>
          <ul class="help-list">
            <li>Always check <code>response.ok</code> or status code before parsing JSON</li>
            <li>Use try-catch blocks for error handling</li>
            <li>Implement retry logic with exponential backoff for failed requests</li>
            <li>Cache responses when appropriate (OHLCV data, model status)</li>
            <li>Use WebSocket for real-time updates, HTTP for one-time queries</li>
            <li>Respect rate limits (1200 requests/minute for Binance, etc.)</li>
          </ul>

          <h3>Example: Complete Data Retrieval Flow</h3>
          <pre class="code-block"><code>// Complete example: Fetch market data with error handling
// Using HuggingFace Space: https://Really-amin-Datasourceforcryptocurrency-2.hf.space
const API_BASE = 'https://Really-amin-Datasourceforcryptocurrency-2.hf.space';

async function fetchMarketData(symbol = 'BTC') {
  try {
    // 1. Get current price
    const priceRes = await fetch(
      `${API_BASE}/api/market?limit=1&symbol=${symbol}`
    );
    if (!priceRes.ok) throw new Error(`Price API failed: ${priceRes.status}`);
    const priceData = await priceRes.json();

    // 2. Get OHLCV for chart
    const ohlcvRes = await fetch(
      `${API_BASE}/api/ohlcv?symbol=${symbol}&timeframe=1h&limit=100`
    );
    if (!ohlcvRes.ok) throw new Error(`OHLCV API failed: ${ohlcvRes.status}`);
    const ohlcvData = await ohlcvRes.json();

    // 3. Get sentiment
    const sentimentRes = await fetch(`${API_BASE}/api/sentiment/global`);
    const sentimentData = await sentimentRes.json();

    // 4. Get AI analysis
    const aiRes = await fetch(`${API_BASE}/api/ai/decision`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ symbol, timeframe: '1h' })
    });
    const aiData = await aiRes.json();

    return {
      price: priceData.items[0],
      ohlcv: ohlcvData.data,
      sentiment: sentimentData,
      aiDecision: aiData
    };
  } catch (error) {
    console.error('Error fetching data:', error);
    // Fallback to cached data or show error message
    return null;
  }
}
</code></pre>

          <p class="help-note">
            <strong>Tip:</strong> Use the <code>/docs</code> endpoint (Swagger UI) to explore all available
            endpoints, test requests, and see response schemas interactively.
          </p>
        </section>

        <section class="help-section" id="unified-service-api">
          <h2>9. Unified Service API - Complete Endpoint Guide</h2>
          <p>
            The <strong>Unified Service API</strong> provides a single entry point for all cryptocurrency data needs.
            These endpoints are the primary way to access market data, prices, sentiment, whales, and blockchain information.
          </p>

          <h3>Base URL:</h3>
          <p class="help-note">
            <strong>HuggingFace Space:</strong> <code>https://Really-amin-Datasourceforcryptocurrency-2.hf.space</code>
            <br>
            <strong>Local:</strong> <code>http://localhost:7860</code>
          </p>

          <h3>Available Endpoints:</h3>

          <h4>1. Exchange Rates (جفت ارزها)</h4>
          <pre class="code-block"><code>// Get single exchange rate
GET /api/service/rate?pair=BTC/USDT

// Response:
{
  "data": {
    "pair": "BTC/USDT",
    "price": 50234.12,
    "quote": "USDT",
    "ts": "2025-01-15T12:00:00Z"
  },
  "meta": {
    "source": "hf",
    "generated_at": "2025-01-15T12:00:00Z",
    "cache_ttl_seconds": 10
  }
}

// Get multiple rates (batch)
GET /api/service/rate/batch?pairs=BTC/USDT,ETH/USDT,BNB/USDT

// Get pair metadata
GET /api/service/pair/BTC-USDT
// or
GET /api/service/pair/BTC/USDT</code></pre>

          <h4>2. Market Data</h4>
          <pre class="code-block"><code>// Market status
GET /api/service/market-status

// Top coins
GET /api/service/top?n=10  // or n=50

// Price history
GET /api/service/history?symbol=BTC&interval=60</code></pre>

          <h4>3. Sentiment Analysis</h4>
          <pre class="code-block"><code>// Get sentiment for a symbol
GET /api/service/sentiment?symbol=BTC

// Analyze text
POST /api/sentiment/analyze
Content-Type: application/json
{
  "text": "Bitcoin is going to the moon! 🚀"
}

// Response:
{
  "label": "positive",
  "score": 0.85,
  "confidence": 0.92
}</code></pre>

          <h4>4. Whale Tracking (نهنگ‌ها)</h4>
          <pre class="code-block"><code>// Get whale transactions
GET /api/service/whales?chain=ethereum&min_amount_usd=1000000&limit=50

// Response:
{
  "data": [
    {
      "from": "0x...",
      "to": "0x...",
      "amount": 100.5,
      "amount_usd": 1500000,
      "chain": "ethereum",
      "ts": "2025-01-15T12:00:00Z"
    }
  ],
  "meta": {
    "source": "whale_alert",
    "generated_at": "2025-01-15T12:00:00Z"
  }
}

// Alternative endpoint
GET /api/whales/transactions?limit=50&chain=ethereum
GET /api/whales/stats?hours=24</code></pre>

          <h4>5. On-Chain Data (بلاکچین)</h4>
          <pre class="code-block"><code>// Get on-chain data for an address
GET /api/service/onchain?address=0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb&chain=ethereum&limit=50

// Get gas prices
GET /api/blockchain/gas?chain=ethereum

// Response:
{
  "slow": 20,
  "standard": 25,
  "fast": 30,
  "unit": "gwei"
}</code></pre>

          <h4>6. Generic Query Endpoint</h4>
          <pre class="code-block"><code>// Universal query endpoint
POST /api/service/query
Content-Type: application/json
{
  "type": "rate",  // or: history, sentiment, econ, whales, onchain, pair
  "payload": {
    "pair": "BTC/USDT"
  },
  "options": {
    "prefer_hf": true,
    "persist": true
  }
}</code></pre>

          <h3>Complete Usage Examples:</h3>

          <h4>JavaScript Example:</h4>
          <pre class="code-block"><code>// Complete client example
const API_BASE = 'https://Really-amin-Datasourceforcryptocurrency-2.hf.space';

class CryptoAPIClient {
  constructor(baseUrl = API_BASE) {
    this.baseUrl = baseUrl;
  }

  // Get exchange rate
  async getRate(pair) {
    const response = await fetch(`${this.baseUrl}/api/service/rate?pair=${pair}`);
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return await response.json();
  }

  // Get multiple rates
  async getBatchRates(pairs) {
    const pairsStr = Array.isArray(pairs) ? pairs.join(',') : pairs;
    const response = await fetch(`${this.baseUrl}/api/service/rate/batch?pairs=${pairsStr}`);
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return await response.json();
  }

  // Get whale transactions
  async getWhales(chain = 'ethereum', minAmount = 1000000) {
    const response = await fetch(
      `${this.baseUrl}/api/service/whales?chain=${chain}&min_amount_usd=${minAmount}&limit=50`
    );
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return await response.json();
  }

  // Analyze sentiment
  async analyzeSentiment(text) {
    const response = await fetch(`${this.baseUrl}/api/sentiment/analyze`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ text })
    });
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return await response.json();
  }

  // Get on-chain data
  async getOnChainData(address, chain = 'ethereum') {
    const response = await fetch(
      `${this.baseUrl}/api/service/onchain?address=${address}&chain=${chain}&limit=50`
    );
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return await response.json();
  }
}

// Usage
const client = new CryptoAPIClient();

// Get BTC price
const btcRate = await client.getRate('BTC/USDT');
console.log(`BTC Price: $${btcRate.data.price}`);

// Get multiple prices
const rates = await client.getBatchRates(['BTC/USDT', 'ETH/USDT', 'BNB/USDT']);
rates.data.forEach(rate => {
  console.log(`${rate.pair}: $${rate.price}`);
});

// Get whale transactions
const whales = await client.getWhales('ethereum', 1000000);
console.log(`Found ${whales.data.length} whale transactions`);

// Analyze sentiment
const sentiment = await client.analyzeSentiment('Bitcoin is bullish!');
console.log(`Sentiment: ${sentiment.label} (${sentiment.score})`);</code></pre>

          <h4>Python Example:</h4>
          <pre class="code-block"><code>import requests
from typing import Optional, Dict, Any

class CryptoAPIClient:
    def __init__(self, base_url: str = "https://Really-amin-Datasourceforcryptocurrency-2.hf.space"):
        self.base_url = base_url
    
    def get_rate(self, pair: str) -> Dict[str, Any]:
        """Get exchange rate for a pair"""
        url = f"{self.base_url}/api/service/rate"
        params = {"pair": pair}
        response = requests.get(url, params=params, timeout=30)
        response.raise_for_status()
        return response.json()
    
    def get_batch_rates(self, pairs: list) -> Dict[str, Any]:
        """Get rates for multiple pairs"""
        url = f"{self.base_url}/api/service/rate/batch"
        params = {"pairs": ",".join(pairs)}
        response = requests.get(url, params=params, timeout=30)
        response.raise_for_status()
        return response.json()
    
    def get_whales(self, chain: str = "ethereum", min_amount: int = 1000000) -> Dict[str, Any]:
        """Get whale transactions"""
        url = f"{self.base_url}/api/service/whales"
        params = {
            "chain": chain,
            "min_amount_usd": min_amount,
            "limit": 50
        }
        response = requests.get(url, params=params, timeout=30)
        response.raise_for_status()
        return response.json()
    
    def analyze_sentiment(self, text: str) -> Dict[str, Any]:
        """Analyze sentiment"""
        url = f"{self.base_url}/api/sentiment/analyze"
        payload = {"text": text}
        response = requests.post(url, json=payload, timeout=30)
        response.raise_for_status()
        return response.json()
    
    def get_onchain_data(self, address: str, chain: str = "ethereum") -> Dict[str, Any]:
        """Get on-chain data"""
        url = f"{self.baseUrl}/api/service/onchain"
        params = {
            "address": address,
            "chain": chain,
            "limit": 50
        }
        response = requests.get(url, params=params, timeout=30)
        response.raise_for_status()
        return response.json()

# Usage
client = CryptoAPIClient()

# Get BTC price
btc_rate = client.get_rate("BTC/USDT")
print(f"BTC Price: ${btc_rate['data']['price']}")

# Get multiple prices
rates = client.get_batch_rates(["BTC/USDT", "ETH/USDT", "BNB/USDT"])
for rate in rates['data']:
    print(f"{rate['pair']}: ${rate['price']}")

# Get whales
whales = client.get_whales("ethereum", 1000000)
print(f"Found {len(whales['data'])} whale transactions")

# Analyze sentiment
sentiment = client.analyze_sentiment("Bitcoin is bullish!")
print(f"Sentiment: {sentiment['label']} ({sentiment['score']})")</code></pre>

          <h3>cURL Examples:</h3>
          <pre class="code-block"><code># Get BTC/USDT rate
curl "https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/service/rate?pair=BTC/USDT"

# Get multiple rates
curl "https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/service/rate/batch?pairs=BTC/USDT,ETH/USDT"

# Get whale transactions
curl "https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/service/whales?chain=ethereum&min_amount_usd=1000000"

# Analyze sentiment
curl -X POST "https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/sentiment/analyze" \
  -H "Content-Type: application/json" \
  -d '{"text": "Bitcoin is rising!"}'

# Get gas prices
curl "https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/blockchain/gas?chain=ethereum"</code></pre>
        </section>

        <section class="help-section" id="common-errors">
          <h2>10. Common Errors & Solutions</h2>
          <p>
            This section covers the most common errors users encounter and how to fix them.
          </p>

          <h3>Error 1: 404 Not Found - /api/service/* endpoints</h3>
          <div class="help-note" style="background: #fee; border-left: 4px solid #f44; padding: 1rem; margin: 1rem 0;">
            <strong>Problem:</strong> Getting 404 errors when calling <code>/api/service/rate</code>, <code>/api/service/whales</code>, etc.
            <br><strong>Cause:</strong> Unified Service API router not loaded in server
            <br><strong>Solution:</strong> Ensure <code>app_unified.py</code> or <code>hf_unified_server.py</code> includes the router
          </div>
          <pre class="code-block"><code>// Check if router is loaded
GET /api/routers

// Should return:
{
  "routers": {
    "unified_service_api": "loaded"  // ✅ Should be "loaded"
  }
}

// If "not_available", the router needs to be added to server file</code></pre>
          <p><strong>Fix:</strong> Make sure your server file includes:</p>
          <pre class="code-block"><code>from backend.routers.unified_service_api import router as unified_service_router
app.include_router(unified_service_router)</code></pre>

          <h3>Error 2: 503 Service Unavailable - OHLC Data</h3>
          <div class="help-note" style="background: #fee; border-left: 4px solid #f44; padding: 1rem; margin: 1rem 0;">
            <strong>Problem:</strong> <code>GET /api/market/ohlc</code> returns 503: "All OHLC sources failed"
            <br><strong>Cause:</strong> All OHLC providers (Binance, CoinGecko) are failing or rate limited
            <br><strong>Solution:</strong> Check API keys, wait for rate limit reset, or use alternative endpoints
          </div>
          <pre class="code-block"><code>// Alternative: Use market tickers instead
GET /api/market/tickers?limit=100

// Or use direct API
GET /api/v1/binance/klines?symbol=BTC&timeframe=1h&limit=100</code></pre>

          <h3>Error 3: 500 Internal Server Error - HuggingFace Models</h3>
          <div class="help-note" style="background: #fee; border-left: 4px solid #f44; padding: 1rem; margin: 1rem 0;">
            <strong>Problem:</strong> <code>POST /api/sentiment/analyze</code> or <code>POST /api/news/summarize</code> returns 500
            <br><strong>Error Message:</strong> "404 Not Found for url 'https://router.huggingface.co/models/...'"
            <br><strong>Cause:</strong> Model not found on HuggingFace Hub or requires authentication
            <br><strong>Solution:</strong> System uses fallback analysis, but you can configure alternative models
          </div>
          <pre class="code-block"><code>// Check model status
GET /api/models/status

// If models fail, system uses fallback lexical analysis
// You can also use direct sentiment endpoint
POST /api/v1/hf/sentiment
{
  "text": "Your text here",
  "model": "ProsusAI/finbert"  // Alternative model
}</code></pre>

          <h3>Error 4: Timeout Errors</h3>
          <div class="help-note" style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 1rem; margin: 1rem 0;">
            <strong>Problem:</strong> Requests timeout after 10-30 seconds
            <br><strong>Cause:</strong> HuggingFace Space may be slow or sleeping
            <br><strong>Solution:</strong> Increase timeout, add retry logic, or wake up the Space
          </div>
          <pre class="code-block"><code>// JavaScript - Increase timeout
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 60000); // 60 seconds

try {
  const response = await fetch(url, {
    signal: controller.signal,
    // ... other options
  });
  clearTimeout(timeoutId);
  // ... handle response
} catch (error) {
  clearTimeout(timeoutId);
  if (error.name === 'AbortError') {
    console.error('Request timeout');
  }
}

// Python - Increase timeout
import requests
response = requests.get(url, timeout=60)  # 60 seconds</code></pre>

          <h3>Error 5: CORS Errors</h3>
          <div class="help-note" style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 1rem; margin: 1rem 0;">
            <strong>Problem:</strong> "CORS policy blocked" errors in browser console
            <br><strong>Cause:</strong> CORS not configured properly
            <br><strong>Solution:</strong> Server should have CORS enabled (already configured), but check if you're using correct URL
          </div>
          <pre class="code-block"><code>// Make sure you're using the correct base URL
// ✅ Correct:
const API_BASE = 'https://Really-amin-Datasourceforcryptocurrency-2.hf.space';

// ❌ Wrong (will cause CORS):
const API_BASE = 'http://localhost:7860';  // If running from different origin</code></pre>

          <h3>Error 6: Empty Responses</h3>
          <div class="help-note" style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 1rem; margin: 1rem 0;">
            <strong>Problem:</strong> Endpoint returns 200 but data is empty
            <br><strong>Cause:</strong> No data available, provider failed, or cache issue
            <br><strong>Solution:</strong> Check response structure, try different endpoint, or wait for data refresh
          </div>
          <pre class="code-block"><code>// Check response structure
const response = await fetch('/api/news/latest?symbol=BTC&limit=10');
const data = await response.json();

// Response might be:
{
  "success": true,
  "news": [],  // Empty array - no news available
  "meta": {
    "source": "newsapi",
    "total": 0
  }
}

// Try alternative endpoint
const altResponse = await fetch('/api/news?limit=10');</code></pre>

          <h3>Error 7: Rate Limit Exceeded (429)</h3>
          <div class="help-note" style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 1rem; margin: 1rem 0;">
            <strong>Problem:</strong> Getting 429 "Rate limit exceeded" errors
            <br><strong>Cause:</strong> Too many requests in short time
            <br><strong>Solution:</strong> Implement rate limiting, add delays, or use caching
          </div>
          <pre class="code-block"><code>// Check rate limit headers
const response = await fetch('/api/service/rate?pair=BTC/USDT');
console.log('Limit:', response.headers.get('X-RateLimit-Limit'));
console.log('Remaining:', response.headers.get('X-RateLimit-Remaining'));
console.log('Reset:', response.headers.get('X-RateLimit-Reset'));

// Implement client-side rate limiting
let lastRequest = 0;
const MIN_DELAY = 100; // 100ms between requests

async function rateLimitedFetch(url, options) {
  const now = Date.now();
  const timeSinceLastRequest = now - lastRequest;
  
  if (timeSinceLastRequest < MIN_DELAY) {
    await new Promise(resolve => setTimeout(resolve, MIN_DELAY - timeSinceLastRequest));
  }
  
  lastRequest = Date.now();
  return fetch(url, options);
}</code></pre>

          <h3>Quick Diagnostic Checklist:</h3>
          <ol class="help-steps">
            <li><strong>Check Health:</strong>
              <code>GET /api/health</code> - Should return 200 with "healthy" status
            </li>
            <li><strong>Check Routers:</strong>
              <code>GET /api/routers</code> - Verify <code>unified_service_api</code> is "loaded"
            </li>
            <li><strong>Check Status:</strong>
              <code>GET /api/status</code> - See overall system status
            </li>
            <li><strong>Check Docs:</strong>
              Visit <code>/docs</code> - See all available endpoints
            </li>
            <li><strong>Test Simple Endpoint:</strong>
              <code>GET /api/market/tickers?limit=10</code> - Should work if system is running
            </li>
            <li><strong>Check Network Tab:</strong>
              Open browser DevTools → Network tab to see actual requests and responses
            </li>
            <li><strong>Check Server Logs:</strong>
              If on HuggingFace Space, check Space logs for errors
            </li>
          </ol>
        </section>

        <section class="help-section" id="technical-analysis">
          <h2>11. Technical Analysis - Advanced Trading Tools</h2>
          <p>
            صفحه Technical Analysis ابزارهای پیشرفته تحلیل تکنیکال را با 5 حالت مختلف تحلیل ارائه می‌دهد.
            این صفحه شامل تشخیص الگوهای هارمونیک، تحلیل Elliott Wave، اندیکاتورهای پیشرفته و توصیه‌های معاملاتی است.
          </p>

          <h3>5 حالت تحلیل (Analysis Modes):</h3>
          
          <h4>1. Quick Technical Analysis (TA_QUICK)</h4>
          <p>تحلیل سریع روند کوتاه‌مدت و مومنتوم:</p>
          <pre class="code-block"><code>// JavaScript
const response = await fetch('/api/technical/ta-quick', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    timeframe: '4h',
    ohlcv: [...] // Array of OHLCV candles
  })
});
const data = await response.json();
// Returns: { success: true, trend: 'Bullish', rsi: 65.5, macd: {...}, support_resistance: {...}, entry_range: {...}, exit_range: {...} }

// Python
import requests
response = requests.post(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/technical/ta-quick',
    json={
        'symbol': 'BTC',
        'timeframe': '4h',
        'ohlcv': [...]  # List of OHLCV dictionaries
    }
)
data = response.json()</code></pre>

          <h4>2. Fundamental Evaluation (FA_EVAL)</h4>
          <p>ارزیابی بنیادی پروژه و پتانسیل بلندمدت:</p>
          <pre class="code-block"><code>// JavaScript
const response = await fetch('/api/technical/fa-eval', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    whitepaper_summary: 'Bitcoin is a decentralized digital currency...',
    team_credibility_score: 9,
    token_utility_description: 'Store of value and digital gold...',
    total_supply_mechanism: 'Fixed supply of 21 million coins'
  })
});
const data = await response.json();
// Returns: { success: true, fundamental_score: 8.5, justification: '...', risks: [...], growth_potential: 'High' }

// Python
import requests
response = requests.post(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/technical/fa-eval',
    json={
        'symbol': 'BTC',
        'whitepaper_summary': 'Bitcoin is a decentralized digital currency...',
        'team_credibility_score': 9,
        'token_utility_description': 'Store of value and digital gold...',
        'total_supply_mechanism': 'Fixed supply of 21 million coins'
    }
)
data = response.json()</code></pre>

          <h4>3. On-Chain Network Health (ON_CHAIN_HEALTH)</h4>
          <p>تحلیل سلامت شبکه و رفتار نهنگ‌ها:</p>
          <pre class="code-block"><code>// JavaScript
const response = await fetch('/api/technical/onchain-health', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    active_addresses_7day_avg: 850000,
    exchange_net_flow_24h: -150000000,  // Negative = outflow (bullish)
    mrvv_z_score: -0.5
  })
});
const data = await response.json();
// Returns: { success: true, network_phase: 'Accumulation', cycle_position: 'Bottom Zone', health_status: 'Healthy' }

// Python
import requests
response = requests.post(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/technical/onchain-health',
    json={
        'symbol': 'BTC',
        'active_addresses_7day_avg': 850000,
        'exchange_net_flow_24h': -150000000,
        'mrvv_z_score': -0.5
    }
)
data = response.json()</code></pre>

          <h4>4. Risk & Volatility Assessment (RISK_ASSESSMENT)</h4>
          <p>ارزیابی ریسک و نوسانات:</p>
          <pre class="code-block"><code>// JavaScript
const response = await fetch('/api/technical/risk-assessment', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    historical_daily_prices: [...],  // Last 90 days
    max_drawdown_percentage: 25.5
  })
});
const data = await response.json();
// Returns: { success: true, risk_level: 'Medium', volatility: 0.045, max_drawdown: 25.5, justification: '...' }

// Python
import requests
response = requests.post(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/technical/risk-assessment',
    json={
        'symbol': 'BTC',
        'historical_daily_prices': [...],  # List of prices for last 90 days
        'max_drawdown_percentage': 25.5
    }
)
data = response.json()</code></pre>

          <h4>5. Comprehensive Analysis (COMPREHENSIVE)</h4>
          <p>تحلیل جامع ترکیبی از همه حالت‌ها:</p>
          <pre class="code-block"><code>// JavaScript
const response = await fetch('/api/technical/comprehensive', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    timeframe: '4h',
    ohlcv: [...],
    fundamental_data: {...},
    onchain_data: {...}
  })
});
const data = await response.json();
// Returns: { success: true, recommendation: 'BUY', confidence: 0.85, executive_summary: '...', ta_score: 8, fa_score: 7.5, onchain_score: 9 }

// Python
import requests
response = requests.post(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/technical/comprehensive',
    json={
        'symbol': 'BTC',
        'timeframe': '4h',
        'ohlcv': [...],
        'fundamental_data': {...},
        'onchain_data': {...}
    }
)
data = response.json()</code></pre>

          <h3>API Endpoint اصلی - تحلیل تکنیکال جامع:</h3>
          <pre class="code-block"><code>// JavaScript - تحلیل تکنیکال کامل با همه اندیکاتورها و الگوها
const response = await fetch('/api/technical/analyze', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    timeframe: '4h',
    ohlcv: [
      { t: 1234567890000, o: 50000, h: 51000, l: 49500, c: 50500, v: 1000000 },
      // ... more candles
    ],
    indicators: {
      rsi: true,
      macd: true,
      volume: true,
      ichimoku: false,
      elliott: true
    },
    patterns: {
      gartley: true,
      butterfly: true,
      bat: true,
      crab: true,
      candlestick: true
    }
  })
});
const analysis = await response.json();
// Returns: {
//   success: true,
//   support_resistance: { support: 49500, resistance: 51000, levels: [...] },
//   harmonic_patterns: [{ type: 'Gartley', pattern: 'Bullish', confidence: 0.75 }],
//   elliott_wave: { wave_count: 5, current_wave: 3, direction: 'up' },
//   candlestick_patterns: [{ type: 'Hammer', signal: 'Bullish' }],
//   indicators: { rsi: 65.5, macd: {...}, sma20: 50200, sma50: 49800 },
//   signals: [{ type: 'BUY', source: 'RSI Oversold', strength: 'Strong' }],
//   trade_recommendations: { entry: 50000, tp: 52000, sl: 49000 }
// }

// Python
import requests
response = requests.post(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/technical/analyze',
    json={
        'symbol': 'BTC',
        'timeframe': '4h',
        'ohlcv': [
            {'t': 1234567890000, 'o': 50000, 'h': 51000, 'l': 49500, 'c': 50500, 'v': 1000000},
            # ... more candles
        ],
        'indicators': {
            'rsi': True,
            'macd': True,
            'volume': True,
            'ichimoku': False,
            'elliott': True
        },
        'patterns': {
            'gartley': True,
            'butterfly': True,
            'bat': True,
            'crab': True,
            'candlestick': True
        }
    }
)
analysis = response.json()</code></pre>

          <h3>دریافت داده‌های OHLCV برای تحلیل:</h3>
          <pre class="code-block"><code>// JavaScript - دریافت داده‌های OHLCV
const ohlcvResponse = await fetch('/api/ohlcv?symbol=BTC&timeframe=4h&limit=200');
const ohlcvData = await ohlcvResponse.json();
// Returns: { success: true, data: [{ t, o, h, l, c, v }, ...] }

// استفاده از داده‌ها در تحلیل
const analysisResponse = await fetch('/api/technical/ta-quick', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    symbol: 'BTC',
    timeframe: '4h',
    ohlcv: ohlcvData.data  // استفاده از داده‌های دریافت شده
  })
});

// Python
import requests

# دریافت داده‌های OHLCV
ohlcv_response = requests.get(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/ohlcv',
    params={'symbol': 'BTC', 'timeframe': '4h', 'limit': 200}
)
ohlcv_data = ohlcv_response.json()

# استفاده در تحلیل
analysis_response = requests.post(
    'https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/technical/ta-quick',
    json={
        'symbol': 'BTC',
        'timeframe': '4h',
        'ohlcv': ohlcv_data['data']
    }
)
analysis = analysis_response.json()</code></pre>

          <h3>مثال کامل: تحلیل جامع یک ارز:</h3>
          <pre class="code-block"><code>// JavaScript - مثال کامل
async function analyzeCrypto(symbol = 'BTC') {
  const API_BASE = window.location.origin; // یا URL کامل HuggingFace Space
  
  try {
    // 1. دریافت داده‌های OHLCV
    const ohlcvRes = await fetch(`${API_BASE}/api/ohlcv?symbol=${symbol}&timeframe=4h&limit=200`);
    if (!ohlcvRes.ok) throw new Error('Failed to fetch OHLCV');
    const ohlcvData = await ohlcvRes.json();
    
    // 2. تحلیل تکنیکال سریع
    const taQuickRes = await fetch(`${API_BASE}/api/technical/ta-quick`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        symbol: symbol,
        timeframe: '4h',
        ohlcv: ohlcvData.data
      })
    });
    const taQuick = await taQuickRes.json();
    
    // 3. تحلیل بنیادی (اگر داده‌ها موجود باشد)
    const faRes = await fetch(`${API_BASE}/api/technical/fa-eval`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        symbol: symbol,
        whitepaper_summary: '...',  // داده‌های پروژه
        team_credibility_score: 8,
        token_utility_description: '...',
        total_supply_mechanism: '...'
      })
    });
    const faData = await faRes.json();
    
    // 4. تحلیل جامع
    const comprehensiveRes = await fetch(`${API_BASE}/api/technical/comprehensive`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        symbol: symbol,
        timeframe: '4h',
        ohlcv: ohlcvData.data,
        fundamental_data: faData,
        onchain_data: {}  // اگر داده‌های on-chain موجود باشد
      })
    });
    const comprehensive = await comprehensiveRes.json();
    
    return {
      taQuick: taQuick,
      fundamental: faData,
      comprehensive: comprehensive
    };
  } catch (error) {
    console.error('Analysis error:', error);
    return null;
  }
}

// استفاده
analyzeCrypto('BTC').then(results => {
  console.log('TA Quick:', results.taQuick);
  console.log('Fundamental:', results.fundamental);
  console.log('Comprehensive:', results.comprehensive);
  console.log('Recommendation:', results.comprehensive.recommendation);
});

// Python
import requests

def analyze_crypto(symbol='BTC'):
    API_BASE = 'https://Really-amin-Datasourceforcryptocurrency-2.hf.space'
    
    try:
        # 1. دریافت داده‌های OHLCV
        ohlcv_res = requests.get(
            f'{API_BASE}/api/ohlcv',
            params={'symbol': symbol, 'timeframe': '4h', 'limit': 200}
        )
        ohlcv_data = ohlcv_res.json()
        
        # 2. تحلیل تکنیکال سریع
        ta_quick_res = requests.post(
            f'{API_BASE}/api/technical/ta-quick',
            json={
                'symbol': symbol,
                'timeframe': '4h',
                'ohlcv': ohlcv_data['data']
            }
        )
        ta_quick = ta_quick_res.json()
        
        # 3. تحلیل جامع
        comprehensive_res = requests.post(
            f'{API_BASE}/api/technical/comprehensive',
            json={
                'symbol': symbol,
                'timeframe': '4h',
                'ohlcv': ohlcv_data['data']
            }
        )
        comprehensive = comprehensive_res.json()
        
        return {
            'ta_quick': ta_quick,
            'comprehensive': comprehensive
        }
    except Exception as e:
        print(f'Analysis error: {e}')
        return None

# استفاده
results = analyze_crypto('BTC')
print(f"Recommendation: {results['comprehensive']['recommendation']}")</code></pre>

          <h3>اندیکاتورها و الگوهای پشتیبانی شده:</h3>
          <ul class="help-list">
            <li><strong>اندیکاتورها:</strong> RSI (14), MACD, Volume, Ichimoku Cloud, Elliott Wave, SMA 20/50</li>
            <li><strong>الگوهای هارمونیک:</strong> Gartley, Butterfly, Bat, Crab</li>
            <li><strong>الگوهای کندل استیک:</strong> Doji, Hammer, Engulfing (Bullish/Bearish)</li>
            <li><strong>سطوح Support/Resistance:</strong> محاسبه خودکار بر اساس Pivot Points</li>
            <li><strong>توصیه‌های معاملاتی:</strong> Entry, Take Profit (TP), Stop Loss (SL)</li>
          </ul>

          <h3>نکات مهم:</h3>
          <ul class="help-list">
            <li>برای تحلیل دقیق‌تر، حداقل 100-200 کندل داده نیاز است</li>
            <li>Timeframe پیشنهادی برای TA_QUICK: 4h</li>
            <li>سیستم به صورت خودکار از محاسبات محلی استفاده می‌کند اگر API در دسترس نباشد</li>
            <li>همه endpointها از retry logic با exponential backoff استفاده می‌کنند</li>
            <li>برای تحلیل جامع، داده‌های TA، FA و On-Chain را ترکیب کنید</li>
          </ul>

          <h3>Error Handling:</h3>
          <pre class="code-block"><code>// JavaScript - مدیریت خطا با retry
async function fetchWithRetry(url, options, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      const response = await fetch(url, options);
      if (response.ok) return await response.json();
      
      if (i < maxRetries - 1) {
        await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
        continue;
      }
      
      throw new Error(`HTTP ${response.status}`);
    } catch (error) {
      if (i < maxRetries - 1) {
        await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
        continue;
      }
      throw error;
    }
  }
}

// استفاده
try {
  const analysis = await fetchWithRetry('/api/technical/ta-quick', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ symbol: 'BTC', timeframe: '4h', ohlcv: [...] })
  });
  console.log('Analysis:', analysis);
} catch (error) {
  console.error('Analysis failed after retries:', error);
  // استفاده از fallback calculations
}</code></pre>

          <p class="help-note">
            <strong>💡 نکته:</strong> برای مشاهده تمام endpointها و تست آنها، به <code>/docs</code> (Swagger UI) مراجعه کنید.
            همچنین می‌توانید از صفحه Technical Analysis در UI استفاده کنید که همه این تحلیل‌ها را به صورت بصری نمایش می‌دهد.
          </p>
        </section>

        <section class="help-section" id="quick-start">
          <h2>12. Quick Start Guide for Average Users</h2>
          <p>
            This section provides simple, step-by-step examples for average users who want to quickly start using the API.
          </p>

          <h3>Step 1: Get a Single Price</h3>
          <pre class="code-block"><code>// Simplest example - Get BTC price
fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/service/rate?pair=BTC/USDT')
  .then(r => r.json())
  .then(data => {
    console.log(`BTC Price: $${data.data.price}`);
  })
  .catch(err => console.error('Error:', err));</code></pre>

          <h3>Step 2: Get Multiple Prices</h3>
          <pre class="code-block"><code>// Get prices for multiple coins
fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/service/rate/batch?pairs=BTC/USDT,ETH/USDT,BNB/USDT')
  .then(r => r.json())
  .then(data => {
    data.data.forEach(rate => {
      console.log(`${rate.pair}: $${rate.price}`);
    });
  });</code></pre>

          <h3>Step 3: Get Latest News</h3>
          <pre class="code-block"><code>// Get latest crypto news
fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/news/latest?symbol=BTC&limit=5')
  .then(r => r.json())
  .then(data => {
    data.news.forEach(article => {
      console.log(`- ${article.title}`);
      console.log(`  Source: ${article.source}`);
      console.log(`  URL: ${article.url}\n`);
    });
  });</code></pre>

          <h3>Step 4: Get Whale Transactions</h3>
          <pre class="code-block"><code>// Get large transactions (whales)
fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/service/whales?chain=ethereum&min_amount_usd=1000000&limit=20')
  .then(r => r.json())
  .then(data => {
    console.log(`Found ${data.data.length} whale transactions:`);
    data.data.forEach(tx => {
      console.log(`From: ${tx.from}`);
      console.log(`To: ${tx.to}`);
      console.log(`Amount: $${tx.amount_usd.toLocaleString()}\n`);
    });
  });</code></pre>

          <h3>Step 5: Analyze Sentiment</h3>
          <pre class="code-block"><code>// Analyze text sentiment
fetch('https://Really-amin-Datasourceforcryptocurrency-2.hf.space/api/sentiment/analyze', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    text: 'Bitcoin is going to the moon! 🚀'
  })
})
  .then(r => r.json())
  .then(data => {
    console.log(`Sentiment: ${data.label}`);
    console.log(`Score: ${data.score}`);
    console.log(`Confidence: ${data.confidence || 'N/A'}`);
  });</code></pre>

          <h3>Complete Working Example:</h3>
          <pre class="code-block"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;Crypto API Example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;h1&gt;Crypto Data&lt;/h1&gt;
  &lt;div id="prices"&gt;Loading...&lt;/div&gt;
  &lt;div id="news"&gt;Loading...&lt;/div&gt;

  &lt;script&gt;
    const API_BASE = 'https://Really-amin-Datasourceforcryptocurrency-2.hf.space';

    // Get prices
    async function loadPrices() {
      try {
        const response = await fetch(`${API_BASE}/api/service/rate/batch?pairs=BTC/USDT,ETH/USDT,BNB/USDT`);
        const data = await response.json();
        
        const pricesHtml = data.data.map(rate => 
          `&lt;p&gt;&lt;strong&gt;${rate.pair}:&lt;/strong&gt; $${rate.price.toFixed(2)}&lt;/p&gt;`
        ).join('');
        
        document.getElementById('prices').innerHTML = pricesHtml;
      } catch (error) {
        document.getElementById('prices').innerHTML = `Error: ${error.message}`;
      }
    }

    // Get news
    async function loadNews() {
      try {
        const response = await fetch(`${API_BASE}/api/news/latest?symbol=BTC&limit=5`);
        const data = await response.json();
        
        const newsHtml = data.news.map(article => 
          `&lt;div&gt;
            &lt;h3&gt;${article.title}&lt;/h3&gt;
            &lt;p&gt;${article.summary}&lt;/p&gt;
            &lt;a href="${article.url}" target="_blank"&gt;Read more&lt;/a&gt;
          &lt;/div&gt;`
        ).join('');
        
        document.getElementById('news').innerHTML = newsHtml;
      } catch (error) {
        document.getElementById('news').innerHTML = `Error: ${error.message}`;
      }
    }

    // Load data on page load
    loadPrices();
    loadNews();

    // Refresh every 30 seconds
    setInterval(() => {
      loadPrices();
      loadNews();
    }, 30000);
  &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>

          <h3>Python Quick Start:</h3>
          <pre class="code-block"><code>import requests

API_BASE = "https://Really-amin-Datasourceforcryptocurrency-2.hf.space"

# Get BTC price
response = requests.get(f"{API_BASE}/api/service/rate?pair=BTC/USDT")
data = response.json()
print(f"BTC Price: ${data['data']['price']}")

# Get multiple prices
response = requests.get(f"{API_BASE}/api/service/rate/batch?pairs=BTC/USDT,ETH/USDT")
data = response.json()
for rate in data['data']:
    print(f"{rate['pair']}: ${rate['price']}")

# Get news
response = requests.get(f"{API_BASE}/api/news/latest?symbol=BTC&limit=5")
data = response.json()
for article in data['news']:
    print(f"- {article['title']}")

# Analyze sentiment
response = requests.post(
    f"{API_BASE}/api/sentiment/analyze",
    json={"text": "Bitcoin is bullish!"}
)
data = response.json()
print(f"Sentiment: {data['label']} ({data['score']})")</code></pre>
        </section>

        <section class="help-section" id="meta">
          <h2>13. Summary</h2>
          <p>
            This system provides real-time market data, global sentiment, model management and
            analysis tools. Ensure the correct backend server is running with valid environment
            variables, then use the Dashboard, Models and Providers pages to explore data and
            run analyses from the UI.
          </p>
          
          <h3>Available API Endpoints:</h3>
          <ul class="help-list">
            <li><strong>Unified Service API:</strong> <code>/api/service/*</code> - Primary endpoints for all data needs
              <ul>
                <li><code>/api/service/rate</code> - Exchange rates</li>
                <li><code>/api/service/whales</code> - Whale transactions</li>
                <li><code>/api/service/sentiment</code> - Sentiment analysis</li>
                <li><code>/api/service/onchain</code> - Blockchain data</li>
                <li><code>/api/service/market-status</code> - Market overview</li>
              </ul>
            </li>
            <li><strong>Market Data:</strong> <code>/api/market/*</code> - Prices, tickers, OHLCV</li>
            <li><strong>News:</strong> <code>/api/news/*</code> - Crypto news articles</li>
            <li><strong>Sentiment:</strong> <code>/api/sentiment/*</code> - Sentiment analysis</li>
            <li><strong>Blockchain:</strong> <code>/api/blockchain/*</code> - Gas prices, transactions</li>
            <li><strong>AI Models:</strong> <code>/api/models/*</code> - Model management</li>
            <li><strong>Technical Analysis:</strong> <code>/api/technical/*</code> - Advanced trading analysis</li>
          </ul>

          <p>
            <strong>Key Points:</strong>
          </p>
          <ul class="help-list">
            <li>All data is accessible via HTTP REST API endpoints</li>
            <li><strong>Unified Service API</strong> (<code>/api/service/*</code>) is the primary way to access data</li>
            <li>WebSocket is optional for real-time updates (automatic fallback to HTTP polling)</li>
            <li>55 functional resources with automatic fallback system</li>
            <li>11 active API keys for enhanced features</li>
            <li>Comprehensive error handling and retry mechanisms</li>
            <li>Full documentation available at <code>/docs</code> endpoint</li>
            <li>Check <code>/api/routers</code> to see which endpoints are available</li>
            <li>Use <code>/api/health</code> to verify system status</li>
          </ul>

          <h3>Common Use Cases:</h3>
          <ul class="help-list">
            <li><strong>Get Prices:</strong> Use <code>/api/service/rate</code> or <code>/api/market/tickers</code></li>
            <li><strong>Get News:</strong> Use <code>/api/news/latest</code> or <code>/api/news</code></li>
            <li><strong>Track Whales:</strong> Use <code>/api/service/whales</code></li>
            <li><strong>Analyze Sentiment:</strong> Use <code>/api/sentiment/analyze</code> or <code>/api/service/sentiment</code></li>
            <li><strong>Get Blockchain Data:</strong> Use <code>/api/service/onchain</code> or <code>/api/blockchain/gas</code></li>
            <li><strong>Technical Analysis:</strong> Use <code>/api/technical/analyze</code> or other TA endpoints</li>
          </ul>

          <h3>If You Encounter Errors:</h3>
          <ol class="help-steps">
            <li>Check <code>/api/health</code> - System should be "healthy"</li>
            <li>Check <code>/api/routers</code> - Verify endpoints are loaded</li>
            <li>Check <code>/docs</code> - See all available endpoints</li>
            <li>See <strong>Section 10: Common Errors & Solutions</strong> for specific fixes</li>
            <li>Check browser DevTools → Network tab for actual error messages</li>
            <li>Verify Space is running and not sleeping</li>
          </ol>

          <h3>Getting Help:</h3>
          <ul class="help-list">
            <li><strong>API Documentation:</strong> Visit <code>/docs</code> for interactive Swagger UI</li>
            <li><strong>OpenAPI Spec:</strong> <code>/openapi.json</code> for complete API specification</li>
            <li><strong>Router Status:</strong> <code>/api/routers</code> to see loaded endpoints</li>
            <li><strong>System Status:</strong> <code>/api/status</code> for detailed system information</li>
            <li><strong>This Help Page:</strong> Complete guide with examples and troubleshooting</li>
          </ul>
        </section>
      </div>
    </main>
  </div>

  <!-- Shared JS -->
  <script type="module" src="../../shared/js/core/layout-manager.js"></script>
  
  <!-- Initialize layout and page -->
  <script type="module">
    import { LayoutManager } from '/static/shared/js/core/layout-manager.js';
    import HelpPage from './help.js';
    
    document.addEventListener('DOMContentLoaded', async () => {
      await LayoutManager.init('help');
      const helpPage = new HelpPage();
      helpPage.init();
    });
  </script>
</body>
</html>