-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathopenapi.yaml
More file actions
931 lines (900 loc) · 26.6 KB
/
Copy pathopenapi.yaml
File metadata and controls
931 lines (900 loc) · 26.6 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
openapi: 3.0.3
info:
title: SmartDrop API
description: |
SmartDrop backend services — price oracle, webhook delivery, health monitoring, and indexing.
This specification covers all current REST endpoints and planned future endpoints.
version: 0.1.0
license:
name: MIT
url: https://opensource.org/licenses/MIT
contact:
name: SmartDrop Labs
url: https://github.com/SmartDropLabs
servers:
- url: http://localhost:4000
description: Local development
- url: https://api.smartdrop.app
description: Production (planned)
security: []
paths:
/health:
get:
operationId: healthCheck
summary: Service health check
description: Returns the current health status of the API server and its Redis connection.
tags:
- Health
responses:
'200':
description: Service is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
status: ok
timestamp: '2026-06-27T12:00:00.000Z'
redis_connected: true
redis_unavailable: false
'503':
description: Service is not healthy
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Service unavailable
message: Redis connection failed
'500':
$ref: '#/components/responses/InternalError'
/api/v1/prices/{asset_code}:
get:
operationId: getAssetPrice
summary: Get asset price
description: |
Returns the current USD price for a Stellar asset.
If no issuer is provided, native asset (XLM) is assumed.
tags:
- Prices
parameters:
- name: asset_code
in: path
required: true
schema:
$ref: '#/components/schemas/AssetCode'
description: Stellar asset code (1–12 uppercase alphanumeric characters)
example: XLM
- name: issuer
in: query
required: false
schema:
$ref: '#/components/schemas/StellarAddress'
description: Stellar issuer public key (G…)
example: GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335AX2OBFLDTQLNUEHRGPTM6RIA
x-rate-limit:
window: 60s
max: 30
responses:
'200':
description: Price data for the requested asset
content:
application/json:
schema:
$ref: '#/components/schemas/PriceResponse'
example:
asset_code: XLM
issuer: null
price_usd: 0.1234
source: stellar_dex
fetched_at: '2026-06-27T12:00:00.000Z'
is_stale: false
stale_warning: null
sources_attempted:
- stellar_dex
- coingecko
redis_unavailable: false
'400':
$ref: '#/components/responses/ValidationError'
'404':
description: Price data is not available for the requested asset
content:
application/json:
schema:
$ref: '#/components/schemas/PriceNotFoundResponse'
example:
error: Price not available
message: 'No price data found for UNKNOWN'
asset_code: UNKNOWN
issuer: null
price_usd: null
source: unavailable
fetched_at: '2026-06-27T12:00:00.000Z'
is_stale: true
stale_warning: 'No price data available from any source'
sources_attempted: []
redis_unavailable: false
'500':
$ref: '#/components/responses/InternalError'
/api/v1/prices/batch:
post:
operationId: batchGetPrices
summary: Get prices for multiple assets (planned)
description: |
**⚠️ Planned — not yet implemented.**
Accepts a list of asset identifiers and returns prices for all of them
in a single request.
tags:
- Prices
x-draft: true
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BatchPriceRequest'
example:
assets:
- asset_code: XLM
issuer: null
- asset_code: USDC
issuer: GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335AX2OBFLDTQLNUEHRGPTM6RIA
- asset_code: BTC
issuer: GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335AX2OBFLDTQLNUEHRGPTM6RIA
responses:
'200':
description: Batch price results
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PriceResponse'
'400':
$ref: '#/components/responses/ValidationError'
'422':
$ref: '#/components/responses/UnprocessableEntity'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/webhooks:
post:
operationId: createWebhookEndpoint
summary: Register a webhook endpoint
description: |
Creates a new webhook endpoint that will receive signed POST requests
when SmartDrop lifecycle events occur.
tags:
- Webhooks
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateWebhookRequest'
example:
url: https://example.com/webhooks/smartdrop
events:
- airdrop.completed
- recipient.claimed
secret: whsec_myverys3cretkey
x-rate-limit:
window: 60s
max: 20
responses:
'201':
description: Webhook endpoint created
content:
application/json:
schema:
$ref: '#/components/schemas/WebhookEndpoint'
example:
id: wh_a1b2c3d4e5f6g7h8
url: https://example.com/webhooks/smartdrop
events:
- airdrop.completed
- recipient.claimed
active: true
secret_preview: whse...key
created_at: '2026-06-27T12:00:00.000Z'
updated_at: '2026-06-27T12:00:00.000Z'
'400':
$ref: '#/components/responses/ValidationError'
'429':
$ref: '#/components/responses/RateLimited'
'500':
$ref: '#/components/responses/InternalError'
get:
operationId: listWebhookEndpoints
summary: List all registered webhook endpoints
description: |
Returns webhook endpoints (secrets are excluded; only a preview is
shown), in the canonical pagination envelope every list endpoint in
this API uses — see `PaginationMeta`.
tags:
- Webhooks
parameters:
- $ref: '#/components/parameters/PageParam'
- $ref: '#/components/parameters/LimitParam'
responses:
'200':
description: Paginated list of webhook endpoints
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/WebhookEndpoint'
pagination:
$ref: '#/components/schemas/PaginationMeta'
example:
data:
- id: wh_a1b2c3d4e5f6g7h8
url: https://example.com/webhooks/smartdrop
events:
- airdrop.completed
active: true
secret_preview: whse...key
created_at: '2026-06-27T12:00:00.000Z'
updated_at: '2026-06-27T12:00:00.000Z'
pagination:
page: 1
limit: 20
total: 1
total_pages: 1
has_next: false
has_prev: false
'500':
$ref: '#/components/responses/InternalError'
/api/v1/webhooks/{id}:
delete:
operationId: deleteWebhookEndpoint
summary: Remove a webhook endpoint
description: Soft-deletes a webhook endpoint by marking it inactive.
tags:
- Webhooks
parameters:
- name: id
in: path
required: true
schema:
$ref: '#/components/schemas/WebhookId'
description: Webhook endpoint ID
example: wh_a1b2c3d4e5f6g7h8
responses:
'200':
description: Webhook endpoint removed
content:
application/json:
schema:
type: object
properties:
deleted:
type: boolean
enum:
- true
webhook:
$ref: '#/components/schemas/WebhookEndpoint'
example:
deleted: true
webhook:
id: wh_a1b2c3d4e5f6g7h8
url: https://example.com/webhooks/smartdrop
events:
- airdrop.completed
active: false
secret_preview: whse...key
created_at: '2026-06-27T12:00:00.000Z'
updated_at: '2026-06-27T12:00:01.000Z'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/webhooks/{id}/test:
post:
operationId: testWebhookEndpoint
summary: Send a test ping to a webhook endpoint
description: |
Queues a test `ping` event delivery to the specified webhook endpoint.
The delivery is processed asynchronously.
tags:
- Webhooks
parameters:
- name: id
in: path
required: true
schema:
$ref: '#/components/schemas/WebhookId'
example: wh_a1b2c3d4e5f6g7h8
x-rate-limit:
window: 60s
max: 10
responses:
'202':
description: Test ping queued for delivery
content:
application/json:
schema:
type: object
properties:
delivery:
$ref: '#/components/schemas/WebhookDelivery'
example:
delivery:
id: dlv_x1y2z3
endpoint_id: wh_a1b2c3d4e5f6g7h8
event: ping
payload:
event: ping
timestamp: '2026-06-27T12:00:00.000Z'
status: pending
attempt_count: 0
attempts: []
next_retry_at: null
created_at: '2026-06-27T12:00:00.000Z'
updated_at: '2026-06-27T12:00:00.000Z'
'404':
$ref: '#/components/responses/NotFound'
'429':
$ref: '#/components/responses/RateLimited'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/indexer/status:
get:
operationId: getIndexerStatus
summary: Indexer service status (planned)
description: |
**⚠️ Planned — not yet implemented.**
Returns the current status and ledger height of the on-chain indexer service.
tags:
- Indexer
x-draft: true
responses:
'200':
description: Indexer status
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum:
- syncing
- synced
- error
current_ledger:
type: integer
latest_ledger:
type: integer
last_indexed_at:
type: string
format: date-time
example:
status: synced
current_ledger: 52489123
latest_ledger: 52489123
last_indexed_at: '2026-06-27T12:00:00.000Z'
'503':
description: Indexer is not responding
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Indexer unavailable
message: Indexer service is not responding
'500':
$ref: '#/components/responses/InternalError'
/ws:
get:
operationId: websocketEndpoint
summary: Real-time event stream (planned)
description: |
**⚠️ Planned — not yet implemented.**
WebSocket endpoint for streaming real-time SmartDrop events
(price updates, airdrop status changes, webhook delivery logs).
tags:
- WebSocket
x-draft: true
x-websocket: true
responses:
'101':
description: WebSocket protocol upgrade (future)
'400':
$ref: '#/components/responses/ValidationError'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: |
API key authentication. Provide your API key as a Bearer token in the
`Authorization` header. Keys are created via `POST /api/v1/keys` and
can be scoped to specific resources.
parameters:
PageParam:
name: page
in: query
required: false
schema:
type: integer
minimum: 1
default: 1
description: 1-indexed page number.
LimitParam:
name: limit
in: query
required: false
schema:
type: integer
minimum: 1
maximum: 100
default: 20
description: Results per page (max 100).
schemas:
StellarAddress:
type: string
pattern: ^G[A-Z0-9]{55}$
description: Stellar public key (ed25519) starting with G
example: GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335AX2OBFLDTQLNUEHRGPTM6RIA
StellarAddressNullable:
type: string
nullable: true
pattern: ^G[A-Z0-9]{55}$
description: Stellar public key (ed25519) starting with G, or null for native assets
example: GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335AX2OBFLDTQLNUEHRGPTM6RIA
AssetCode:
type: string
minLength: 1
maxLength: 12
pattern: ^[A-Z0-9]+$
description: Stellar asset code (1–12 uppercase alphanumeric)
example: USDC
WebhookId:
type: string
pattern: ^wh_
description: Webhook endpoint ID (prefixed with `wh_`)
example: wh_a1b2c3d4e5f6g7h8
PaginationMeta:
type: object
description: |
The canonical pagination envelope every list endpoint in this API
returns (see the README's "Pagination" section) — `GET
/api/v1/webhooks`, `/airdrops`, `/airdrops/:id/recipients`,
`/alerts`, `/airdrops/:id/onchain-recipients`, and
`/recipients/:address/claims`. `GET /api/v1/webhooks/:id/deliveries`
is intentionally exempt (limit-only, no page/offset concept).
properties:
page:
type: integer
example: 1
limit:
type: integer
example: 20
total:
type: integer
example: 42
total_pages:
type: integer
example: 3
has_next:
type: boolean
example: true
has_prev:
type: boolean
example: false
required:
- page
- limit
- total
- total_pages
- has_next
- has_prev
HealthResponse:
type: object
properties:
status:
type: string
enum:
- ok
- degraded
description: Service health status
timestamp:
type: string
format: date-time
description: Current server time in ISO 8601
redis_connected:
type: boolean
description: Whether Redis is connected
redis_unavailable:
type: boolean
description: Inverse of redis_connected (for legacy monitoring)
price_source_circuits:
type: array
description: Circuit-breaker state for each price source with a nonRetryable failure mode (e.g. an invalid API key)
items:
type: object
properties:
source:
type: string
description: Price source name (e.g. coingecko, coinmarketcap)
open:
type: boolean
description: Whether this source is currently circuit-broken and being skipped
openUntil:
type: string
format: date-time
nullable: true
description: When the circuit will next allow a retry, or null if closed
required:
- status
- timestamp
- redis_connected
- redis_unavailable
PriceResponse:
type: object
properties:
asset_code:
$ref: '#/components/schemas/AssetCode'
issuer:
$ref: '#/components/schemas/StellarAddressNullable'
price_usd:
type: number
nullable: true
description: Current USD price (null if unavailable)
source:
type: string
enum:
- stellar_dex
- coingecko
- coinmarketcap
- aggregated
- unavailable
description: Primary data source
fetched_at:
type: string
format: date-time
description: When the price was last fetched
is_stale:
type: boolean
description: Whether the cached price exceeds the stale threshold
stale_warning:
type: string
nullable: true
description: Human-readable stale warning message
sources_attempted:
type: array
items:
type: string
description: List of data sources that were queried
redis_unavailable:
type: boolean
description: Whether Redis was unavailable during this request
required:
- asset_code
- issuer
- price_usd
- source
- fetched_at
- is_stale
- stale_warning
- sources_attempted
- redis_unavailable
PriceNotFoundResponse:
allOf:
- $ref: '#/components/schemas/ErrorResponse'
- type: object
properties:
asset_code:
$ref: '#/components/schemas/AssetCode'
issuer:
$ref: '#/components/schemas/StellarAddressNullable'
price_usd:
type: number
nullable: true
source:
type: string
example: unavailable
fetched_at:
type: string
format: date-time
is_stale:
type: boolean
example: true
stale_warning:
type: string
sources_attempted:
type: array
items:
type: string
redis_unavailable:
type: boolean
BatchPriceRequest:
type: object
properties:
assets:
type: array
minItems: 1
maxItems: 100
items:
type: object
properties:
asset_code:
$ref: '#/components/schemas/AssetCode'
issuer:
$ref: '#/components/schemas/StellarAddressNullable'
required:
- asset_code
required:
- assets
CreateWebhookRequest:
type: object
properties:
url:
type: string
format: uri
description: Subscriber endpoint URL (HTTP or HTTPS)
example: https://example.com/webhooks/smartdrop
events:
type: array
minItems: 1
items:
$ref: '#/components/schemas/WebhookEvent'
description: Events the endpoint wishes to subscribe to
secret:
type: string
minLength: 8
description: Shared secret used for HMAC-SHA256 signature verification
example: whsec_myverys3cretkey
required:
- url
- events
- secret
WebhookEndpoint:
type: object
properties:
id:
$ref: '#/components/schemas/WebhookId'
url:
type: string
format: uri
events:
type: array
items:
$ref: '#/components/schemas/WebhookEvent'
active:
type: boolean
description: Whether the endpoint is currently active
secret_preview:
type: string
nullable: true
description: First 4 and last 4 characters of the secret
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
required:
- id
- url
- events
- active
- secret_preview
- created_at
- updated_at
WebhookEvent:
type: string
enum:
- airdrop.created
- airdrop.executing
- airdrop.completed
- airdrop.failed
- recipient.claimed
- ping
description: SmartDrop lifecycle events
WebhookDelivery:
type: object
properties:
id:
type: string
pattern: ^dlv_
endpoint_id:
$ref: '#/components/schemas/WebhookId'
event:
$ref: '#/components/schemas/WebhookEvent'
payload:
type: object
status:
type: string
enum:
- pending
- delivered
- failed
- dead_letter
attempt_count:
type: integer
minimum: 0
attempts:
type: array
items:
$ref: '#/components/schemas/DeliveryAttempt'
next_retry_at:
type: string
format: date-time
nullable: true
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
required:
- id
- endpoint_id
- event
- payload
- status
- attempt_count
- attempts
- created_at
- updated_at
DeliveryAttempt:
type: object
properties:
attempt:
type: integer
description: Attempt number (1-based)
ok:
type: boolean
status:
type: string
enum:
- delivered
- failed
response_code:
type: integer
nullable: true
error:
type: string
nullable: true
duration_ms:
type: integer
nullable: true
created_at:
type: string
format: date-time
next_retry_at:
type: string
format: date-time
nullable: true
required:
- attempt
- ok
- status
- response_code
- error
- duration_ms
- created_at
- next_retry_at
ErrorResponse:
type: object
properties:
error:
type: string
description: Machine-readable error type
message:
type: string
description: Human-readable error description
required:
- error
- message
ValidationErrorDetail:
type: object
properties:
error:
type: string
example: Validation error
message:
type: string
example: url must be a valid HTTP or HTTPS URL
details:
type: array
items:
type: object
properties:
field:
type: string
issue:
type: string
required:
- error
- message
RateLimitInfo:
type: object
properties:
error:
type: string
example: Too many requests
message:
type: string
example: Rate limit exceeded. Try again in 42 seconds.
retry_after_seconds:
type: integer
required:
- error
- message
responses:
ValidationError:
description: Request validation failed
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorDetail'
Unauthorized:
description: Missing or invalid authentication
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Missing or invalid API key
message: Missing or invalid API key
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Webhook endpoint not found
message: Webhook endpoint not found
UnprocessableEntity:
description: Request body is semantically invalid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Unprocessable entity
message: One or more field values are invalid
RateLimited:
description: Rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/RateLimitInfo'
example:
error: Too many requests
message: Rate limit exceeded. Try again in 42 seconds.
retry_after_seconds: 42
headers:
Retry-After:
schema:
type: integer
description: Seconds to wait before retrying
X-RateLimit-Limit:
schema:
type: integer
description: Maximum requests per window
X-RateLimit-Remaining:
schema:
type: integer
description: Remaining requests in current window
X-RateLimit-Reset:
schema:
type: integer
description: Unix timestamp when the window resets
InternalError:
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Internal server error
message: An unexpected error occurred