OMCHOKSI108 commited on
Commit
b7293f9
Β·
1 Parent(s): 593a8fb

docs: add comprehensive OpenAPI docs for ReDoc/Swagger

Browse files

- Rich markdown description with data coverage, quick start
- Tag descriptions for all endpoint groups
- Contact info, license metadata
- API_REFERENCE.txt with full endpoint docs

Files changed (2) hide show
  1. API_REFERENCE.txt +591 -0
  2. app/main.py +134 -5
API_REFERENCE.txt ADDED
@@ -0,0 +1,591 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ================================================================================
2
+ ForexDataLake API β€” Complete Reference
3
+ ================================================================================
4
+
5
+ BASE URL (HuggingFace Space): https://omchoksi108-forexdatalake.hf.space
6
+ DOCS (Swagger UI): https://omchoksi108-forexdatalake.hf.space/docs
7
+ REDOC: https://omchoksi108-forexdatalake.hf.space/redoc
8
+
9
+ LOCAL BASE URL: http://localhost:7860
10
+
11
+ ================================================================================
12
+ AUTHENTICATION
13
+ ================================================================================
14
+
15
+ All endpoints (except /health) require an API key.
16
+
17
+ Header: X-API-Key: <your-api-key>
18
+ Current: X-API-Key: OJGHKJOAOFIERHOISSIGHERSGIOERSHGOESGIHESGHIE
19
+
20
+ Example:
21
+ curl -H "X-API-Key: OJGHKJOAOFIERHOISSIGHERSGIOERSHGOESGIHESGHIE" \
22
+ https://omchoksi108-forexdatalake.hf.space/api/v1/symbols
23
+
24
+
25
+ ================================================================================
26
+ VALID ENUM VALUES
27
+ ================================================================================
28
+
29
+ TIMEFRAMES:
30
+ 1min, 5min, 15min, 30min, 1hr, 4hr, 1day
31
+
32
+ ASSET CLASSES:
33
+ forex_major, forex_cross, crypto_major, crypto_alt, crypto_cross,
34
+ commodities, stocks
35
+
36
+ SOURCES:
37
+ ALL_TIME_DATA (full historical data β€” default)
38
+ data (recent data)
39
+ reports (equity/trade reports)
40
+
41
+ SUPPORTED INDICATORS:
42
+ sma Simple Moving Average
43
+ ema Exponential Moving Average
44
+ rsi Relative Strength Index
45
+ macd Moving Average Convergence Divergence
46
+ atr Average True Range
47
+ vwap Volume Weighted Average Price
48
+ bbands Bollinger Bands (middle band)
49
+
50
+
51
+ ================================================================================
52
+ 1. HEALTH CHECK
53
+ ================================================================================
54
+
55
+ GET /api/v1/health
56
+
57
+ Auth: NO (public)
58
+ Parameters: None
59
+
60
+ Response:
61
+ {
62
+ "status": "healthy",
63
+ "version": "1.0.0",
64
+ "timestamp": "2026-02-15T19:15:46.000000",
65
+ "total_files": 793,
66
+ "total_symbols": 110,
67
+ "total_timeframes": 7,
68
+ "cache_entries": 0
69
+ }
70
+
71
+ Example:
72
+ curl https://omchoksi108-forexdatalake.hf.space/api/v1/health
73
+
74
+
75
+ ================================================================================
76
+ 2. LIST ALL SYMBOLS
77
+ ================================================================================
78
+
79
+ GET /api/v1/symbols
80
+
81
+ Auth: YES
82
+ Parameters:
83
+ asset_class (optional) Filter by asset class
84
+ Values: forex_major, forex_cross, crypto_major,
85
+ crypto_alt, crypto_cross, commodities, stocks
86
+
87
+ Response: Array of SymbolInfo
88
+ [
89
+ {
90
+ "symbol": "EURUSD",
91
+ "asset_class": "forex_major",
92
+ "available_timeframes": ["1min", "5min", "15min", "30min", "1hr", "4hr", "1day"],
93
+ "description": "Euro / US Dollar"
94
+ }
95
+ ]
96
+
97
+ Examples:
98
+ curl -H "X-API-Key: <key>" \
99
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/symbols"
100
+
101
+ curl -H "X-API-Key: <key>" \
102
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/symbols?asset_class=forex_major"
103
+
104
+
105
+ ================================================================================
106
+ 3. SEARCH SYMBOLS
107
+ ================================================================================
108
+
109
+ GET /api/v1/symbols/search
110
+
111
+ Auth: YES
112
+ Parameters:
113
+ q (REQUIRED) Search query, 1-50 characters
114
+ asset_class (optional) Filter by asset class
115
+ limit (optional) Max results, default=20, range 1-100
116
+
117
+ Response: SymbolSearchResult
118
+ {
119
+ "total": 5,
120
+ "results": [
121
+ {
122
+ "symbol": "EURUSD",
123
+ "asset_class": "forex_major",
124
+ "available_timeframes": ["1hr", "4hr", "1day"],
125
+ "description": "Euro / US Dollar"
126
+ }
127
+ ]
128
+ }
129
+
130
+ Examples:
131
+ curl -H "X-API-Key: <key>" \
132
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/symbols/search?q=EUR"
133
+
134
+ curl -H "X-API-Key: <key>" \
135
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/symbols/search?q=BTC&asset_class=crypto_major&limit=5"
136
+
137
+
138
+ ================================================================================
139
+ 4. GET SYMBOL DETAIL
140
+ ================================================================================
141
+
142
+ GET /api/v1/symbols/{symbol}
143
+
144
+ Auth: YES
145
+ Parameters:
146
+ symbol (REQUIRED) Path parameter, auto-uppercased
147
+
148
+ Response: SymbolDetail
149
+ {
150
+ "symbol": "EURUSD",
151
+ "asset_class": "forex_major",
152
+ "description": "Euro / US Dollar",
153
+ "timeframes": [
154
+ {
155
+ "timeframe": "1hr",
156
+ "source": "ALL_TIME_DATA",
157
+ "row_count": 0,
158
+ "file_path": "ALL_TIME_DATA/1hr_time/EURUSD_1hr.parquet"
159
+ }
160
+ ]
161
+ }
162
+
163
+ Example:
164
+ curl -H "X-API-Key: <key>" \
165
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/symbols/EURUSD"
166
+
167
+
168
+ ================================================================================
169
+ 5. LIST TIMEFRAMES FOR A SYMBOL
170
+ ================================================================================
171
+
172
+ GET /api/v1/symbols/{symbol}/timeframes
173
+
174
+ Auth: YES
175
+ Parameters:
176
+ symbol (REQUIRED) Path parameter, auto-uppercased
177
+
178
+ Response: Array of TimeframeDetail
179
+ [
180
+ {
181
+ "timeframe": "1hr",
182
+ "source": "ALL_TIME_DATA",
183
+ "row_count": 0,
184
+ "file_path": "ALL_TIME_DATA/1hr_time/EURUSD_1hr.parquet"
185
+ }
186
+ ]
187
+
188
+ Example:
189
+ curl -H "X-API-Key: <key>" \
190
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/symbols/EURUSD/timeframes"
191
+
192
+
193
+ ================================================================================
194
+ 6. QUERY OHLCV DATA
195
+ ================================================================================
196
+
197
+ GET /api/v1/data
198
+
199
+ Auth: YES
200
+ Parameters:
201
+ symbol (REQUIRED) Trading symbol, e.g. EURUSD
202
+ timeframe (REQUIRED) Values: 1min, 5min, 15min, 30min, 1hr, 4hr, 1day
203
+ start (optional) Start timestamp, ISO 8601 format
204
+ end (optional) End timestamp, ISO 8601 format
205
+ source (optional) Default: "ALL_TIME_DATA"
206
+ limit (optional) Max rows, default=500, range 1-10000
207
+ offset (optional) Pagination offset, default=0
208
+
209
+ Response: OHLCVResponse
210
+ {
211
+ "symbol": "EURUSD",
212
+ "timeframe": "1hr",
213
+ "source": "ALL_TIME_DATA",
214
+ "total_rows": 389327,
215
+ "returned": 500,
216
+ "limit": 500,
217
+ "offset": 0,
218
+ "data": [
219
+ {
220
+ "ts": "1971-01-04 00:00:00",
221
+ "open": 1.2345,
222
+ "high": 1.2400,
223
+ "low": 1.2300,
224
+ "close": 1.2380,
225
+ "volume": 1500.0
226
+ }
227
+ ]
228
+ }
229
+
230
+ Examples:
231
+ curl -H "X-API-Key: <key>" \
232
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data?symbol=EURUSD&timeframe=1hr"
233
+
234
+ curl -H "X-API-Key: <key>" \
235
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data?symbol=EURUSD&timeframe=1hr&start=2020-01-01&end=2025-12-31&limit=1000"
236
+
237
+ curl -H "X-API-Key: <key>" \
238
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data?symbol=BTCUSD&timeframe=1day&source=data&limit=100"
239
+
240
+
241
+ ================================================================================
242
+ 7. GET DATE RANGE
243
+ ================================================================================
244
+
245
+ GET /api/v1/data/range
246
+
247
+ Auth: YES
248
+ Parameters:
249
+ symbol (REQUIRED) Trading symbol
250
+ timeframe (REQUIRED) Values: 1min, 5min, 15min, 30min, 1hr, 4hr, 1day
251
+ source (optional) Default: "ALL_TIME_DATA"
252
+
253
+ Response: DateRangeInfo
254
+ {
255
+ "symbol": "EURUSD",
256
+ "timeframe": "1hr",
257
+ "source": "ALL_TIME_DATA",
258
+ "start_date": "1971-01-04 00:00:00",
259
+ "end_date": "2026-01-13 11:00:00",
260
+ "total_rows": 389327
261
+ }
262
+
263
+ Example:
264
+ curl -H "X-API-Key: <key>" \
265
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data/range?symbol=EURUSD&timeframe=1hr"
266
+
267
+
268
+ ================================================================================
269
+ 8. GET LATEST BARS
270
+ ================================================================================
271
+
272
+ GET /api/v1/data/latest
273
+
274
+ Auth: YES
275
+ Parameters:
276
+ symbol (REQUIRED) Trading symbol
277
+ timeframe (REQUIRED) Values: 1min, 5min, 15min, 30min, 1hr, 4hr, 1day
278
+ count (optional) Number of most recent bars, default=1, range 1-100
279
+ source (optional) Default: "ALL_TIME_DATA"
280
+
281
+ Response: LatestBar
282
+ {
283
+ "symbol": "EURUSD",
284
+ "timeframe": "1hr",
285
+ "count": 5,
286
+ "data": [
287
+ {
288
+ "ts": "2026-01-13 07:00:00",
289
+ "open": 1.0250,
290
+ "high": 1.0265,
291
+ "low": 1.0240,
292
+ "close": 1.0258,
293
+ "volume": 2500.0
294
+ }
295
+ ]
296
+ }
297
+
298
+ Example:
299
+ curl -H "X-API-Key: <key>" \
300
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data/latest?symbol=EURUSD&timeframe=1day&count=10"
301
+
302
+
303
+ ================================================================================
304
+ 9. GET EQUITY CURVE
305
+ ================================================================================
306
+
307
+ GET /api/v1/reports/equity
308
+
309
+ Auth: YES
310
+ Parameters:
311
+ limit (optional) Max rows, default=500, range 1-10000
312
+ offset (optional) Pagination offset, default=0
313
+
314
+ Response: EquityResponse
315
+ {
316
+ "total": 5000,
317
+ "returned": 500,
318
+ "limit": 500,
319
+ "offset": 0,
320
+ "data": [
321
+ {
322
+ "step": 0,
323
+ "equity": 10000.0
324
+ }
325
+ ]
326
+ }
327
+
328
+ Example:
329
+ curl -H "X-API-Key: <key>" \
330
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/reports/equity?limit=1000"
331
+
332
+
333
+ ================================================================================
334
+ 10. GET TRADE RECORDS
335
+ ================================================================================
336
+
337
+ GET /api/v1/reports/trades
338
+
339
+ Auth: YES
340
+ Parameters:
341
+ pair (optional) Filter by trading pair
342
+ side (optional) Filter by side: "buy" or "sell"
343
+ limit (optional) Max rows, default=500, range 1-10000
344
+ offset (optional) Pagination offset, default=0
345
+
346
+ Response: TradesResponse
347
+ {
348
+ "total": 320,
349
+ "returned": 100,
350
+ "limit": 100,
351
+ "offset": 0,
352
+ "data": [
353
+ {
354
+ "pair": "EURUSD",
355
+ "type": "market",
356
+ "side": "buy",
357
+ "price": 1.0250,
358
+ "size": 100000.0,
359
+ "time": "2025-06-15 14:30:00",
360
+ "score": 0.85,
361
+ "pnl": 250.0
362
+ }
363
+ ]
364
+ }
365
+
366
+ Examples:
367
+ curl -H "X-API-Key: <key>" \
368
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/reports/trades"
369
+
370
+ curl -H "X-API-Key: <key>" \
371
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/reports/trades?pair=EURUSD&side=buy&limit=50"
372
+
373
+
374
+ ================================================================================
375
+ 11. LIST SUPPORTED INDICATORS
376
+ ================================================================================
377
+
378
+ GET /api/v1/indicators
379
+
380
+ Auth: YES
381
+ Parameters: None
382
+
383
+ Response:
384
+ {
385
+ "indicators": {
386
+ "sma": "Simple Moving Average",
387
+ "ema": "Exponential Moving Average",
388
+ "rsi": "Relative Strength Index",
389
+ "macd": "Moving Average Convergence Divergence",
390
+ "atr": "Average True Range",
391
+ "vwap": "Volume Weighted Average Price",
392
+ "bbands": "Bollinger Bands (middle)"
393
+ }
394
+ }
395
+
396
+ Example:
397
+ curl -H "X-API-Key: <key>" \
398
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/indicators"
399
+
400
+
401
+ ================================================================================
402
+ 12. COMPUTE INDICATOR
403
+ ================================================================================
404
+
405
+ GET /api/v1/indicators/{symbol}
406
+
407
+ Auth: YES
408
+ Parameters:
409
+ symbol (REQUIRED) Path parameter, auto-uppercased
410
+ indicator (REQUIRED) Values: sma, ema, rsi, macd, atr, vwap, bbands
411
+ timeframe (REQUIRED) Values: 1min, 5min, 15min, 30min, 1hr, 4hr, 1day
412
+ period (optional) Indicator lookback period, default=14, range 1-500
413
+ start (optional) Start timestamp, ISO 8601
414
+ end (optional) End timestamp, ISO 8601
415
+ source (optional) Default: "ALL_TIME_DATA"
416
+ limit (optional) Max rows, default=500, range 1-10000
417
+ offset (optional) Pagination offset, default=0
418
+
419
+ Response: IndicatorResponse
420
+ {
421
+ "symbol": "EURUSD",
422
+ "timeframe": "1hr",
423
+ "indicator": "sma",
424
+ "period": 14,
425
+ "total_rows": 500,
426
+ "returned": 500,
427
+ "data": [
428
+ {
429
+ "ts": "2025-01-01 00:00:00",
430
+ "open": 1.0250,
431
+ "high": 1.0265,
432
+ "low": 1.0240,
433
+ "close": 1.0258,
434
+ "volume": 2500.0,
435
+ "indicator_value": 1.0255
436
+ }
437
+ ]
438
+ }
439
+
440
+ Examples:
441
+ curl -H "X-API-Key: <key>" \
442
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/indicators/EURUSD?indicator=sma&timeframe=1hr&period=20"
443
+
444
+ curl -H "X-API-Key: <key>" \
445
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/indicators/BTCUSD?indicator=rsi&timeframe=1day&period=14"
446
+
447
+ curl -H "X-API-Key: <key>" \
448
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/indicators/EURUSD?indicator=macd&timeframe=4hr"
449
+
450
+
451
+ ================================================================================
452
+ 13. REFRESH METADATA INDEX (SYNC)
453
+ ================================================================================
454
+
455
+ POST /api/v1/sync
456
+
457
+ Auth: YES
458
+ Parameters: None
459
+
460
+ Description:
461
+ Re-scans the remote HuggingFace repo and rebuilds the parquet file
462
+ metadata index. No data is downloaded β€” everything stays remote.
463
+
464
+ Response:
465
+ {
466
+ "status": "refreshed",
467
+ "total_files": 793,
468
+ "total_symbols": 110
469
+ }
470
+
471
+ Example:
472
+ curl -X POST -H "X-API-Key: <key>" \
473
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/sync"
474
+
475
+
476
+ ================================================================================
477
+ 14. WEBSOCKET STREAM
478
+ ================================================================================
479
+
480
+ WS /api/v1/ws/stream?api_key=<your-api-key>
481
+
482
+ Auth: Via query parameter "api_key"
483
+ Connection: ws://host/api/v1/ws/stream?api_key=<key>
484
+
485
+ CLIENT SENDS (JSON):
486
+
487
+ Subscribe to a symbol:
488
+ {
489
+ "symbol": "EURUSD", // REQUIRED
490
+ "timeframe": "1hr", // optional, default "1h"
491
+ "source": "ALL_TIME_DATA",// optional, default "ALL_TIME_DATA"
492
+ "limit": 100 // optional, default 100, max 1000
493
+ }
494
+
495
+ Unsubscribe:
496
+ { "action": "unsubscribe" }
497
+
498
+ Ping:
499
+ { "action": "ping" }
500
+
501
+ SERVER RESPONDS (JSON):
502
+
503
+ On subscribe β€” stream header:
504
+ { "status": "streaming", "symbol": "EURUSD", "timeframe": "1hr", "total": 100 }
505
+
506
+ Each bar:
507
+ {
508
+ "type": "bar",
509
+ "data": {
510
+ "ts": "2025-01-01 00:00:00",
511
+ "open": 1.0250,
512
+ "high": 1.0265,
513
+ "low": 1.0240,
514
+ "close": 1.0258,
515
+ "volume": 2500.0
516
+ }
517
+ }
518
+
519
+ End of stream:
520
+ { "type": "end", "symbol": "EURUSD" }
521
+
522
+ On ping:
523
+ { "status": "pong" }
524
+
525
+ On unsubscribe:
526
+ { "status": "unsubscribed" }
527
+
528
+ On error:
529
+ { "error": "Symbol 'XYZ' not found" }
530
+
531
+
532
+ ================================================================================
533
+ ERROR RESPONSES
534
+ ================================================================================
535
+
536
+ All errors return JSON:
537
+
538
+ {
539
+ "error": "ERROR_CODE",
540
+ "detail": "Human-readable message",
541
+ "path": "/api/v1/..."
542
+ }
543
+
544
+ Error codes:
545
+ SYMBOL_NOT_FOUND Symbol does not exist in the data lake
546
+ TIMEFRAME_NOT_FOUND Timeframe not available for this symbol
547
+ INVALID_DATE_RANGE Start date is after end date
548
+ DATA_NOT_AVAILABLE No data found for this query
549
+ AUTHENTICATION_FAILED Missing or invalid API key
550
+ RATE_LIMIT_EXCEEDED Too many requests
551
+ VALIDATION_ERROR Invalid parameter value
552
+ DATABASE_ERROR DuckDB query failed
553
+ INTERNAL_ERROR Unexpected server error
554
+
555
+ HTTP Status Codes:
556
+ 200 Success
557
+ 401 Authentication failed
558
+ 404 Symbol/timeframe/data not found
559
+ 422 Validation error (missing/invalid params)
560
+ 429 Rate limit exceeded
561
+ 500 Internal server error
562
+
563
+
564
+ ================================================================================
565
+ QUICK START EXAMPLES
566
+ ================================================================================
567
+
568
+ # 1. Check API health
569
+ curl https://omchoksi108-forexdatalake.hf.space/api/v1/health
570
+
571
+ # 2. List all forex major symbols
572
+ curl -H "X-API-Key: OJGHKJOAOFIERHOISSIGHERSGIOERSHGOESGIHESGHIE" \
573
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/symbols?asset_class=forex_major"
574
+
575
+ # 3. Get EURUSD date range
576
+ curl -H "X-API-Key: OJGHKJOAOFIERHOISSIGHERSGIOERSHGOESGIHESGHIE" \
577
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data/range?symbol=EURUSD&timeframe=1hr"
578
+
579
+ # 4. Get last 10 daily bars for BTCUSD
580
+ curl -H "X-API-Key: OJGHKJOAOFIERHOISSIGHERSGIOERSHGOESGIHESGHIE" \
581
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data/latest?symbol=BTCUSD&timeframe=1day&count=10"
582
+
583
+ # 5. Get OHLCV data with date filter
584
+ curl -H "X-API-Key: OJGHKJOAOFIERHOISSIGHERSGIOERSHGOESGIHESGHIE" \
585
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/data?symbol=EURUSD&timeframe=1hr&start=2024-01-01&end=2024-12-31&limit=1000"
586
+
587
+ # 6. Compute RSI(14) on EURUSD hourly
588
+ curl -H "X-API-Key: OJGHKJOAOFIERHOISSIGHERSGIOERSHGOESGIHESGHIE" \
589
+ "https://omchoksi108-forexdatalake.hf.space/api/v1/indicators/EURUSD?indicator=rsi&timeframe=1hr&period=14"
590
+
591
+ ================================================================================
app/main.py CHANGED
@@ -65,18 +65,142 @@ async def lifespan(app: FastAPI):
65
 
