@bizjaya/finclient 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BizJaya TechLab S/B
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # @bizjaya/finclient
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The official TypeScript SDK for FinCopy's public API, `https://api.fincopy.pro`. Version 0.2.0 uses numeric ACNO account
4
+ paths under `/v1/fxs` and changes the 0.1 API; see the changelog before upgrading.
5
+
6
+ ```sh
7
+ npm install @bizjaya/finclient
8
+ ```
9
+
10
+ ```ts
11
+ import { FinClient } from "@bizjaya/finclient";
12
+
13
+ const fin = new FinClient({ apiKey: process.env.FINCOPY_API_KEY! });
14
+ const accounts = await fin.copy.accounts.list();
15
+ for (const account of accounts.items) console.log(account.Fleet?.Account?.ACNO, account.Fleet?.Account?.Login);
16
+
17
+ // ACNO is in the route; the JSON body contains only trade fields.
18
+ // await fin.copy.orders.make(52014125, { SYM: "EURUSD", ACT: "NEW", OTY: "OP_BUY", LOT: 0.01 });
19
+ ```
20
+
21
+ The client defaults to `https://api.fincopy.pro`. Account-scoped methods take the numeric ACNO, and paged list methods
22
+ return `{ items, paging, ... }`. DTO fields keep the API's PascalCase names.
23
+
24
+ - `copy.accounts`: settings and lifecycle, pairs, symbols, quotes, orders, history, DCA, performance, activity, strategy
25
+ preview and apply, and terminal operations.
26
+ - `copy.orders`: preflight, trade, hedge, modify, cancel and DCA answers.
27
+ - `copy.fx`: lists across every account you can reach (pairs, orders, history, activity, DCA, terminal operations,
28
+ performance window and bars), strategies, signals, alerts, brokers and the event stream.
29
+ - `copy.changes` and `copy.webhooks`: the change feed and webhook setup.
30
+
31
+ ## API key or member session
32
+
33
+ API-key mode is for trusted server-side code. Do not put an API key in browser JavaScript, a mobile app, a public
34
+ repository, or a client-side environment variable.
35
+
36
+ Member session mode sends the signed-in member's `fincopy_member` cookie instead of a key: omit `apiKey` and pass `fetch`.
37
+ A session client defaults to `credentials: "include"`, so in a browser page on a FinCopy site the browser's `fetch` sends
38
+ the cookie. On a server, pass a `fetch` that adds the cookie header.
39
+
40
+ ```ts
41
+ const fin = new FinClient({ fetch: (input, init) => fetch(input, init) });
42
+ const account = await fin.copy.accounts.get(52014125);
43
+ ```
44
+
45
+ The API accepts browser requests only from FinCopy's own sites. Session trade writes pass the member's trade-PIN gate on
46
+ the server. The main entry uses no Node.js built-ins, so it runs in browsers, Node.js 18+, Deno and Bun.
47
+
48
+ ## Results, errors and the stream
49
+
50
+ Trade calls report that an operation was queued; follow the stream, change feed or webhook for its terminal result. Errors
51
+ are raised as `FinApiError` with HTTP status, API code, validation errors, any `Retry-After` value, and an `errorCode` of
52
+ `timeout`, `network`, `rate_limited`, `invalid_response` or `empty_response` when the SDK set one. Retries reuse the same
53
+ `Idempotency-Key`.
54
+
55
+ `copy.fx.stream()` does not reconnect. It ends when the server closes it (about every 30 minutes); a broken connection
56
+ raises a `network` error. Open it again in a loop, waiting a few seconds between attempts.
57
+
58
+ ## Webhooks
59
+
60
+ Webhook verification is server-side and uses Node.js's crypto module, so it has its own entry:
61
+
62
+ ```ts
63
+ import { FinWebhook } from "@bizjaya/finclient/webhook";
64
+
65
+ const valid = FinWebhook.verify(secret, timestampHeader, rawBody, signatureHeader);
66
+ ```
67
+
68
+ See the [FinCopy API docs](https://fincopy.io/docs), the [QuickStart](./examples/QuickStart.ts), and the
69
+ [FinClient source](https://github.com/bizjaya/FinClient).
70
+
71
+ ## Build from source
72
+
73
+ ```sh
74
+ npm ci
75
+ npm run generate:types
76
+ npm run typecheck
77
+ npm test
78
+ npm run build
79
+ ```