alltradingapi 0.0.0-stage → 1.0.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/CHANGELOG.md +37 -0
- package/LICENSE +21 -0
- package/README.md +171 -2
- package/dist/index.cjs +2138 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +686 -0
- package/dist/index.d.ts +686 -0
- package/dist/index.mjs +2053 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-11-21
|
|
9
|
+
|
|
10
|
+
Initial release — the Node/TypeScript sibling of
|
|
11
|
+
[`alltradingapi-python`](https://github.com/alltradingapi/alltradingapi-python).
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `Client` (and `AsyncClient` alias) covering all six v1 endpoints:
|
|
16
|
+
`assets`, `candles`, `history`, `saved`, `screenshot`, `result`
|
|
17
|
+
- Zero-dependency transport on `node:http`/`node:https`: keep-alive pool,
|
|
18
|
+
gzip/deflate decompression, browser-like User-Agent rotation,
|
|
19
|
+
connect + read timeouts, 32 MiB response cap
|
|
20
|
+
- Bounded retries with exponential full-jitter backoff on 429/5xx and
|
|
21
|
+
transient socket errors, honouring `Retry-After`; POST retries at most
|
|
22
|
+
once and only on 5xx
|
|
23
|
+
- Strict client-side parameter validation for every documented endpoint
|
|
24
|
+
parameter (names, types, ranges, enums, boolean serialisation)
|
|
25
|
+
- Typed models: `Asset`, `Candle`, `SavedCandles`, `TradeResult`, `APIObject`
|
|
26
|
+
and the `TradeOutcome` enum
|
|
27
|
+
- Error hierarchy (`ALLError` + 12 subclasses) with redacted URLs, parsed
|
|
28
|
+
payloads and actionable messages
|
|
29
|
+
- Key resolution: per-call → per-product → `default` → constructor →
|
|
30
|
+
`ATA_API_KEY` → `ATA_KEY_<PRODUCT>` environment variables
|
|
31
|
+
- Bearer (default) and query auth modes
|
|
32
|
+
- In-memory TTL cache for the assets endpoint with `refresh` bypass
|
|
33
|
+
- Must-update gate against the npm registry (strict/ask/warn/off policies,
|
|
34
|
+
6 h disk cache, `ATA_UPDATE_POLICY` / `ATA_SKIP_UPDATE` escape hatches)
|
|
35
|
+
- `scan()` fan-out helper with per-asset error isolation
|
|
36
|
+
- 85 tests against a real local HTTP fixture server; dual ESM/CJS build with
|
|
37
|
+
bundled TypeScript declarations
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 All Trading API
|
|
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,172 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://cdn.jsdelivr.net/gh/alltradingapi/alltradingapi-js@v1.0.0/assets/hero.svg" alt="All Trading API" width="100%">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# alltradingapi
|
|
6
|
+
|
|
7
|
+
JavaScript/TypeScript client for the [All Trading API](https://alltradingapi.com) —
|
|
8
|
+
candles, assets, saved candles, candle history, chart images and trade result
|
|
9
|
+
checks for Quotex. The Node sibling of
|
|
10
|
+
[`alltradingapi-python`](https://github.com/alltradingapi/alltradingapi-python).
|
|
11
|
+
|
|
12
|
+
- Zero dependencies — Node built-ins only, ESM + CJS, ships TypeScript types
|
|
13
|
+
- Automatic retries on rate limits and server errors, honouring `Retry-After`
|
|
14
|
+
- Strict client-side parameter validation (saves a round trip)
|
|
15
|
+
- Node 18+
|
|
16
|
+
|
|
17
|
+
| | |
|
|
18
|
+
|---|---|
|
|
19
|
+
| [](https://www.npmjs.com/package/alltradingapi) | [](https://www.npmjs.com/package/alltradingapi) |
|
|
20
|
+
| [](LICENSE) | |
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
npm install alltradingapi
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Get an API key from [alltradingapi.com](https://alltradingapi.com). Each
|
|
29
|
+
endpoint type has its own key. The simplest setup is one default key:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
export ATA_API_KEY=ap_yourkey
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You can also pass keys per product, or per call — see
|
|
36
|
+
[authentication](#authentication).
|
|
37
|
+
|
|
38
|
+
## Quickstart
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
import { Client } from "alltradingapi";
|
|
42
|
+
|
|
43
|
+
const ata = new Client(); // uses ATA_API_KEY
|
|
44
|
+
|
|
45
|
+
const assets = await ata.assets({ onlyOpen: true });
|
|
46
|
+
console.log("open assets:", assets.length);
|
|
47
|
+
|
|
48
|
+
const candles = await ata.candles("EURUSD_otc", { hours: 2, timeframe: "1m" });
|
|
49
|
+
console.log("last close:", candles[candles.length - 1].close);
|
|
50
|
+
|
|
51
|
+
ata.close();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Endpoints
|
|
55
|
+
|
|
56
|
+
| method | endpoint | returns |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `ata.assets()` | `/qx_assets` | list of assets with open state and payouts |
|
|
59
|
+
| `ata.candles(asset)` | `/qx_candles` | current candles (OHLC) |
|
|
60
|
+
| `ata.history(asset)` | `/qx_history` | candle history |
|
|
61
|
+
| `ata.saved(asset)` | `/qx_saved` | saved candles from the archive |
|
|
62
|
+
| `ata.screenshot(asset)` | `/qx_ss_pro_v2` | chart image as PNG bytes |
|
|
63
|
+
| `ata.result(asset, { time, direction })` | `/qx_result` | trade result check |
|
|
64
|
+
|
|
65
|
+
Common options: `timeframe` (`5s`…`4h`), `timezone` (`"-3"`, `"UTC"`,
|
|
66
|
+
`"Asia/Dhaka"`, …), `hours` (1–24), `count` (1–1000 for saved candles).
|
|
67
|
+
Invalid values raise `ValidationError` before any request is sent.
|
|
68
|
+
|
|
69
|
+
## Saving a chart image
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
import { writeFile } from "node:fs/promises";
|
|
73
|
+
|
|
74
|
+
const png = await ata.screenshot("EURUSD_otc", { timeframe: "1m" });
|
|
75
|
+
await writeFile("chart.png", png); // real PNG, 1200x680, returned by the API
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Result check
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
const outcome = await ata.result("EURUSD_otc", { time: "20:00", direction: "call", mtg: 1 });
|
|
82
|
+
console.log(outcome.result); // "win" / "lose" / "refund" / "pending" / ...
|
|
83
|
+
console.log(outcome.won); // true for win / win1 / win2
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Fan-out scan
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
// candles for many assets at once; failures stay per-asset
|
|
90
|
+
const results = await ata.scan(["EURUSD_otc", "GBPUSD_otc", "BRLUSD_otc"], {
|
|
91
|
+
hours: 1,
|
|
92
|
+
concurrency: 3,
|
|
93
|
+
});
|
|
94
|
+
for (const [symbol, value] of Object.entries(results)) {
|
|
95
|
+
if (value instanceof Error) console.log(symbol, "failed");
|
|
96
|
+
else console.log(symbol, value.length, "candles");
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## TypeScript
|
|
101
|
+
|
|
102
|
+
The package ships its own types — no `@types` install needed:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { Client, Candle } from "alltradingapi";
|
|
106
|
+
|
|
107
|
+
const ata = new Client({ apiKey: process.env.ATA_API_KEY });
|
|
108
|
+
const candles: Candle[] = await ata.candles("EURUSD_otc");
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Authentication
|
|
112
|
+
|
|
113
|
+
Keys are sent as a bearer header by default. Resolution order:
|
|
114
|
+
|
|
115
|
+
1. per-call `apiKey` option
|
|
116
|
+
2. `new Client({ keys: { "quotex-quotes": "ap_..." } })`
|
|
117
|
+
3. `new Client({ keys: { default: "ap_..." } })`
|
|
118
|
+
4. `new Client({ apiKey: "ap_..." })`
|
|
119
|
+
5. `ATA_API_KEY` environment variable
|
|
120
|
+
6. per-product `ATA_KEY_QUOTEX_QUOTES`, `ATA_KEY_QUOTEX_ASSETS`, etc.
|
|
121
|
+
|
|
122
|
+
Use `authMode: "query"` if you prefer `?key=` in the URL instead.
|
|
123
|
+
|
|
124
|
+
## Errors and retries
|
|
125
|
+
|
|
126
|
+
429 and 5xx responses are retried automatically with full-jitter backoff,
|
|
127
|
+
honouring `Retry-After`. After the retries are exhausted you get a specific
|
|
128
|
+
error:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
import {
|
|
132
|
+
AuthenticationError, PermissionDeniedError,
|
|
133
|
+
RateLimitError, UpstreamError, ValidationError,
|
|
134
|
+
} from "alltradingapi";
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
const candles = await ata.candles("EURUSD_otc");
|
|
138
|
+
} catch (err) {
|
|
139
|
+
if (err instanceof RateLimitError) console.log("slow down, retry after", err.retryAfter, "s");
|
|
140
|
+
else if (err instanceof ValidationError) console.log("bad parameter:", err.message);
|
|
141
|
+
else if (err instanceof UpstreamError) console.log("feed is down, try again later");
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Every error carries `.status`, `.message`, `.payload` and a redacted `.url`.
|
|
146
|
+
API keys never appear in error text or URLs.
|
|
147
|
+
|
|
148
|
+
## Staying up to date
|
|
149
|
+
|
|
150
|
+
The client checks the npm registry once per process and refuses to run if a
|
|
151
|
+
newer version exists, unless you opt out:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
const ata = new Client({ updatePolicy: "warn" }); // strict (default) | ask | warn | off
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Escape hatches: `ATA_UPDATE_POLICY=off`, `ATA_SKIP_UPDATE=1`,
|
|
158
|
+
`new Client({ allowOutdated: true })`. Check without gating:
|
|
159
|
+
`await ata.checkUpdates(true)`.
|
|
160
|
+
|
|
161
|
+
## More examples
|
|
162
|
+
|
|
163
|
+
See the [examples/](examples/) folder: quickstart, candle history with a
|
|
164
|
+
sparkline, and chart images with async scanning.
|
|
165
|
+
|
|
166
|
+
## License & disclaimer
|
|
167
|
+
|
|
168
|
+
MIT — see [LICENSE](LICENSE). © 2026 All Trading API.
|
|
169
|
+
|
|
170
|
+
Independent, unofficial API. Not affiliated with, endorsed by, or connected
|
|
171
|
+
to Quotex. Trading involves substantial risk. This SDK provides market data
|
|
172
|
+
only — it cannot place trades and is not financial advice.
|