@distyra/sdk 0.3.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.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # @distyra/sdk
2
+
3
+ TypeScript client for the [Distyra](https://distyra.com) Transaction Enrichment & SME Underwriting API.
4
+
5
+ Type-safe by construction: the types are generated from the same committed OpenAPI spec that powers the API and the public reference, so requests and responses never drift from the live API.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i @distyra/sdk
11
+ ```
12
+
13
+ Node 20+. The package ships ESM + CommonJS types and depends only on [`openapi-fetch`](https://www.npmjs.com/package/openapi-fetch).
14
+
15
+ ## Quickstart
16
+
17
+ Get a free sandbox key (10,000 calls/month, no card) at [distyra.com](https://distyra.com).
18
+
19
+ ```ts
20
+ import { createDistyraClient } from '@distyra/sdk';
21
+
22
+ const distyra = createDistyraClient({ apiKey: process.env.DISTYRA_KEY! });
23
+
24
+ const { data, error } = await distyra.POST('/v1/enrich', {
25
+ body: {
26
+ descriptor: 'CARREFOUR MARKET 75011 PARIS FR 14/03',
27
+ amount: -23.47,
28
+ currency: 'EUR',
29
+ country_hint: 'FR',
30
+ mcc: '5411',
31
+ },
32
+ });
33
+
34
+ if (error) {
35
+ // `{ error, detail? }` envelope on 4xx/5xx
36
+ throw new Error(error.detail ?? error.error);
37
+ }
38
+
39
+ // `data` is fully typed against the EnrichResponse schema
40
+ console.log(data.merchant.name, data.category.primary);
41
+ ```
42
+
43
+ ## Options
44
+
45
+ `createDistyraClient(options)`:
46
+
47
+ | Option | Type | Default | Notes |
48
+ |---|---|---|---|
49
+ | `apiKey` | `string` | — | **Required.** Your API key (`sk_…`). |
50
+ | `baseUrl` | `string` | `https://api.distyra.com` | Override for local dev / staging. |
51
+ | `headers` | `Record<string, string>` | — | Extra headers merged on every request. |
52
+
53
+ The returned client is a typed [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) client — use `.GET`, `.POST`, etc. against any path in the spec, with full request/response typing.
54
+
55
+ ## Lower-level access
56
+
57
+ The generated `paths` and `operations` types are re-exported if you want to build your own `openapi-fetch` client or reference response shapes directly:
58
+
59
+ ```ts
60
+ import type { operations } from '@distyra/sdk';
61
+
62
+ type EnrichResponse =
63
+ operations['enrichSingle']['responses']['200']['content']['application/json'];
64
+ ```
65
+
66
+ ## Reference
67
+
68
+ Full API reference (every endpoint, live parameters, response schemas): <https://api.distyra.com/docs>
69
+
70
+ ## License
71
+
72
+ MIT