66
  def create_app() -> FastAPI:
67
  """Build and configure the FastAPI application."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  application = FastAPI(
69
  title="ForexDataLake API",
70
- description=(
71
- "High-performance market data API serving OHLCV data from a "
72
- "HuggingFace-hosted parquet data lake. Supports 111 instruments, "
73
- "7 timeframes, technical indicators, equity/trade reports, and WebSocket streaming."
74
- ),
75
  version="1.0.0",
76
  lifespan=lifespan,
77
  docs_url="/docs",
78
  redoc_url="/redoc",
79
  openapi_url="/openapi.json",
 
 
 
 
 
 
 
 
 
80
  )
81
 
82
  # -- Exception handlers ---------------------------------------------------
@@ -109,6 +233,11 @@ def create_app() -> FastAPI:
109
  response_model=HealthResponse,
110
  tags=["Health"],
111
  summary="Health check",
 
 
 
 
 
112
  )
113
  def health() -> HealthResponse:
114
  from app.core.cache import cache
 
65
 
66
  def create_app() -> FastAPI:
67
  """Build and configure the FastAPI application."""
68
+
69
+ DESCRIPTION = """
70
+ ## ForexDataLake API πŸ“ˆ
71
+
72
+ **High-performance market data API** serving OHLCV data directly from a
73
+ HuggingFace-hosted parquet data lake β€” **zero local storage required**.
74
+
75
+ ---
76
+
77
+ ### πŸ“Š Data Coverage
78
+
79
+ | Category | Count |
80
+ |----------|-------|
81
+ | **Instruments** | 111 symbols |
82
+ | **Timeframes** | 7 (1min β†’ 1day) |
83
+ | **Total Rows** | 276M+ |
84
+ | **Data Size** | 4.65 GB |
85
+ | **Asset Classes** | Forex, Crypto, Commodities, Stocks |
86
+
87
+ ### πŸ”‘ Authentication
88
+
89
+ All endpoints (except `/health`) require an API key via the `X-API-Key` header.
90
+
91
+ ```
92
+ curl -H "X-API-Key: YOUR_KEY" https://host/api/v1/symbols
93
+ ```
94
+
95
+ ### ⏱️ Supported Timeframes
96
+
97
+ `1min` Β· `5min` Β· `15min` Β· `30min` Β· `1hr` Β· `4hr` Β· `1day`
98
+
99
+ ### πŸ“ˆ Supported Indicators
100
+
101
+ `sma` Β· `ema` Β· `rsi` Β· `macd` Β· `atr` Β· `vwap` Β· `bbands`
102
+
103
+ ### πŸ—‚οΈ Data Sources
104
+
105
+ | Source | Description |
106
+ |--------|-------------|
107
+ | `ALL_TIME_DATA` | Full historical data (default) |
108
+ | `data` | Recent/live data |
109
+ | `reports` | Equity curves & trade logs |
110
+
111
+ ### ⚑ Quick Start
112
+
113
+ 1. **Health check** β€” `GET /api/v1/health` (no auth)
114
+ 2. **List symbols** β€” `GET /api/v1/symbols`
115
+ 3. **Get date range** β€” `GET /api/v1/data/range?symbol=EURUSD&timeframe=1hr`
116
+ 4. **Fetch OHLCV** β€” `GET /api/v1/data?symbol=EURUSD&timeframe=1hr&limit=100`
117
+ 5. **Compute RSI** β€” `GET /api/v1/indicators/EURUSD?indicator=rsi&timeframe=1hr`
118
+ 6. **Stream via WS** β€” `WS /api/v1/ws/stream?api_key=KEY`
119
+
120
+ ---
121
+
122
+ ### ❌ Error Format
123
+
124
+ All errors return:
125
+ ```json
126
+ {
127
+ "error": "SYMBOL_NOT_FOUND",
128
+ "detail": "Symbol 'XYZ' not found",
129
+ "path": "/api/v1/symbols/XYZ"
130
+ }
131
+ ```
132
+ """
133
+
134
+ tags_metadata = [
135
+ {
136
+ "name": "Health",
137
+ "description": "Server health and status. **No authentication required.**",
138
+ },
139
+ {
140
+ "name": "Symbols",
141
+ "description": (
142
+ "Discover and search available trading instruments. "
143
+ "List all symbols, filter by asset class, search by name, "
144
+ "and get detailed symbol info including available timeframes."
145
+ ),
146
+ },
147
+ {
148
+ "name": "Market Data",
149
+ "description": (
150
+ "Query historical OHLCV (Open, High, Low, Close, Volume) candlestick data. "
151
+ "Supports date filtering, pagination, date range discovery, "
152
+ "and fetching the latest N bars."
153
+ ),
154
+ },
155
+ {
156
+ "name": "Indicators",
157
+ "description": (
158
+ "Compute technical indicators on OHLCV data on-the-fly. "
159
+ "Supported: **SMA**, **EMA**, **RSI**, **MACD**, **ATR**, **VWAP**, **Bollinger Bands**. "
160
+ "Specify the indicator name, timeframe, and lookback period."
161
+ ),
162
+ },
163
+ {
164
+ "name": "Reports",
165
+ "description": (
166
+ "Access trading reports including equity curves (cumulative P&L) "
167
+ "and individual trade records with pair/side filtering."
168
+ ),
169
+ },
170
+ {
171
+ "name": "Sync",
172
+ "description": (
173
+ "Refresh the internal metadata index by re-scanning the remote "
174
+ "HuggingFace repository. No data is downloaded β€” everything is read remotely."
175
+ ),
176
+ },
177
+ {
178
+ "name": "WebSocket",
179
+ "description": (
180
+ "Stream OHLCV bars over a persistent WebSocket connection. "
181
+ "Authenticate via `?api_key=KEY` query parameter. "
182
+ "Send JSON subscription messages to receive bars."
183
+ ),
184
+ },
185
+ ]
186
+
187
  application = FastAPI(
188
  title="ForexDataLake API",
189
+ description=DESCRIPTION,
 
 
 
 
190
  version="1.0.0",
191
  lifespan=lifespan,
192
  docs_url="/docs",
193
  redoc_url="/redoc",
194
  openapi_url="/openapi.json",
195
+ openapi_tags=tags_metadata,
196
+ contact={
197
+ "name": "OMCHOKSI108",
198
+ "url": "https://huggingface.co/OMCHOKSI108",
199
+ },
200
+ license_info={
201
+ "name": "MIT",
202
+ },
203
+ root_path_in_servers=False,
204
  )
205
 
206
  # -- Exception handlers ---------------------------------------------------
 
233
  response_model=HealthResponse,
234
  tags=["Health"],
235
  summary="Health check",
236
+ description=(
237
+ "Returns the current health status of the API including version, "
238
+ "number of indexed parquet files, unique symbols, timeframes, "
239
+ "and cache statistics. **No authentication required.**"
240
+ ),
241
  )
242
  def health() -> HealthResponse:
243
  from app.core.cache import cache