-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindexer-api.yml
More file actions
480 lines (465 loc) · 12.7 KB
/
Copy pathindexer-api.yml
File metadata and controls
480 lines (465 loc) · 12.7 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
openapi: 3.0.3
info:
title: ChainLearn Indexer API
description: |
Read-only API for querying indexed Stellar/Soroban data. The indexer
subscribes to on-chain events and caches them in PostgreSQL for
fast, flexible querying. Data is eventually consistent (typically
under 30 seconds lag).
version: 1.0.0
contact:
name: ChainLearn Team
email: indexer@chainlearn.dev
servers:
- url: https://indexer.chainlearn.dev/v1
description: Production
- url: https://indexer-testnet.chainlearn.dev/v1
description: Testnet
- url: http://localhost:3001/v1
description: Local development
tags:
- name: Tokens
description: LearnToken transfer history and balances
- name: Credentials
description: Credential NFT queries
- name: Progress
description: Enrollment and progress tracking
- name: Events
description: Raw contract event queries
paths:
/tokens/transfers:
get:
tags: [Tokens]
summary: List token transfers
description: Returns indexed LearnToken transfer events.
operationId: listTokenTransfers
parameters:
- name: from
in: query
schema:
type: string
description: Filter by sender address
- name: to
in: query
schema:
type: string
description: Filter by recipient address
- name: from_timestamp
in: query
schema:
type: string
format: date-time
- name: to_timestamp
in: query
schema:
type: string
format: date-time
- name: limit
in: query
schema:
type: integer
default: 50
maximum: 200
- name: cursor
in: query
schema:
type: string
description: Pagination cursor from previous response
responses:
"200":
description: Token transfer list
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/TokenTransfer"
next_cursor:
type: string
nullable: true
/tokens/balances/{address}:
get:
tags: [Tokens]
summary: Get token balance for address
operationId: getTokenBalance
parameters:
- name: address
in: path
required: true
schema:
type: string
description: Stellar address
responses:
"200":
description: Token balance
content:
application/json:
schema:
type: object
properties:
address:
type: string
balance:
type: string
description: LEARN token balance in human-readable units
last_updated:
type: string
format: date-time
/credentials:
get:
tags: [Credentials]
summary: List all credentials
description: Query minted credential NFTs with optional filters.
operationId: listCredentials
parameters:
- name: holder
in: query
schema:
type: string
description: Filter by holder Stellar address
- name: course_id
in: query
schema:
type: string
description: Filter by course identifier
- name: issued_after
in: query
schema:
type: string
format: date-time
- name: limit
in: query
schema:
type: integer
default: 50
- name: cursor
in: query
schema:
type: string
responses:
"200":
description: Credential list
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/IndexedCredential"
next_cursor:
type: string
nullable: true
/credentials/{credentialId}:
get:
tags: [Credentials]
summary: Get credential details
operationId: getIndexedCredential
parameters:
- name: credentialId
in: path
required: true
schema:
type: string
responses:
"200":
description: Credential details
content:
application/json:
schema:
$ref: "#/components/schemas/IndexedCredential"
"404":
description: Credential not found
/credentials/verify/{address}:
get:
tags: [Credentials]
summary: Verify all credentials for an address
description: |
Returns all credentials held by a given address, along with
verification status for each.
operationId: verifyCredentials
parameters:
- name: address
in: path
required: true
schema:
type: string
description: Stellar address to verify
responses:
"200":
description: Verification result
content:
application/json:
schema:
type: object
properties:
address:
type: string
credential_count:
type: integer
credentials:
type: array
items:
allOf:
- $ref: "#/components/schemas/IndexedCredential"
- type: object
properties:
verified:
type: boolean
description: Whether the credential is confirmed on-chain
/progress/enrollments:
get:
tags: [Progress]
summary: List enrollments
operationId: listEnrollments
parameters:
- name: user
in: query
schema:
type: string
description: Filter by user Stellar address
- name: course_id
in: query
schema:
type: string
- name: status
in: query
schema:
type: string
enum: [active, completed]
- name: limit
in: query
schema:
type: integer
default: 50
responses:
"200":
description: Enrollment list
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/IndexedEnrollment"
/progress/enrollments/{enrollmentId}:
get:
tags: [Progress]
summary: Get enrollment details with module progress
operationId: getEnrollmentProgress
parameters:
- name: enrollmentId
in: path
required: true
schema:
type: string
responses:
"200":
description: Enrollment with module completion details
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/IndexedEnrollment"
- type: object
properties:
modules:
type: array
items:
type: object
properties:
module_id:
type: string
title:
type: string
completed:
type: boolean
completed_at:
type: string
format: date-time
nullable: true
/events:
get:
tags: [Events]
summary: Query raw contract events
description: |
Returns indexed Soroban contract events. Useful for debugging,
analytics, and building custom dashboards.
operationId: listEvents
parameters:
- name: contract_id
in: query
schema:
type: string
description: Filter by contract address
- name: event_type
in: query
schema:
type: string
enum: [transfer, mint, enrollment, module_completion, credential_mint]
- name: from_ledger
in: query
schema:
type: integer
- name: to_ledger
in: query
schema:
type: integer
- name: limit
in: query
schema:
type: integer
default: 100
maximum: 500
- name: cursor
in: query
schema:
type: string
responses:
"200":
description: Event list
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/ContractEvent"
next_cursor:
type: string
nullable: true
/stats/overview:
get:
tags: [Tokens]
summary: Platform statistics
description: Aggregate statistics for the ChainLearn platform.
operationId: getPlatformStats
responses:
"200":
description: Platform statistics
content:
application/json:
schema:
type: object
properties:
total_learners:
type: integer
total_enrollments:
type: integer
total_completions:
type: integer
total_tokens_distributed:
type: string
total_credentials_minted:
type: integer
active_courses:
type: integer
last_updated:
type: string
format: date-time
components:
schemas:
TokenTransfer:
type: object
properties:
id:
type: string
from:
type: string
description: Sender Stellar address
to:
type: string
description: Recipient Stellar address
amount:
type: string
description: Transfer amount in human-readable units
tx_hash:
type: string
ledger:
type: integer
timestamp:
type: string
format: date-time
IndexedCredential:
type: object
properties:
id:
type: string
holder:
type: string
description: Stellar address of credential holder
course_id:
type: string
course_title:
type: string
score:
type: number
format: float
metadata_uri:
type: string
format: uri
tx_hash:
type: string
minted_at:
type: string
format: date-time
revoked:
type: boolean
IndexedEnrollment:
type: object
properties:
id:
type: string
user:
type: string
description: Stellar address of learner
course_id:
type: string
status:
type: string
enum: [active, completed]
modules_completed:
type: integer
total_modules:
type: integer
enrolled_at:
type: string
format: date-time
completed_at:
type: string
format: date-time
nullable: true
tx_hash:
type: string
ContractEvent:
type: object
properties:
id:
type: string
contract_id:
type: string
description: Soroban contract address
event_type:
type: string
topics:
type: array
items:
type: string
data:
type: object
description: Parsed event data
ledger:
type: integer
tx_hash:
type: string
timestamp:
type: string
format: date-time