triqai 0.2.8 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: Triqai Transaction Enrichment API
4
- version: 1.5.51
4
+ version: 1.5.53
5
5
  description: |
6
6
  The Triqai API provides transaction enrichment capabilities for financial applications.
7
7
 
@@ -12,7 +12,8 @@ info:
12
12
  ## Rate Limiting
13
13
 
14
14
  Per-organization limits use a token bucket (RPS) plus a concurrent in-flight cap.
15
- Headers may include:
15
+ Every `/v1/...` endpoint except `GET /v1` returns these headers once the organization
16
+ rate-limit check has run, including on its 429 responses:
16
17
  - `X-RateLimit-Limit`
17
18
  - `X-RateLimit-Remaining`
18
19
  - `X-RateLimit-Reset`
@@ -20,15 +21,26 @@ info:
20
21
  - `X-RateLimit-Concurrency-Limit`
21
22
  - `X-RateLimit-Concurrency-Remaining`
22
23
 
24
+ `X-RateLimit-Limit` and `X-RateLimit-Remaining` describe the limit named by `X-RateLimit-Scope`.
25
+ On a `concurrency` 429 they carry the concurrent request cap and the free request slots,
26
+ not the per-second bucket.
27
+
28
+ Requests with a missing or malformed API key, and repeated API key lookups from one IP address,
29
+ have their own limits. Their 429 responses send only `Retry-After`.
30
+
23
31
  `Retry-After` is returned in **seconds** on throttled responses.
24
32
 
25
33
  ## Idempotency
26
34
 
27
- You must supply `Idempotency-Key` (or `X-Idempotency-Key`) for enrichment requests so retries preserve billing and persistence identity.
28
- Keys must match `^[a-zA-Z0-9_-]{1,64}$`.
29
- Reusing a key returns `409`:
30
- - `state=completed`: request with this key already finished
31
- - `state=in_progress`: request with this key is still processing (`Retry-After` included)
35
+ `Idempotency-Key` (or `X-Idempotency-Key`) on enrichment requests is optional. It only matters when the same request can be sent more than once: without a key, every request, including a retry, is a new enrichment and is charged. The Node.js SDK sends a key with every enrichment and reuses it on its own retries. To retry across separate calls, or to re-send transactions you have already enriched, send one key per bank transaction, such as your own transaction ID, and reuse it only for that same request.
36
+ Keys must match `^[a-zA-Z0-9_-]{1,64}$` and are scoped to your organization. A key identifies one request: its normalized `title`, `country`, `type` and `options` (including `options.p2p`).
37
+ Reusing a key:
38
+ - Same request, completed: `200` with the stored result and the same `meta.transactionId`. No credit is charged, but the replay counts toward your rate limit and, like any enrichment, can be refused with `402` when no credit is available.
39
+ - Same request, still processing: `409` `DUPLICATE_REQUEST` with `details.state=in_progress` and `Retry-After`.
40
+ - Same request, stored result partial: the request is enriched again and can complete the result. Only the first complete result is charged.
41
+ - Different request: `409` `DUPLICATE_REQUEST` with `details.state=completed` and `details.reason=payload_mismatch`. Nothing is charged and no stored data is returned.
42
+ - If the stored result cannot be read within a few minutes of the original request, a retry may return `409` `DUPLICATE_REQUEST` with `details.state=completed` and no `reason`. Retry shortly.
43
+ After you delete a transaction, its key returns `410`. After the transaction passes your retention period, its key enriches as a new, charged request.
32
44
  contact:
33
45
  name: Triqai Contact
34
46
  url: https://triqai.com/contact
@@ -67,6 +79,8 @@ paths:
67
79
  application/json:
68
80
  schema:
69
81
  $ref: '#/components/schemas/HealthResponse'
82
+ '422':
83
+ $ref: '#/components/responses/ValidationError'
70
84
 
71
85
  /health:
72
86
  get:
@@ -82,6 +96,8 @@ paths:
82
96
  application/json:
83
97
  schema:
84
98
  $ref: '#/components/schemas/HealthResponse'
99
+ '422':
100
+ $ref: '#/components/responses/ValidationError'
85
101
 
86
102
  /v1:
87
103
  get:
@@ -100,6 +116,14 @@ paths:
100
116
  $ref: '#/components/responses/Unauthorized'
101
117
  '403':
102
118
  $ref: '#/components/responses/Forbidden'
