toss-openapi-cli 0.1.5 → 0.1.7
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 +394 -0
- package/bin/tosscli.js +2 -0
- package/package.json +10 -7
package/README.md
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# toss-openapi-cli
|
|
2
|
+
|
|
3
|
+
English | [한국어](docs/i18n/README.ko-KR.md) | [简体中文](docs/i18n/README.zh-CN.md) | [日本語](docs/i18n/README.ja-JP.md)
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Install the CLI:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g toss-openapi-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Install the companion agent skill globally:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx skills add finetension/tosscli-skills -g -a universal
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Restart your agent session after installing the skill so the new skill is
|
|
20
|
+
loaded.
|
|
21
|
+
|
|
22
|
+
Then verify the installed CLI:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
tosscli version
|
|
26
|
+
tosscli -v
|
|
27
|
+
tosscli doctor
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`toss-openapi-cli` is an unofficial, public-OpenAPI-only CLI and agent toolkit
|
|
31
|
+
for Toss APIs, starting with the Toss Securities Open API exposed through the
|
|
32
|
+
`invest` namespace.
|
|
33
|
+
|
|
34
|
+
The primary command is `tosscli`. It keeps output structured and predictable so
|
|
35
|
+
it can be used reliably by automation agents, scripts, and terminal users.
|
|
36
|
+
|
|
37
|
+
> [!IMPORTANT]
|
|
38
|
+
> This is not an official Toss or Toss Securities product. It is built against
|
|
39
|
+
> public, documented Open API surfaces and should not be read as endorsed,
|
|
40
|
+
> supported, or maintained by Toss or Toss Securities.
|
|
41
|
+
|
|
42
|
+
> [!NOTE]
|
|
43
|
+
> This project does not reuse browser sessions, automate Toss Securities web
|
|
44
|
+
> login, or call undocumented web-internal APIs. It uses documented API
|
|
45
|
+
> contracts instead of browser or undocumented web-app behavior.
|
|
46
|
+
|
|
47
|
+
## Status
|
|
48
|
+
|
|
49
|
+
This project is in early MVP development. The current implementation focuses on
|
|
50
|
+
the `invest` namespace and maps every operation in the bundled OpenAPI spec at
|
|
51
|
+
`specs/invest/openapi.json`.
|
|
52
|
+
|
|
53
|
+
The CLI is designed to stay predictable for automation and comfortable for
|
|
54
|
+
terminal use:
|
|
55
|
+
|
|
56
|
+
- JSON-first output on stdout.
|
|
57
|
+
- Stable, machine-readable error responses.
|
|
58
|
+
- Stable exit codes.
|
|
59
|
+
- Commands shaped from official API concepts where practical.
|
|
60
|
+
- Order-capable workflows with dry-run support.
|
|
61
|
+
- No fallback to browser-session or undocumented web API clients.
|
|
62
|
+
|
|
63
|
+
See [Roadmap](docs/ROADMAP.md) for planned public preview and agent usage work.
|
|
64
|
+
|
|
65
|
+
## Why Use This
|
|
66
|
+
|
|
67
|
+
`tosscli` provides a local CLI boundary for documented Toss Invest API calls. It
|
|
68
|
+
keeps credentials, token caching, account headers, request construction, and
|
|
69
|
+
output formatting in one predictable tool.
|
|
70
|
+
|
|
71
|
+
Use this project when you want:
|
|
72
|
+
|
|
73
|
+
- A public OpenAPI-only Toss Invest integration path.
|
|
74
|
+
- Agent-readable JSON output and structured JSON errors.
|
|
75
|
+
- A CLI boundary for credentials, token caching, account headers, and order
|
|
76
|
+
request construction.
|
|
77
|
+
- Dry-run order previews before any live order request is sent.
|
|
78
|
+
|
|
79
|
+
This project does not cover Toss Securities web-app features that require
|
|
80
|
+
browser session reuse or undocumented internal APIs.
|
|
81
|
+
|
|
82
|
+
## Build From Source
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
go build -o bin/tosscli ./cmd/tosscli
|
|
86
|
+
./bin/tosscli version
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
During development, you can also run commands directly:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
go run ./cmd/tosscli version
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This repository currently uses Go `1.26.4`.
|
|
96
|
+
|
|
97
|
+
## Alternative Install
|
|
98
|
+
|
|
99
|
+
macOS and Linux can also install from GitHub Releases with the standalone
|
|
100
|
+
installer:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
curl -fsSL https://raw.githubusercontent.com/finetension/toss-openapi-cli/main/install.sh | sh
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
To install a specific version:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
curl -fsSL https://raw.githubusercontent.com/finetension/toss-openapi-cli/main/install.sh | TOSSCLI_VERSION=v0.1.1 sh
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The standalone installer defaults to `~/.local/bin`. If that directory is not
|
|
113
|
+
on `PATH`, follow the printed PATH guidance before running `tosscli`.
|
|
114
|
+
|
|
115
|
+
## Authentication
|
|
116
|
+
|
|
117
|
+
The invest API uses OAuth2 client credentials. Run login and enter the
|
|
118
|
+
credentials interactively:
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
tosscli invest auth login
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
You can also provide the same credential names used by the OpenAPI spec as
|
|
125
|
+
shell environment variables:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
export TOSS_INVEST_CLIENT_ID="..."
|
|
129
|
+
export TOSS_INVEST_CLIENT_SECRET="..."
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Then issue and cache a token without being prompted:
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
tosscli invest auth login
|
|
136
|
+
tosscli invest auth status
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Credentials and cached tokens are stored in the OS keyring when possible.
|
|
140
|
+
`tosscli` reads process environment variables; it does not automatically load
|
|
141
|
+
`.env` files.
|
|
142
|
+
|
|
143
|
+
You can also pass credentials directly:
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
tosscli invest auth login \
|
|
147
|
+
--client-id "$TOSS_INVEST_CLIENT_ID" \
|
|
148
|
+
--client-secret "$TOSS_INVEST_CLIENT_SECRET"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
For non-interactive environments, an access token can be supplied directly:
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
export TOSS_INVEST_ACCESS_TOKEN="..."
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
If login or API calls fail with `access_denied` and `IP address not allowed`,
|
|
158
|
+
check the allowed IP settings for your Toss Open API credentials. The CLI cannot
|
|
159
|
+
override server-side IP restrictions.
|
|
160
|
+
|
|
161
|
+
To check the public IP address visible to external services:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
tosscli doctor --show-ip
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
To add an allowed IP:
|
|
168
|
+
|
|
169
|
+
1. Open <https://www.tossinvest.com>.
|
|
170
|
+
2. Log in.
|
|
171
|
+
3. Click the settings button in the bottom-right corner.
|
|
172
|
+
4. Open the Open API tab.
|
|
173
|
+
5. Click the Add IP button.
|
|
174
|
+
6. Enter the IP address and click Add.
|
|
175
|
+
|
|
176
|
+
## Quick Start
|
|
177
|
+
|
|
178
|
+
Check local readiness:
|
|
179
|
+
|
|
180
|
+
```sh
|
|
181
|
+
tosscli doctor
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`doctor` checks only four things: CLI version, credential availability, token
|
|
185
|
+
availability, and read-only account list access. It does not test order
|
|
186
|
+
execution.
|
|
187
|
+
|
|
188
|
+
Check auth and list accounts:
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
tosscli invest auth status
|
|
192
|
+
tosscli invest account list
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Read market data:
|
|
196
|
+
|
|
197
|
+
```sh
|
|
198
|
+
tosscli invest market-data prices --symbols AAPL
|
|
199
|
+
tosscli invest market-data orderbook --symbol AAPL
|
|
200
|
+
tosscli invest stock-info stocks --symbols AAPL
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Read account state:
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
ACCOUNT_SEQ="123456789"
|
|
207
|
+
|
|
208
|
+
tosscli invest asset holdings --account-seq "$ACCOUNT_SEQ"
|
|
209
|
+
tosscli invest order-info buying-power --account-seq "$ACCOUNT_SEQ" --currency USD
|
|
210
|
+
tosscli invest order-history list --account-seq "$ACCOUNT_SEQ"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Orders
|
|
214
|
+
|
|
215
|
+
Order commands can place, modify, or cancel real orders. Start with `--dry-run`
|
|
216
|
+
to inspect the request without sending it to Toss Invest.
|
|
217
|
+
|
|
218
|
+
```sh
|
|
219
|
+
tosscli invest order create \
|
|
220
|
+
--dry-run \
|
|
221
|
+
--account-seq "$ACCOUNT_SEQ" \
|
|
222
|
+
--symbol AAPL \
|
|
223
|
+
--side BUY \
|
|
224
|
+
--order-type LIMIT \
|
|
225
|
+
--quantity 1 \
|
|
226
|
+
--price 100
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Remove `--dry-run` only when you intend to send the order:
|
|
230
|
+
|
|
231
|
+
```sh
|
|
232
|
+
tosscli invest order create \
|
|
233
|
+
--account-seq "$ACCOUNT_SEQ" \
|
|
234
|
+
--symbol AAPL \
|
|
235
|
+
--side BUY \
|
|
236
|
+
--order-type LIMIT \
|
|
237
|
+
--quantity 1 \
|
|
238
|
+
--price 100
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Modify or cancel an order:
|
|
242
|
+
|
|
243
|
+
```sh
|
|
244
|
+
tosscli invest order modify "$ORDER_ID" \
|
|
245
|
+
--dry-run \
|
|
246
|
+
--account-seq "$ACCOUNT_SEQ" \
|
|
247
|
+
--quantity 1 \
|
|
248
|
+
--price 101
|
|
249
|
+
|
|
250
|
+
tosscli invest order cancel "$ORDER_ID" \
|
|
251
|
+
--dry-run \
|
|
252
|
+
--account-seq "$ACCOUNT_SEQ"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Output Contract
|
|
256
|
+
|
|
257
|
+
Successful commands print formatted JSON to stdout. Where practical, the CLI
|
|
258
|
+
preserves the Toss Invest API response shape instead of wrapping every response
|
|
259
|
+
in a custom envelope.
|
|
260
|
+
|
|
261
|
+
Errors are also JSON:
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"error": {
|
|
266
|
+
"code": "AUTH_CONFIG_ERROR",
|
|
267
|
+
"message": "Toss Invest credentials are not configured",
|
|
268
|
+
"reason": "AUTH_CONFIG_ERROR"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Exit codes:
|
|
274
|
+
|
|
275
|
+
| Code | Meaning |
|
|
276
|
+
| ---: | --- |
|
|
277
|
+
| `0` | Success |
|
|
278
|
+
| `1` | Unexpected CLI error |
|
|
279
|
+
| `2` | Usage error |
|
|
280
|
+
| `3` | Authentication or configuration error |
|
|
281
|
+
| `4` | Toss Invest API error |
|
|
282
|
+
| `5` | Spec or generated-surface error |
|
|
283
|
+
|
|
284
|
+
## Commands
|
|
285
|
+
|
|
286
|
+
Diagnostics:
|
|
287
|
+
|
|
288
|
+
```sh
|
|
289
|
+
tosscli doctor
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Authentication:
|
|
293
|
+
|
|
294
|
+
```sh
|
|
295
|
+
tosscli invest auth login
|
|
296
|
+
tosscli invest auth status
|
|
297
|
+
tosscli invest auth token
|
|
298
|
+
tosscli invest auth logout
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Accounts and assets:
|
|
302
|
+
|
|
303
|
+
```sh
|
|
304
|
+
tosscli invest account list
|
|
305
|
+
tosscli invest asset holdings
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Market data:
|
|
309
|
+
|
|
310
|
+
```sh
|
|
311
|
+
tosscli invest market-data prices
|
|
312
|
+
tosscli invest market-data orderbook
|
|
313
|
+
tosscli invest market-data trades
|
|
314
|
+
tosscli invest market-data price-limits
|
|
315
|
+
tosscli invest market-data candles
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Market and stock information:
|
|
319
|
+
|
|
320
|
+
```sh
|
|
321
|
+
tosscli invest stock-info stocks
|
|
322
|
+
tosscli invest stock-info warnings <symbol>
|
|
323
|
+
tosscli invest market-info exchange-rate
|
|
324
|
+
tosscli invest market-info calendar kr
|
|
325
|
+
tosscli invest market-info calendar us
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Order information and history:
|
|
329
|
+
|
|
330
|
+
```sh
|
|
331
|
+
tosscli invest order-info buying-power
|
|
332
|
+
tosscli invest order-info sellable-quantity
|
|
333
|
+
tosscli invest order-info commissions
|
|
334
|
+
tosscli invest order-history list
|
|
335
|
+
tosscli invest order-history get <orderId>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Order mutations:
|
|
339
|
+
|
|
340
|
+
```sh
|
|
341
|
+
tosscli invest order create
|
|
342
|
+
tosscli invest order modify <orderId>
|
|
343
|
+
tosscli invest order cancel <orderId>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Use `--help` on any command to see required flags:
|
|
347
|
+
|
|
348
|
+
```sh
|
|
349
|
+
tosscli invest order create --help
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## Development
|
|
353
|
+
|
|
354
|
+
Run the test suite:
|
|
355
|
+
|
|
356
|
+
```sh
|
|
357
|
+
go test ./...
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Build the CLI:
|
|
361
|
+
|
|
362
|
+
```sh
|
|
363
|
+
go build -o bin/tosscli ./cmd/tosscli
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Check the release configuration:
|
|
367
|
+
|
|
368
|
+
```sh
|
|
369
|
+
goreleaser check
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Create local snapshot artifacts:
|
|
373
|
+
|
|
374
|
+
```sh
|
|
375
|
+
goreleaser release --snapshot --clean
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Release
|
|
379
|
+
|
|
380
|
+
Public releases are published through GitHub Releases and GoReleaser:
|
|
381
|
+
|
|
382
|
+
- Cross-platform archives for macOS, Linux, and Windows.
|
|
383
|
+
- SHA256 checksums.
|
|
384
|
+
- `install.sh` for macOS/Linux.
|
|
385
|
+
- Windows zip first, with `install.ps1` after manual Windows validation.
|
|
386
|
+
|
|
387
|
+
Homebrew, Scoop, Winget, npm wrappers, signing, and notarization are intentionally
|
|
388
|
+
deferred until the GitHub Releases path is stable.
|
|
389
|
+
|
|
390
|
+
## Disclaimer
|
|
391
|
+
|
|
392
|
+
This project is unofficial and provided as-is. Trading APIs can move real money
|
|
393
|
+
and may create financial loss. Review commands, credentials, account numbers,
|
|
394
|
+
symbols, quantities, prices, and order status before sending mutation requests.
|
package/bin/tosscli.js
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toss-openapi-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Unofficial CLI for public Toss Open APIs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"tosscli": "bin/tosscli.js"
|
|
8
8
|
},
|
|
9
|
-
"files": [
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
10
13
|
"optionalDependencies": {
|
|
11
|
-
"@finetension/tosscli-darwin-arm64": "0.1.
|
|
12
|
-
"@finetension/tosscli-darwin-x64": "0.1.
|
|
13
|
-
"@finetension/tosscli-linux-arm64": "0.1.
|
|
14
|
-
"@finetension/tosscli-linux-x64": "0.1.
|
|
15
|
-
"@finetension/tosscli-win32-x64": "0.1.
|
|
14
|
+
"@finetension/tosscli-darwin-arm64": "0.1.7",
|
|
15
|
+
"@finetension/tosscli-darwin-x64": "0.1.7",
|
|
16
|
+
"@finetension/tosscli-linux-arm64": "0.1.7",
|
|
17
|
+
"@finetension/tosscli-linux-x64": "0.1.7",
|
|
18
|
+
"@finetension/tosscli-win32-x64": "0.1.7"
|
|
16
19
|
},
|
|
17
20
|
"engines": {
|
|
18
21
|
"node": ">=18"
|