-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathflowfi.postman_collection.json
More file actions
440 lines (440 loc) · 18.6 KB
/
flowfi.postman_collection.json
File metadata and controls
440 lines (440 loc) · 18.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
{
"info": {
"_postman_id": "7f3e2a1b-4c5d-6e7f-8a9b-0c1d2e3f4a5b",
"name": "FlowFi API",
"description": "Complete API collection for FlowFi — real-time payment streaming on Stellar.\n\n**Before you start:**\n1. Import one of the environment files from the same folder:\n - `local.postman_environment.json` — Docker / manual local setup (port 3001)\n - `test.postman_environment.json` — shared test deployment\n2. Select the imported environment from the top-right dropdown.\n3. Send requests. Variables like `{{baseUrl}}`, `{{senderPublicKey}}`, etc. are resolved automatically.\n\n**Sandbox mode:** Add `X-Sandbox-Mode: true` header or `?sandbox=true` to any request.\n**Swagger UI** (local): http://localhost:3001/api-docs\n**OpenAPI JSON** (local): http://localhost:3001/api-docs.json",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"variable": [
{
"key": "baseUrl",
"value": "http://localhost:3001",
"type": "string",
"description": "Overridden by the active environment file."
}
],
"item": [
{
"name": "Health",
"description": "Liveness and readiness probes.",
"item": [
{
"name": "Root ping",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/",
"host": ["{{baseUrl}}"],
"path": [""]
},
"description": "Simple liveness probe. Returns the plain-text string `FlowFi Backend is running` when the server is up."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "plain",
"header": [{ "key": "Content-Type", "value": "text/plain; charset=utf-8" }],
"body": "FlowFi Backend is running"
}
]
},
{
"name": "Detailed health check",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/health",
"host": ["{{baseUrl}}"],
"path": ["health"]
},
"description": "Returns status, uptime, version, supported API versions, and service health."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"status\": \"healthy\",\n \"timestamp\": \"2024-02-21T14:30:00.000Z\",\n \"uptime\": 3600,\n \"version\": \"1.0.0\",\n \"api\": {\n \"supported\": [\"v1\"],\n \"default\": \"v1\"\n }\n}"
}
]
},
{
"name": "Swagger UI",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/api-docs",
"host": ["{{baseUrl}}"],
"path": ["api-docs"]
},
"description": "Interactive Swagger UI for the FlowFi API. Open in a browser."
},
"response": []
},
{
"name": "OpenAPI JSON spec",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/api-docs.json",
"host": ["{{baseUrl}}"],
"path": ["api-docs.json"]
},
"description": "Raw OpenAPI 3.0 specification in JSON format."
},
"response": []
}
]
},
{
"name": "Streams",
"description": "Payment stream lifecycle management. All endpoints prefixed with `/v1/streams`.",
"item": [
{
"name": "Create stream",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"sender\": \"{{senderPublicKey}}\",\n \"recipient\": \"{{recipientPublicKey}}\",\n \"amount\": 10000,\n \"token\": \"{{tokenAddress}}\",\n \"startTime\": 1708531200,\n \"endTime\": 1711209600\n}",
"options": { "raw": { "language": "json" } }
},
"url": {
"raw": "{{baseUrl}}/v1/streams",
"host": ["{{baseUrl}}"],
"path": ["v1", "streams"]
},
"description": "Creates a new payment stream.\n\n**Required:** `sender`, `recipient`, `amount` (positive), `token`.\n**Optional:** `startTime`, `endTime` (Unix timestamps).\n\nReturns **201 Created** with the stream object. Broadcasts `stream.created` SSE event."
},
"response": [
{
"name": "201 Created",
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"id\": \"uuid\",\n \"streamId\": 1,\n \"sender\": \"GABC...\",\n \"recipient\": \"GDEF...\",\n \"tokenAddress\": \"CBCD...\",\n \"depositedAmount\": \"10000\",\n \"isActive\": true,\n \"startTime\": 1708531200,\n \"createdAt\": \"2024-02-21T14:30:00.000Z\"\n}"
},
{
"name": "400 Validation error",
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"message\": \"Validation failed\",\n \"errors\": [\n { \"code\": \"too_small\", \"path\": [\"sender\"], \"message\": \"Sender address is required\" }\n ]\n}"
}
]
},
{
"name": "List streams",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/streams?sender={{senderPublicKey}}&recipient={{recipientPublicKey}}",
"host": ["{{baseUrl}}"],
"path": ["v1", "streams"],
"query": [
{ "key": "sender", "value": "{{senderPublicKey}}", "description": "Filter by sender address (optional)." },
{ "key": "recipient", "value": "{{recipientPublicKey}}", "description": "Filter by recipient address (optional).", "disabled": true }
]
},
"description": "List all streams, optionally filtered by sender and/or recipient public key."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "[\n {\n \"streamId\": 1,\n \"sender\": \"GABC...\",\n \"recipient\": \"GDEF...\",\n \"isActive\": true\n }\n]"
}
]
},
{
"name": "Get stream by ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/streams/{{streamId}}",
"host": ["{{baseUrl}}"],
"path": ["v1", "streams", "{{streamId}}"]
},
"description": "Get details for a single stream including related events."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"streamId\": 1,\n \"sender\": \"GABC...\",\n \"recipient\": \"GDEF...\",\n \"tokenAddress\": \"CBCD...\",\n \"ratePerSecond\": \"115740\",\n \"depositedAmount\": \"10000\",\n \"withdrawnAmount\": \"0\",\n \"startTime\": 1708531200,\n \"lastUpdateTime\": 1708531200,\n \"isActive\": true,\n \"events\": []\n}"
},
{
"name": "404 Not Found",
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"message\": \"Stream not found\"\n}"
}
]
},
{
"name": "Get stream events",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/streams/{{streamId}}/events",
"host": ["{{baseUrl}}"],
"path": ["v1", "streams", "{{streamId}}", "events"]
},
"description": "Get all indexed on-chain events for a stream (CREATED, TOPPED_UP, WITHDRAWN, CANCELLED, COMPLETED)."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "[\n {\n \"id\": \"uuid\",\n \"streamId\": 1,\n \"eventType\": \"CREATED\",\n \"transactionHash\": \"abc123...\",\n \"ledgerSequence\": 12345,\n \"timestamp\": 1708531200\n }\n]"
}
]
},
{
"name": "Get claimable amount",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/streams/{{streamId}}/claimable",
"host": ["{{baseUrl}}"],
"path": ["v1", "streams", "{{streamId}}", "claimable"],
"query": [
{ "key": "at", "value": "", "description": "Optional Unix timestamp to calculate claimable at a specific time.", "disabled": true }
]
},
"description": "Calculate the actionable claimable amount for a stream. Supports caching."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"streamId\": 1,\n \"claimableAmount\": \"5000\",\n \"actionable\": true,\n \"calculatedAt\": \"2024-02-21T14:30:00.000Z\",\n \"cached\": false\n}"
}
]
}
]
},
{
"name": "Users",
"description": "User registration and profile endpoints. All prefixed with `/v1/users`.",
"item": [
{
"name": "Register wallet",
"request": {
"method": "POST",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\n \"publicKey\": \"{{senderPublicKey}}\"\n}",
"options": { "raw": { "language": "json" } }
},
"url": {
"raw": "{{baseUrl}}/v1/users",
"host": ["{{baseUrl}}"],
"path": ["v1", "users"]
},
"description": "Register a Stellar wallet public key. Returns 201 for new users or 200 if the key already exists."
},
"response": [
{
"name": "201 Created",
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"id\": \"uuid\",\n \"publicKey\": \"GABC...\",\n \"createdAt\": \"2024-02-21T14:30:00.000Z\",\n \"updatedAt\": \"2024-02-21T14:30:00.000Z\"\n}"
}
]
},
{
"name": "Get user by public key",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/users/{{senderPublicKey}}",
"host": ["{{baseUrl}}"],
"path": ["v1", "users", "{{senderPublicKey}}"]
},
"description": "Get a user profile by Stellar public key, including their recent sent and received streams."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"id\": \"uuid\",\n \"publicKey\": \"GABC...\",\n \"sentStreams\": [],\n \"receivedStreams\": []\n}"
},
{
"name": "404 Not Found",
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"message\": \"User not found\"\n}"
}
]
},
{
"name": "Get current user (authenticated)",
"request": {
"method": "GET",
"header": [
{ "key": "Authorization", "value": "Bearer {{authToken}}", "description": "Signed Stellar transaction XDR (SEP-10)." }
],
"url": {
"raw": "{{baseUrl}}/v1/users/me",
"host": ["{{baseUrl}}"],
"path": ["v1", "users", "me"]
},
"description": "Returns the authenticated user based on the signed Stellar transaction in the Authorization header (SEP-10 auth)."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"id\": \"uuid\",\n \"publicKey\": \"GABC...\"\n}"
},
{
"name": "401 Unauthorized",
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"message\": \"Unauthorized\"\n}"
}
]
},
{
"name": "Get user activity events",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/users/{{senderPublicKey}}/events",
"host": ["{{baseUrl}}"],
"path": ["v1", "users", "{{senderPublicKey}}", "events"]
},
"description": "Get all stream events associated with a user (as sender or recipient)."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "[\n {\n \"id\": \"uuid\",\n \"streamId\": 1,\n \"eventType\": \"CREATED\",\n \"timestamp\": 1708531200\n }\n]"
}
]
}
]
},
{
"name": "Events (SSE)",
"description": "Server-Sent Events for real-time stream updates. All prefixed with `/v1/events`.",
"item": [
{
"name": "Subscribe to stream events (SSE)",
"request": {
"method": "GET",
"header": [
{ "key": "Accept", "value": "text/event-stream" },
{ "key": "Cache-Control", "value": "no-cache" }
],
"url": {
"raw": "{{baseUrl}}/v1/events/subscribe?streams={{streamId}}&users={{senderPublicKey}}&all=false",
"host": ["{{baseUrl}}"],
"path": ["v1", "events", "subscribe"],
"query": [
{ "key": "streams", "value": "{{streamId}}", "description": "Stream ID to watch. Repeat for multiple." },
{ "key": "users", "value": "{{senderPublicKey}}", "description": "Public key to watch. Repeat for multiple." },
{ "key": "all", "value": "false", "description": "Set to true to receive all events." }
]
},
"description": "Establishes a persistent SSE connection. Pushes events: `stream.created`, `stream.topped_up`, `stream.withdrawn`, `stream.cancelled`, `stream.completed`.\n\nUse at least one filter: `streams`, `users`, or `all=true`.\n\n**Postman note:** SSE is buffered. Use *Send and Download*, or test with:\n```\ncurl -N --no-buffer '{{baseUrl}}/v1/events/subscribe?all=true'\n```"
},
"response": [
{
"name": "200 SSE stream",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "text",
"header": [
{ "key": "Content-Type", "value": "text/event-stream" },
{ "key": "Cache-Control", "value": "no-cache" },
{ "key": "Connection", "value": "keep-alive" }
],
"body": "data: {\"type\":\"connected\",\"clientId\":\"1708531200-abc123xyz\"}\n\nevent: stream.created\ndata: {\"streamId\":1,\"sender\":\"GABC...\",\"recipient\":\"GDEF...\",\"amount\":10000}\n\n"
},
{
"name": "400 Missing filter",
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"message\": \"Invalid subscription parameters\"\n}"
}
]
},
{
"name": "Get SSE connection stats",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/events/stats",
"host": ["{{baseUrl}}"],
"path": ["v1", "events", "stats"]
},
"description": "Returns the count of active SSE connections and server timestamp."
},
"response": [
{
"name": "200 OK",
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [{ "key": "Content-Type", "value": "application/json; charset=utf-8" }],
"body": "{\n \"activeConnections\": 3,\n \"timestamp\": \"2024-02-21T14:30:00.000Z\"\n}"
}
]
}
]
}
]
}