119
+ '422':
120
+ $ref: '#/components/responses/ValidationError'
121
+ '429':
122
+ $ref: '#/components/responses/RateLimited'
123
+ '500':
124
+ $ref: '#/components/responses/InternalError'
125
+ '503':
126
+ $ref: '#/components/responses/ServiceUnavailable'
103
127
 
104
128
  /v1/transactions/enrich:
105
129
  post:
@@ -111,8 +135,8 @@ paths:
111
135
  parameters:
112
136
  - name: Idempotency-Key
113
137
  in: header
114
- required: true
115
- description: Required retry identity. `X-Idempotency-Key` is also accepted and must match when both are sent.
138
+ required: false
139
+ description: Optional. One key per bank transaction, used only for that request. A retry of the same request with this key returns the stored result without a charge; a different request with it returns `409` with `details.reason=payload_mismatch`. Without a key, every request is a new, charged enrichment. `X-Idempotency-Key` is also accepted and must match when both are sent.
116
140
  schema:
117
141
  type: string
118
142
  minLength: 1
@@ -219,9 +243,11 @@ paths:
219
243
  - name: page
220
244
  in: query
221
245
  required: false
246
+ description: Page number, at most 10000.
222
247
  schema:
223
248
  type: integer
224
249
  minimum: 1
250
+ maximum: 10000
225
251
  default: 1
226
252
  - name: size
227
253
  in: query
@@ -234,14 +260,14 @@ paths:
234
260
  - name: startDate
235
261
  in: query
236
262
  required: false
237
- description: Inclusive lower bound (ISO 8601 timestamp)
263
+ description: Inclusive lower bound (ISO 8601 date or timestamp between 0001-01-01 and 9999-12-31 UTC).
238
264
  schema:
239
265
  type: string
240
266
  format: date-time
241
267
  - name: endDate
242
268
  in: query
243
269
  required: false
244
- description: Inclusive upper bound (ISO 8601 timestamp)
270
+ description: Inclusive upper bound (ISO 8601 date or timestamp between 0001-01-01 and 9999-12-31 UTC).
245
271
  schema:
246
272
  type: string
247
273
  format: date-time
@@ -262,6 +288,8 @@ paths:
262
288
  $ref: '#/components/responses/RateLimited'
263
289
  '500':
264
290
  $ref: '#/components/responses/InternalError'
291
+ '503':
292
+ $ref: '#/components/responses/ServiceUnavailable'
265
293
 
266
294
  /v1/transactions/{id}:
267
295
  get:
@@ -290,6 +318,8 @@ paths:
290
318
  $ref: '#/components/responses/RateLimited'
291
319
  '500':
292
320
  $ref: '#/components/responses/InternalError'
321
+ '503':
322
+ $ref: '#/components/responses/ServiceUnavailable'
293
323
 
294
324
  delete:
295
325
  tags:
@@ -336,7 +366,7 @@ paths:
336
366
  - name: afterDate
337
367
  in: query
338
368
  required: false
339
- description: Only count transactions created on or after this ISO 8601 timestamp.
369
+ description: Only count transactions created on or after this ISO 8601 date or timestamp (between 0001-01-01 and 9999-12-31 UTC).
340
370
  schema:
341
371
  type: string
342
372
  format: date-time
@@ -357,6 +387,8 @@ paths:
357
387
  $ref: '#/components/responses/RateLimited'
358
388
  '500':
359
389
  $ref: '#/components/responses/InternalError'
390
+ '503':
391
+ $ref: '#/components/responses/ServiceUnavailable'
360
392
 
361
393
  /v1/transactions/batch:
362
394
  delete:
@@ -431,10 +463,14 @@ paths:
431
463
  $ref: '#/components/responses/Unauthorized'
432
464
  '403':
433
465
  $ref: '#/components/responses/Forbidden'
466
+ '422':
467
+ $ref: '#/components/responses/ValidationError'
434
468
  '429':
435
469
  $ref: '#/components/responses/RateLimited'
436
470
  '500':
437
471
  $ref: '#/components/responses/InternalError'
472
+ '503':
473
+ $ref: '#/components/responses/ServiceUnavailable'
438
474
 
439
475
  /v1/banks:
440
476
  get:
@@ -483,6 +519,8 @@ paths:
483
519
  $ref: '#/components/responses/RateLimited'
484
520
  '500':
485
521
  $ref: '#/components/responses/InternalError'
522
+ '503':
523
+ $ref: '#/components/responses/ServiceUnavailable'
486
524
 
487
525
  /v1/banks/{id}:
488
526
  get:
@@ -511,6 +549,8 @@ paths:
511
549
  $ref: '#/components/responses/RateLimited'
512
550
  '500':
513
551
  $ref: '#/components/responses/InternalError'
552
+ '503':
553
+ $ref: '#/components/responses/ServiceUnavailable'
514
554
 
515
555
  /v1/merchants/{id}:
516
556
  get:
@@ -539,6 +579,8 @@ paths:
539
579
  $ref: '#/components/responses/RateLimited'
540
580
  '500':
541
581
  $ref: '#/components/responses/InternalError'
582
+ '503':
583
+ $ref: '#/components/responses/ServiceUnavailable'
542
584
 
543
585
  /v1/locations/{id}:
544
586
  get:
@@ -567,6 +609,8 @@ paths:
567
609
  $ref: '#/components/responses/RateLimited'
568
610
  '500':
569
611
  $ref: '#/components/responses/InternalError'
612
+ '503':
613
+ $ref: '#/components/responses/ServiceUnavailable'
570
614
 
571
615
  /v1/intermediaries/{id}:
572
616
  get:
@@ -595,6 +639,8 @@ paths:
595
639
  $ref: '#/components/responses/RateLimited'
596
640
  '500':
597
641
  $ref: '#/components/responses/InternalError'
642
+ '503':
643
+ $ref: '#/components/responses/ServiceUnavailable'
598
644
 
599
645
  /v1/report-issue:
600
646
  post:
@@ -604,6 +650,7 @@ paths:
604
650
  operationId: createIssueReport
605
651
  requestBody:
606
652
  required: true
653
+ description: The request body must not exceed 32,768 bytes.
607
654
  content:
608
655
  application/json:
609
656
  schema:
@@ -627,6 +674,8 @@ paths:
627
674
  $ref: '#/components/responses/RateLimited'
628
675
  '500':
629
676
  $ref: '#/components/responses/InternalError'
677
+ '503':
678
+ $ref: '#/components/responses/ServiceUnavailable'
630
679
 
631
680
  get:
632
681
  tags:
@@ -637,13 +686,16 @@ paths:
637
686
  - name: page
638
687
  in: query
639
688
  required: false
689
+ description: Page number, at most 10000. Values below 1 are treated as 1.
640
690
  schema:
641
691
  type: integer
642
692
  minimum: 1
693
+ maximum: 10000
643
694
  default: 1
644
695
  - name: size
645
696
  in: query
646
697
  required: false
698
+ description: Page size, at most 100. Larger values are capped at 100 instead of being rejected, and values below 1 are treated as 1.
647
699
  schema:
648
700
  type: integer
649
701
  minimum: 1
@@ -677,6 +729,8 @@ paths:
677
729
  $ref: '#/components/responses/RateLimited'
678
730
  '500':
679
731
  $ref: '#/components/responses/InternalError'
732
+ '503':
733
+ $ref: '#/components/responses/ServiceUnavailable'
680
734
 
681
735
  /v1/report-issue/{id}:
682
736
  get:
@@ -705,6 +759,8 @@ paths:
705
759
  $ref: '#/components/responses/RateLimited'
706
760
  '500':
707
761
  $ref: '#/components/responses/InternalError'
762
+ '503':
763
+ $ref: '#/components/responses/ServiceUnavailable'
708
764
 
709
765
  components:
710
766
  securitySchemes:
@@ -828,6 +884,10 @@ components:
828
884
  state:
829
885
  type: string
830
886
  enum: [in_progress, completed]
887
+ reason:
888
+ type: string
889
+ enum: [payload_mismatch]
890
+ description: Present when the key was already used for a different request (`state=completed`). The stored result is not returned.
831
891
  retryAfterSeconds:
832
892
  type: integer
833
893
  minimum: 1
@@ -1219,6 +1279,10 @@ components:
1219
1279
 
1220
1280
  CategoryStructure:
1221
1281
  type: object
1282
+ description: |
1283
+ Category path from the most specific category up to its top-level category.
1284
+ For example, a parking payment has `primary` Parking, `secondary` Vehicle Services
1285
+ and `tertiary` Transportation.
1222
1286
  required:
1223
1287
  - primary
1224
1288
  - secondary
@@ -1227,11 +1291,14 @@ components:
1227
1291
  properties:
1228
1292
  primary:
1229
1293
  $ref: '#/components/schemas/Category'
1294
+ description: The most specific category assigned.
1230
1295
  secondary:
1296
+ description: Parent of `primary`, or `null` when `primary` is a top-level category.
1231
1297
  oneOf:
1232
1298
  - $ref: '#/components/schemas/Category'
1233
1299
  - type: 'null'
1234
1300
  tertiary:
1301
+ description: Parent of `secondary`, or `null` when the category is fewer than three levels deep.
1235
1302
  oneOf:
1236
1303
  - $ref: '#/components/schemas/Category'
1237
1304
  - type: 'null'
@@ -1484,6 +1551,18 @@ components:
1484
1551
  role:
1485
1552
  type: string
1486
1553
 
1554
+ IntermediaryEntityData:
1555
+ allOf:
1556
+ - $ref: '#/components/schemas/IntermediaryData'
1557
+ - type: object
1558
+ properties:
1559
+ category:
1560
+ $ref: '#/components/schemas/CategoryStructure'
1561
+ description: |
1562
+ Category of a recognized platform, such as a food delivery app. Returned for
1563
+ those platforms on `GET /v1/transactions` and `GET /v1/transactions/{id}`;
1564
+ enrichment responses may omit it. Absent for other intermediaries.
1565
+
1487
1566
  PersonData:
1488
1567
  type: object
1489
1568
  required:
@@ -1493,12 +1572,27 @@ components:
1493
1572
  type: string
1494
1573
 
1495
1574
  EntityResult:
1575
+ description: |
1576
+ An entity linked to the transaction. `type` selects the shape of `data`.
1577
+ oneOf:
1578
+ - $ref: '#/components/schemas/MerchantEntityResult'
1579
+ - $ref: '#/components/schemas/LocationEntityResult'
1580
+ - $ref: '#/components/schemas/IntermediaryEntityResult'
1581
+ - $ref: '#/components/schemas/PersonEntityResult'
1582
+ discriminator:
1583
+ propertyName: type
1584
+ mapping:
1585
+ merchant: '#/components/schemas/MerchantEntityResult'
1586
+ location: '#/components/schemas/LocationEntityResult'
1587
+ intermediary: '#/components/schemas/IntermediaryEntityResult'
1588
+ person: '#/components/schemas/PersonEntityResult'
1589
+
1590
+ EntityResultBase:
1496
1591
  type: object
1497
1592
  required:
1498
1593
  - type
1499
1594
  - role
1500
1595
  - confidence
1501
- - data
1502
1596
  properties:
1503
1597
  type:
1504
1598
  type: string
@@ -1507,12 +1601,71 @@ components:
1507
1601
  type: string
1508
1602
  confidence:
1509
1603
  $ref: '#/components/schemas/ConfidenceWithReasons'
1510
- data:
1511
- oneOf:
1512
- - $ref: '#/components/schemas/MerchantEntityData'
1513
- - $ref: '#/components/schemas/LocationData'
1514
- - $ref: '#/components/schemas/IntermediaryData'
1515
- - $ref: '#/components/schemas/PersonData'
1604
+ reasoning:
1605
+ type: string
1606
+ minLength: 1
1607
+ description: |
1608
+ Short AI-written explanation of why this entity was linked to the transaction.
1609
+ Use it for display or debugging only: the wording varies, so don't parse it.
1610
+ Optional and never `null`. It's returned when a stored explanation exists, for
1611
+ example on `GET /v1/transactions`, `GET /v1/transactions/{id}` and enrichment
1612
+ results reused from an earlier request, and omitted otherwise.
1613
+
1614
+ MerchantEntityResult:
1615
+ allOf:
1616
+ - $ref: '#/components/schemas/EntityResultBase'
1617
+ - type: object
1618
+ required:
1619
+ - type
1620
+ - data
1621
+ properties:
1622
+ type:
1623
+ type: string
1624
+ enum: [merchant]
1625
+ data:
1626
+ $ref: '#/components/schemas/MerchantEntityData'
1627
+
1628
+ LocationEntityResult:
1629
+ allOf:
1630
+ - $ref: '#/components/schemas/EntityResultBase'
1631
+ - type: object
1632
+ required:
1633
+ - type
1634
+ - data
1635
+ properties:
1636
+ type:
1637
+ type: string
1638
+ enum: [location]
1639
+ data:
1640
+ $ref: '#/components/schemas/LocationData'
1641
+
1642
+ IntermediaryEntityResult:
1643
+ allOf:
1644
+ - $ref: '#/components/schemas/EntityResultBase'
1645
+ - type: object
1646
+ required:
1647
+ - type
1648
+ - data
1649
+ properties:
1650
+ type:
1651
+ type: string
1652
+ enum: [intermediary]
1653
+ data:
1654
+ $ref: '#/components/schemas/IntermediaryEntityData'
1655
+
1656
+ PersonEntityResult:
1657
+ allOf:
1658
+ - $ref: '#/components/schemas/EntityResultBase'
1659
+ - type: object
1660
+ required:
1661
+ - type
1662
+ - data
1663
+ properties:
1664
+ type:
1665
+ type: string
1666
+ enum: [person]
1667
+ data:
1668
+ $ref: '#/components/schemas/PersonData'
1516
1669
 
1517
1670
  TransactionData:
1518
1671
  type: object
@@ -2180,7 +2333,9 @@ components:
2180
2333
  version: '1.1.2'
2181
2334
 
2182
2335
  ValidationError:
2183
- description: Request validation failed
2336
+ description: |
2337
+ Request validation failed. Every endpoint returns this for a malformed `Idempotency-Key`
2338
+ or `X-Idempotency-Key` header, or when both headers are sent with different values.
2184
2339
  content:
2185
2340
  application/json:
2186
2341
  schema:
@@ -2235,26 +2390,35 @@ components:
2235
2390
  $ref: '#/components/schemas/DuplicateRequestErrorResponse'
2236
2391
 
2237
2392
  RateLimited:
2238
- description: Rate limit exceeded
2393
+ description: |
2394
+ Rate limit exceeded. Organization limits send the `X-RateLimit-*` headers.
2395
+ Requests with a missing or malformed API key, and repeated API key lookups from
2396
+ one IP address, have separate limits whose 429s send only `Retry-After`, without
2397
+ any `X-RateLimit-*` header.
2239
2398
  headers:
2240
2399
  X-RateLimit-Limit:
2241
2400
  schema:
2242
2401
  type: integer
2243
- description: Requests per second (sustained rate)
2402
+ description: |
2403
+ Limit named by `X-RateLimit-Scope`. For `rps`, the sustained requests per second.
2404
+ For `concurrency`, the maximum concurrent in-flight requests.
2244
2405
  X-RateLimit-Remaining:
2245
2406
  schema:
2246
2407
  type: integer
2247
- description: Current token-bucket capacity available
2408
+ description: |
2409
+ Remaining capacity for the limit named by `X-RateLimit-Scope`. For `rps`, the
2410
+ token-bucket requests left (0 when throttled). For `concurrency`, the free
2411
+ concurrent request slots.
2248
2412
  X-RateLimit-Reset:
2249
2413
  schema:
2250
2414
  type: string
2251
2415
  format: date-time
2252
- description: Timestamp when token bucket refills
2416
+ description: Time when the limit named by `X-RateLimit-Scope` is expected to admit a new request.
2253
2417
  X-RateLimit-Scope:
2254
2418
  schema:
2255
2419
  type: string
2256
2420
  enum: [rps, concurrency]
2257
- description: Active limiting dimension
2421
+ description: Limit that rejected the request.
2258
2422
  X-RateLimit-Concurrency-Limit:
2259
2423
  schema:
2260
2424
  type: integer
@@ -2296,7 +2460,9 @@ components:
2296
2460
  $ref: '#/components/schemas/ErrorResponse'
2297
2461
 
2298
2462
  ServiceUnavailable:
2299
- description: Service temporarily unavailable
2463
+ description: |
2464
+ Service temporarily unavailable, for example when authentication or the rate-limit
2465
+ and credit check can't complete. Retry after `Retry-After` seconds.
2300
2466
  headers:
2301
2467
  Retry-After:
2302
2468
  schema:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triqai",
3
- "version": "0.2.8",
3
+ "version": "0.4.0",
4
4
  "description": "Official TypeScript SDK for the Triqai Transaction Enrichment API",
5
5
  "author": "Triqai <hello@triqai.com>",
6
6
  "license": "MIT",