Unofficial Python SDK for Toss Securities Open API
Project description
tossinvest-openapi for Python
Unofficial sync Python SDK for Toss Securities Open API.
[!NOTE] This package uses only endpoints published in the official Toss Securities Open API documentation. It is not provided, endorsed, or supported by Toss Securities or Viva Republica.
Status
| Area | Status |
|---|---|
| Runtime SDK | Usable, 0.x |
| Transport | Sync-only, requests |
| Typing | py.typed, standard Python typing |
| Runtime validation | Not included |
| Release package | PyPI |
Requirements
- Python 3.12+
- Toss Securities Open API client credentials
Installation
pip install tossinvest-openapi
Quick Start
from tossinvest_openapi import TossInvestClient
with TossInvestClient(
client_id="...",
client_secret="...",
) as client:
accounts = client.get_accounts()
prices = client.get_prices(symbols="005930,AAPL")
print(
{
"account_count": len(accounts),
"price_count": len(prices),
}
)
[!WARNING] Keep
client_secreton the server side. Do not expose it in browsers, mobile apps, public repositories, logs, or crash reports.
Authentication
The SDK handles OAuth2 Client Credentials internally. It issues an access token on the first business API call, caches it in memory, and refreshes it after expiry.
Prefer one TossInvestClient instance per credential set.
Responses
Business methods return the unwrapped result payload by default.
accounts = client.get_accounts()
Use with_response=True when you need the raw envelope or HTTP metadata.
response = client.get_accounts(with_response=True)
print(
{
"account_count": len(response.data),
"status_code": response.response.status_code,
"request_id": response.response.request_id,
}
)
Avoid logging response.raw unless you have reviewed and redacted the payload.
It may contain account data, order data, or other sensitive fields.
Lifecycle
Use a context manager or call close() explicitly.
with TossInvestClient(client_id="...", client_secret="...") as client:
accounts = client.get_accounts()
client = TossInvestClient(client_id="...", client_secret="...")
try:
accounts = client.get_accounts()
finally:
client.close()
Errors
The SDK exposes domain exceptions such as TossInvestAPIError,
TossInvestAuthenticationError, TossInvestRateLimitError,
TossInvestConnectionError, and TossInvestTimeoutError.
from tossinvest_openapi import TossInvestAPIError, TossInvestConnectionError
try:
client.get_accounts()
except TossInvestAPIError as error:
print(error.status_code, error.code, error.request_id)
except TossInvestConnectionError as error:
print(error.cause)
Do not log full error objects or HTTP metadata. They may contain secrets, tokens, account data, or order data.
Orders
Order methods are exposed because they are part of the official OpenAPI
document. They can change real account state. Add explicit user confirmation at
the application layer before calling create_order, modify_order, or
cancel_order.
The SDK does not retry automatically.
Development
From this package directory:
mise run check
From the repository root:
mise run check
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tossinvest_openapi-0.1.0.tar.gz.
File metadata
- Download URL: tossinvest_openapi-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4a4c02c807a8ad01dfbf791f4185516b45b63ee01a55e0d76e0f289a33a9a03
|
|
| MD5 |
63b4d3e608c0f24b8c092d41de711d63
|
|
| BLAKE2b-256 |
cf59fe03470bedc0de3170bdc16c214a03940bc7d1322cf38f26f9e5155c7bc4
|
File details
Details for the file tossinvest_openapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tossinvest_openapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c7b61eb009651c14a7c9a58c4bc4a7d9a83888647126c3b354f8b934964dd2
|
|
| MD5 |
f13605f4467b7d236791b809706eac72
|
|
| BLAKE2b-256 |
37cdcaf5a6232cc064f416112eb4ef82db080d4e06fe3a8b6a90bbad103cca22
|