-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
835 lines (795 loc) · 19.4 KB
/
openapi.yaml
File metadata and controls
835 lines (795 loc) · 19.4 KB
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
openapi: 3.0.3
info:
title: Reddit AI Curator API
description: |
AI-powered Reddit search and curation platform.
## Features
- **Multi-Query Tournament**: Run multiple query variants and select the best performers
- **Smart Cascade**: Adaptive search with fallback logic for high recall
- **AI Scoring**: LLM-powered relevance scoring with rule-based fallback
- **Tag Learning**: Extract semantic tags from high-scoring posts
## Authentication
Currently, the API is open. Future versions will require JWT authentication.
## Rate Limiting
- 60 requests per minute (configurable)
- Responses include rate limit headers
version: 2.0.0
contact:
name: API Support
url: https://github.com/yourusername/reddit-ai-curator
servers:
- url: http://localhost:5000/api/v2
description: Development server
- url: https://api.reddit-ai-curator.com/v2
description: Production server
tags:
- name: Search
description: AI-powered Reddit search operations
- name: LLM
description: Large Language Model operations
- name: Subreddits
description: Subreddit management
- name: Queries
description: Saved query management
- name: Tags
description: Tagged results for AI learning
- name: Blacklist
description: Blacklist management
paths:
/health:
get:
tags:
- Health
summary: Health check
description: Check if the API and its dependencies are healthy
responses:
'200':
description: Service is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
'503':
description: Service is degraded
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/search:
post:
tags:
- Search
summary: Execute AI-powered search
description: |
Creates a search session, generates query variants using LLM,
executes cascade search, and returns scored results.
operationId: executeSearch
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SearchRequest'
example:
description: "Sexual assault while sleeping"
target_posts: 100
provider: mistral
subreddits:
- sexualassault
- TwoXChromosomes
deep_scan: true
sort: relevance
time_filter: month
responses:
'200':
description: Search results
content:
application/json:
schema:
$ref: '#/components/schemas/SearchResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/search/sessions:
get:
tags:
- Search
summary: List search sessions
description: Retrieve a paginated list of recent search sessions
parameters:
- name: page
in: query
schema:
type: integer
default: 1
- name: per_page
in: query
schema:
type: integer
default: 20
maximum: 100
responses:
'200':
description: List of search sessions
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedSessions'
/search/sessions/{session_id}:
get:
tags:
- Search
summary: Get search session details
parameters:
- name: session_id
in: path
required: true
schema:
type: integer
responses:
'200':
description: Session details
content:
application/json:
schema:
$ref: '#/components/schemas/SessionDetail'
'404':
description: Session not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/llm/generate:
post:
tags:
- LLM
summary: Generate query variants
description: Generate Boolean search query variants using LLM
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LLMGenerateRequest'
responses:
'200':
description: Generated query variants
content:
application/json:
schema:
$ref: '#/components/schemas/LLMGenerateResponse'
'400':
description: Invalid request or provider not configured
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/llm/score:
post:
tags:
- LLM
summary: Score a post
description: Score a Reddit post for relevance to criteria using LLM
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LLMScoreRequest'
responses:
'200':
description: Scoring result
content:
application/json:
schema:
$ref: '#/components/schemas/LLMScoreResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/subreddits:
get:
tags:
- Subreddits
summary: List subreddits
description: Get all active subreddits configured for searches
responses:
'200':
description: List of subreddits
content:
application/json:
schema:
type: object
properties:
subreddits:
type: array
items:
$ref: '#/components/schemas/Subreddit'
total:
type: integer
post:
tags:
- Subreddits
summary: Add subreddit
description: Add a new subreddit to the search configuration
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SubredditCreate'
responses:
'201':
description: Subreddit added
content:
application/json:
schema:
type: object
properties:
message:
type: string
id:
type: integer
name:
type: string
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/queries:
get:
tags:
- Queries
summary: List saved queries
description: Get a paginated list of saved search queries
parameters:
- name: page
in: query
schema:
type: integer
default: 1
- name: per_page
in: query
schema:
type: integer
default: 20
responses:
'200':
description: List of saved queries
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedQueries'
post:
tags:
- Queries
summary: Save a query
description: Save a new search query configuration
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SavedQueryCreate'
responses:
'201':
description: Query saved
content:
application/json:
schema:
type: object
properties:
message:
type: string
id:
type: integer
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/tags:
get:
tags:
- Tags
summary: List tagged results
description: Get tagged results for AI learning, optionally filtered by minimum score
parameters:
- name: min_score
in: query
schema:
type: number
default: 0
responses:
'200':
description: List of tagged results
content:
application/json:
schema:
$ref: '#/components/schemas/TagListResponse'
post:
tags:
- Tags
summary: Add tagged result
description: Add a new tagged result for AI learning
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TaggedResultCreate'
responses:
'201':
description: Result tagged
content:
application/json:
schema:
type: object
properties:
message:
type: string
id:
type: string
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/blacklist:
get:
tags:
- Blacklist
summary: List blacklisted posts
description: Get the list of posts excluded from search results
responses:
'200':
description: List of blacklisted posts
content:
application/json:
schema:
$ref: '#/components/schemas/BlacklistResponse'
post:
tags:
- Blacklist
summary: Add to blacklist
description: Add a post to the blacklist to exclude from future searches
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BlacklistCreate'
responses:
'201':
description: Post blacklisted
content:
application/json:
schema:
type: object
properties:
message:
type: string
id:
type: string
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
HealthResponse:
type: object
properties:
status:
type: string
enum: [healthy, degraded, unhealthy]
version:
type: string
database:
type: string
enum: [connected, disconnected, unknown]
cache:
type: string
enum: [connected, disconnected, unknown]
uptime_seconds:
type: number
timestamp:
type: string
format: date-time
SearchRequest:
type: object
required:
- description
properties:
description:
type: string
minLength: 10
maxLength: 1000
description: Natural language search description
target_posts:
type: integer
default: 100
minimum: 1
maximum: 500
provider:
type: string
enum: [mistral, gemini]
default: mistral
subreddits:
type: array
items:
type: string
description: Specific subreddits to search
deep_scan:
type: boolean
default: false
sort:
type: string
enum: [relevance, hot, new, top]
default: relevance
time_filter:
type: string
enum: [hour, day, week, month, year, all]
default: month
SearchResponse:
type: object
properties:
session_id:
type: integer
query:
type: string
query_variants:
type: array
items:
type: string
results:
type: array
items:
$ref: '#/components/schemas/PostResult'
total_found:
type: integer
total_scanned:
type: integer
duration_seconds:
type: number
status:
type: string
enum: [completed, partial, failed]
error_message:
type: string
PostResult:
type: object
properties:
id:
type: string
title:
type: string
content:
type: string
url:
type: string
score:
type: number
minimum: 0
maximum: 100
tags:
type: array
items:
type: string
subreddit:
type: string
author:
type: string
created_utc:
type: number
comments_count:
type: integer
LLMGenerateRequest:
type: object
required:
- description
properties:
description:
type: string
minLength: 10
maxLength: 1000
provider:
type: string
enum: [mistral, gemini]
default: mistral
num_variants:
type: integer
default: 4
minimum: 1
maximum: 10
LLMGenerateResponse:
type: object
properties:
description:
type: string
variants:
type: array
items:
type: object
properties:
query:
type: string
strategy:
type: string
confidence:
type: number
generated_at:
type: string
format: date-time
LLMScoreRequest:
type: object
required:
- post_title
- criteria
properties:
post_title:
type: string
post_content:
type: string
criteria:
type: string
minLength: 10
provider:
type: string
enum: [mistral, gemini]
default: mistral
LLMScoreResponse:
type: object
properties:
post_id:
type: string
score:
type: number
tags:
type: array
items:
type: string
reasoning:
type: string
cached:
type: boolean
scored_at:
type: string
format: date-time
SubredditCreate:
type: object
required:
- name
properties:
name:
type: string
minLength: 2
maxLength: 100
Subreddit:
type: object
properties:
id:
type: integer
name:
type: string
is_active:
type: boolean
created_at:
type: string
format: date-time
SavedQueryCreate:
type: object
required:
- name
- groups
properties:
name:
type: string
maxLength: 200
groups:
type: array
items:
type: array
items:
type: string
minItems: 1
criteria:
type: string
target_posts:
type: integer
default: 100
deep_scan:
type: boolean
default: false
provider:
type: string
enum: [mistral, gemini]
default: mistral
subreddits:
type: array
items:
type: string
sort:
type: string
time_filter:
type: string
SavedQuery:
type: object
properties:
id:
type: integer
name:
type: string
groups:
type: array
criteria:
type: string
provider:
type: string
target_posts:
type: integer
deep_scan:
type: boolean
subreddits:
type: array
items:
type: string
created_at:
type: string
format: date-time
is_active:
type: boolean
PaginatedSessions:
type: object
properties:
sessions:
type: array
items:
type: object
total:
type: integer
page:
type: integer
per_page:
type: integer
SessionDetail:
type: object
properties:
id:
type: integer
query:
type: string
variants:
type: array
status:
type: string
total_results:
type: integer
total_found:
type: integer
started_at:
type: string
completed_at:
type: string
duration_seconds:
type: number
PaginatedQueries:
type: object
properties:
queries:
type: array
items:
$ref: '#/components/schemas/SavedQuery'
total:
type: integer
page:
type: integer
per_page:
type: integer
TaggedResultCreate:
type: object
required:
- id
- title
- score
properties:
id:
type: string
title:
type: string
maxLength: 500
content:
type: string
maxLength: 10000
score:
type: number
minimum: 0
maximum: 100
original_query:
type: string
tags:
type: array
items:
type: string
effective_terms:
type: array
items:
type: string
TagListResponse:
type: object
properties:
results:
type: array
items:
type: object
total:
type: integer
min_score_filter:
type: number
BlacklistCreate:
type: object
required:
- id
- title
- url
properties:
id:
type: string
title:
type: string
maxLength: 500
url:
type: string
keywords:
type: string
criteria:
type: string
BlacklistResponse:
type: object
properties:
entries:
type: array
items:
type: object
properties:
id:
type: string
title:
type: string
url:
type: string
timestamp:
type: number
created_at:
type: string
format: date-time
total:
type: integer
ErrorResponse:
type: object
properties:
error:
type: string
detail:
type: string
code:
type: string
timestamp:
type: string
format: date-time
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT