-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1100 lines (1099 loc) · 30.5 KB
/
Copy pathopenapi.yaml
File metadata and controls
1100 lines (1099 loc) · 30.5 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
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
openapi: 3.1.0
info:
title: Intuition Core Query API
version: 0.1.0
description: |
REST API for reading and writing the local Intuition knowledge graph.
Authentication is controlled by `API_AUTH`:
- `public-read` (default): read endpoints are open; write endpoints require a writable bearer API key.
- `gated`: all endpoints require a valid bearer API key except `/health` and `/api/schema`.
- `open`: no endpoint requires a key; writes are unattributed.
servers:
- url: http://localhost:3000
description: Local Docker Compose stack
security: []
tags:
- name: Health
- name: Schema
- name: Atoms
- name: Triples
- name: Predicates
- name: Stats
paths:
/health:
get:
tags: [Health]
summary: Check API and database health
responses:
"200":
description: API and database are healthy.
content:
application/json:
schema:
$ref: "#/components/schemas/HealthOk"
examples:
ok:
value:
status: ok
"503":
description: API is running but the database is unreachable.
content:
application/json:
schema:
$ref: "#/components/schemas/HealthDegraded"
/api/schema:
get:
tags: [Schema]
summary: Get machine-readable KG table metadata
description: Returns cached metadata for base tables in the `kg` schema only.
responses:
"200":
description: KG schema metadata.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
$ref: "#/components/schemas/KgSchemaMetadata"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/atoms:
get:
tags: [Atoms]
summary: List public atoms
security:
- bearerAuth: []
- {}
parameters:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
- name: classification_type
in: query
schema:
type: string
description: Filter by atom classification type.
- name: q
in: query
schema:
type: string
description: Substring search over atom search text.
responses:
"200":
description: Public atoms ordered newest first.
content:
application/json:
schema:
type: object
required: [data, pagination]
properties:
data:
type: array
items:
$ref: "#/components/schemas/AtomListItem"
pagination:
$ref: "#/components/schemas/Pagination"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
post:
tags: [Atoms]
summary: Create an atom
description: Creates or finds the deterministic atom for a string, URL, or JSON input.
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [input]
properties:
input:
type: string
minLength: 1
maxLength: 64000
examples:
githubRepo:
value:
input: https://github.com/oven-sh/bun
responses:
"200":
description: Atom already existed.
content:
application/json:
schema:
$ref: "#/components/schemas/CreateAtomResponse"
"201":
description: Atom created.
content:
application/json:
schema:
$ref: "#/components/schemas/CreateAtomResponse"
examples:
created:
value:
data:
id: "0x951d18ba45fdf5ef5c3304ea3ae46a45e00b68464e2b1561cce4b48ffa1c09d3"
created: true
createdBy: "0x1111111111111111111111111111111111111111"
"400":
description: Invalid JSON or invalid input.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"403":
$ref: "#/components/responses/ApiKeyNotWritable"
"413":
description: Input is too large.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/atoms/{id}:
get:
tags: [Atoms]
summary: Get one public atom
security:
- bearerAuth: []
- {}
parameters:
- $ref: "#/components/parameters/TermId"
responses:
"200":
description: Atom row.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
$ref: "#/components/schemas/Atom"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"404":
$ref: "#/components/responses/NotFound"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/atoms/{id}/triples:
get:
tags: [Atoms, Triples]
summary: List public triples touching an atom
description: Matches the atom id in subject, predicate, or object position.
security:
- bearerAuth: []
- {}
parameters:
- $ref: "#/components/parameters/TermId"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
- $ref: "#/components/parameters/ExpandTerms"
responses:
"200":
description: Triples touching the atom.
content:
application/json:
schema:
type: object
required: [data, pagination]
properties:
data:
type: array
items:
$ref: "#/components/schemas/Triple"
pagination:
$ref: "#/components/schemas/Pagination"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/atoms/{id}/artifacts:
get:
tags: [Atoms]
summary: List enrichment artifacts attached to an atom
description: >-
One row per provider output (opengraph, github-repo, ...). Newest
first. 404 when the atom is absent or not public.
security:
- bearerAuth: []
- {}
parameters:
- $ref: "#/components/parameters/TermId"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
responses:
"200":
description: Artifacts for the atom.
content:
application/json:
schema:
type: object
required: [data, pagination]
properties:
data:
type: array
items:
$ref: "#/components/schemas/Artifact"
pagination:
$ref: "#/components/schemas/Pagination"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"404":
$ref: "#/components/responses/NotFound"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/triples:
get:
tags: [Triples]
summary: List public triples
security:
- bearerAuth: []
- {}
parameters:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
- $ref: "#/components/parameters/ExpandTerms"
- name: subject_id
in: query
schema:
type: string
description: Filter by subject term id.
- name: predicate_id
in: query
schema:
type: string
description: Filter by predicate term id.
- name: object_id
in: query
schema:
type: string
description: Filter by object term id.
responses:
"200":
description: Public triples ordered newest first.
content:
application/json:
schema:
type: object
required: [data, pagination]
properties:
data:
type: array
items:
$ref: "#/components/schemas/Triple"
pagination:
$ref: "#/components/schemas/Pagination"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
post:
tags: [Triples]
summary: Create a triple
description: Creates or finds the deterministic triple for subject, predicate, and object ids.
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [subject_id, predicate_id, object_id]
properties:
subject_id:
type: string
predicate_id:
type: string
object_id:
type: string
examples:
claim:
value:
subject_id: "0x951d18ba45fdf5ef5c3304ea3ae46a45e00b68464e2b1561cce4b48ffa1c09d3"
predicate_id: "0x0840db4575bf6bdb49b66c21dc40cb4cbb5e1b26bd239d7f56b126c14e452c07"
object_id: "0x49ed8bdcd1954e1de3af8bb5fca0f0377ebe598de5dd82ab5b4a45a82d53a53f"
responses:
"200":
description: Triple already existed.
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTripleResponse"
"201":
description: Triple created.
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTripleResponse"
"400":
description: Invalid JSON, invalid input, or invalid term id.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"403":
$ref: "#/components/responses/ApiKeyNotWritable"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/triples/{id}:
get:
tags: [Triples]
summary: Get one public triple
security:
- bearerAuth: []
- {}
parameters:
- $ref: "#/components/parameters/TermId"
- $ref: "#/components/parameters/ExpandTerms"
responses:
"200":
description: Triple row.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
$ref: "#/components/schemas/Triple"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"404":
$ref: "#/components/responses/NotFound"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/events:
get:
tags: [Events]
summary: List graph activity events
description: >-
Append-only activity feed (kg.events) — node/triple/predicate/artifact
creations, onchain and off.
security:
- bearerAuth: []
- {}
parameters:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
- name: entity_kind
in: query
schema:
type: string
enum: [node, triple, predicate, artifact]
description: Filter by entity kind.
- name: event_type
in: query
schema:
type: string
description: Filter by event type.
- name: entity_id
in: query
schema:
type: string
description: Filter by entity id.
responses:
"200":
description: Events, newest first.
content:
application/json:
schema:
type: object
required: [data, pagination]
properties:
data:
type: array
items:
$ref: "#/components/schemas/Event"
pagination:
$ref: "#/components/schemas/Pagination"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/predicates:
get:
tags: [Predicates]
summary: List predicate registry
security:
- bearerAuth: []
- {}
responses:
"200":
description: Seeded predicate registry ordered by slug.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
type: array
items:
$ref: "#/components/schemas/Predicate"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/stats/pipeline:
get:
tags: [Stats]
summary: Worker-pipeline status counts
description: Per-stage (parse, classification, enrichment) status counts over public atoms.
security:
- bearerAuth: []
- {}
responses:
"200":
description: Pipeline stats.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
$ref: "#/components/schemas/PipelineStats"
"401":
$ref: "#/components/responses/ApiKeyRequired"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
/api/stats:
get:
tags: [Stats]
summary: Get public graph counts
security:
- bearerAuth: []
- {}
responses:
"200":
description: Counts for active public atoms/triples and all accounts/predicates.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
$ref: "#/components/schemas/Stats"
examples:
empty:
value:
data:
atoms: 0
triples: 0
accounts: 0
predicates: 14
"401":
$ref: "#/components/responses/ApiKeyRequired"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/InternalError"
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: API key
description: Operator-minted `ik_...` API key.
parameters:
Limit:
name: limit
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 25
description: Page size. Values above 100 are clamped to 100.
Offset:
name: offset
in: query
schema:
type: integer
minimum: 0
default: 0
description: Row offset. Negative or invalid values become 0.
TermId:
name: id
in: path
required: true
schema:
type: string
description: Protocol atom or triple id.
ExpandTerms:
name: expand
in: query
required: false
schema:
type: string
enum: [terms]
description: >-
`expand=terms` embeds a `{id, data, classificationType, rawType}`
summary for each subject/predicate/object term (null when the term's
atom is not public).
responses:
ApiKeyRequired:
description: The endpoint requires an API key in the current auth mode, or the presented key is invalid/revoked.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
required:
value:
error: api_key_required
invalid:
value:
error: invalid_api_key
ApiKeyNotWritable:
description: The presented API key is read-only.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
notWritable:
value:
error: api_key_not_writable
NotFound:
description: The resource was not found or is not public.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
notFound:
value:
error: not_found
RateLimited:
description: Request rate limit exceeded.
headers:
retry-after:
schema:
type: string
description: Seconds until the bucket resets.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
rateLimited:
value:
error: rate_limited
InternalError:
description: Unhandled server error.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
internal:
value:
error: internal_error
schemas:
AnyJson:
description: Arbitrary JSON value.
Error:
type: object
required: [error]
properties:
error:
type: string
message:
type: string
additionalProperties: true
HealthOk:
type: object
required: [status]
properties:
status:
type: string
const: ok
HealthDegraded:
type: object
required: [status, database]
properties:
status:
type: string
const: degraded
database:
type: string
const: unreachable
Pagination:
type: object
required: [limit, offset, count]
properties:
limit:
type: integer
offset:
type: integer
count:
type: integer
description: Number of rows returned in this response, not total available rows.
AtomListItem:
type: object
required:
- id
- createdAt
- isOnchain
- rawType
- dataResolved
- classificationType
- parseStatus
- classificationStatus
- enrichmentStatus
properties:
id:
type: string
createdAt:
type: string
format: date-time
isOnchain:
type: boolean
rawType:
type: string
enum: [string, json, http_uri, ipfs_uri]
data:
type: [string, "null"]
dataResolved:
$ref: "#/components/schemas/AnyJson"
classificationType:
type: string
parseStatus:
type: string
classificationStatus:
type: string
enrichmentStatus:
type: string
Atom:
allOf:
- $ref: "#/components/schemas/AtomListItem"
- type: object
additionalProperties: true
properties:
updatedAt:
type: string
format: date-time
status:
type: string
visibility:
type: string
createdBy:
type: [string, "null"]
dataHex:
type: [string, "null"]
parseError:
$ref: "#/components/schemas/AnyJson"
parseResult:
$ref: "#/components/schemas/AnyJson"
classificationError:
$ref: "#/components/schemas/AnyJson"
classificationResult:
$ref: "#/components/schemas/AnyJson"
enrichmentError:
$ref: "#/components/schemas/AnyJson"
processingMeta:
$ref: "#/components/schemas/AnyJson"
searchText:
type: string
stats:
oneOf:
- $ref: "#/components/schemas/NodeStats"
- type: "null"
description: Graph-degree stats; null until the atom participates in a triple.
Triple:
type: object
required:
- id
- createdAt
- updatedAt
- isOnchain
- status
- visibility
- subjectId
- subjectType
- predicateId
- predicateType
- objectId
- objectType
- isCounterTriple
- edgeKind
- inferred
- provenance
- metadata
additionalProperties: true
properties:
id:
type: string
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
isOnchain:
type: boolean
status:
type: string
visibility:
type: string
createdBy:
type: [string, "null"]
subjectId:
type: string
subjectType:
type: string
enum: [node, triple]
predicateId:
type: string
predicateType:
type: string
enum: [node, triple]
objectId:
type: string
objectType:
type: string
enum: [node, triple]
isCounterTriple:
type: boolean
siblingTripleId:
type: [string, "null"]
edgeKind:
type: string
source:
type: [string, "null"]
sourceUri:
type: [string, "null"]
confidence:
type: [string, "null"]
inferred:
type: boolean
provenance:
$ref: "#/components/schemas/AnyJson"
metadata:
$ref: "#/components/schemas/AnyJson"
TermSummary:
type: [object, "null"]
description: Joined atom summary for a triple term (null when not public).
properties:
id:
type: string
data:
type: [string, "null"]
classificationType:
type: string
rawType:
type: string
ExpandedTriple:
allOf:
- $ref: "#/components/schemas/Triple"
- type: object
properties:
subject:
$ref: "#/components/schemas/TermSummary"
predicate:
$ref: "#/components/schemas/TermSummary"
object:
$ref: "#/components/schemas/TermSummary"
NodeStats:
type: object
required: [inDegree, outDegree, neighborKindCounts, predicateCounts]
properties:
inDegree:
type: integer
outDegree:
type: integer
neighborKindCounts:
$ref: "#/components/schemas/AnyJson"
predicateCounts:
$ref: "#/components/schemas/AnyJson"
updatedAt:
type: [string, "null"]
format: date-time
Artifact:
type: object
required: [id, createdAt, updatedAt, artifactKind, artifactVersion, status, data, extracted]
properties:
id:
type: string
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
artifactKind:
type: string
description: Provider slug, e.g. `opengraph`, `github-repo`.
artifactVersion:
type: string
status:
type: string
sourceUri:
type: [string, "null"]
data:
$ref: "#/components/schemas/AnyJson"
extracted:
$ref: "#/components/schemas/AnyJson"
error:
$ref: "#/components/schemas/AnyJson"
Event:
type: object
required: [id, eventTime, eventType, entityKind, entityId, isOnchain, payload]
properties:
id:
type: string
eventTime:
type: string
format: date-time
eventType:
type: string
entityKind:
type: string
enum: [node, triple, predicate, artifact]
entityId:
type: string
actorId:
type: [string, "null"]
classificationType:
type: [string, "null"]
isOnchain:
type: boolean
blockNumber:
type: [integer, "null"]
txHash:
type: [string, "null"]
payload:
$ref: "#/components/schemas/AnyJson"
PipelineStats:
type: object
required: [parse, classification, enrichment]
description: Per-stage status counts over public atoms.
properties:
parse:
type: object
additionalProperties:
type: integer
classification:
type: object
additionalProperties:
type: integer
enrichment:
type: object
additionalProperties:
type: integer
Predicate:
type: object
required:
- id
- slug
- label
- description
- isTransitive
- isSymmetric
- isHierarchical
- isSocial
- isMarket
- metadata
- createdAt
- updatedAt
additionalProperties: true
properties:
id:
type: string
slug:
type: string
label:
type: string
description:
type: [string, "null"]
inversePredicateId:
type: [string, "null"]
isTransitive:
type: boolean
isSymmetric:
type: boolean
isHierarchical:
type: boolean
isSocial:
type: boolean
isMarket:
type: boolean
metadata:
$ref: "#/components/schemas/AnyJson"
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
Stats:
type: object
required: [atoms, triples, accounts, predicates]
properties:
atoms:
type: integer
triples:
type: integer
accounts:
type: integer
predicates:
type: integer
CreateAtomResponse:
type: object
required: [data]
properties:
data:
type: object
required: [id, created]
properties:
id:
type: string
created:
type: boolean
createdBy:
type: [string, "null"]
CreateTripleResponse:
$ref: "#/components/schemas/CreateAtomResponse"
KgSchemaMetadata:
type: object
required: [schema, generatedAt, tables]
properties:
schema: