Skip to main content

tossinvest-openapi for Python

Unofficial sync Python SDK for Toss Securities Open API.

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),
    }
)

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

Metadata

Release files for tossinvest-openapi 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tossinvest-openapi 0.1.0
File Size Uploaded
tossinvest_openapi-0.1.0.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tossinvest-openapi 0.1.0
File Interpreter ABI Platform
tossinvest_openapi-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / tossinvest_openapi-0.1.0.tar.gz

Download URL tossinvest_openapi-0.1.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a4a4c02c807a8ad01dfbf791f4185516b45b63ee01a55e0d76e0f289a33a9a03
BLAKE2b-256 checksum
How to use checksums
cf59fe03470bedc0de3170bdc16c214a03940bc7d1322cf38f26f9e5155c7bc4
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / tossinvest_openapi-0.1.0-py3-none-any.whl

Download URL tossinvest_openapi-0.1.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64c7b61eb009651c14a7c9a58c4bc4a7d9a83888647126c3b354f8b934964dd2
BLAKE2b-256 checksum
How to use checksums
37cdcaf5a6232cc064f416112eb4ef82db080d4e06fe3a8b6a90bbad103cca22
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page