Registry / finance / pyupbit

pyupbit

JSON →
library0.2.34pypypi✓ verified 86d ago

Python wrapper for the Upbit cryptocurrency exchange API. Version 0.2.34, actively maintained. Enables trading, market data retrieval, and account management on Upbit. Release cadence is irregular.

pip install pyupbit
INSTALL
IMPORT
SIG · PYUPBIT
P
pyupbit
financepythonv0.2.34
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Upbit
from pyupbit import Upbit
import pyupbit
Direct import of Upbit class is required for authenticated API calls.
get_ohlcv
from pyupbit import get_ohlcv
import pyupbit as pb; pb.get_ohlcv()
Some functions are top-level and can be imported directly.

Initialize Upbit client with API keys. Keys should be set in environment variables.

import os from pyupbit import Upbit access = os.environ.get('UPBIT_ACCESS_KEY', '') secret = os.environ.get('UPBIT_SECRET_KEY', '') upbit = Upbit(access, secret) # Check balance (returns None if auth fails) print(upbit.get_balance('KRW-BTC'))
Debug
Known issues
gotchaget_ohlcv returns a DataFrame with 'open', 'high', 'low', 'close', 'volume' columns. The index is datetime in UTC. Use `interval` parameter for different timeframes (minute1, minute3, minute5, minute15, minute30, minute60, minute240, day, week, month).
fix
Specify interval as string, e.g., get_ohlcv("KRW-BTC", interval="day").
affects: all
gotchaUpbit API rate limits: 30 requests per second. Exceeding may cause temporary ban.
fix
Implement throttling or use sleep between requests.
affects: all
gotchaThe `buy_limit_order` and `sell_limit_order` methods require price and volume as strings, not floats, to avoid floating-point precision issues.
fix
Pass price and volume as strings, e.g., upbit.buy_limit_order("KRW-BTC", "50000", "0.001").
affects: all
breakingIn version 0.2.25+, the `get_balance` method returns `None` if the market is not found, instead of raising an exception.
fix
Check the return value for None; previously you could rely on exception handling.
affects: >=0.2.25
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyupbit'
Library not installed.
fix
Run 'pip install pyupbit'.
pyupbit.errors.UnauthorizedError: Invalid access key or secret key
API keys are incorrect or expired.
fix
Check your Upbit API keys and regenerate if necessary. Ensure they are set correctly in environment variables.
AttributeError: 'NoneType' object has no attribute 'get'
Calling a method on an API response that returned None, often due to invalid market or rate limit.
fix
Verify the market symbol (e.g., 'KRW-BTC') and that you are not exceeding rate limits.
TypeError: '<' not supported between instances of 'str' and 'float'
Comparing price or volume without converting to proper type.
fix
Ensure you convert strings to float/int when comparing numeric values. Use float() if necessary.
Upgrade
Version history
0.2.34latest on PyPI · released Jun 14, 2024
Audit
Dependencies
requestsrequiredHTTP requests for API calls
pandasoptionalDataFrame output for market data
pyjwtrequiredJWT token generation for authentication
Agent activity
31 hits · last 30 days
node
30
Resources
pyupbit — pip install pyupbit · libregistry