Skip to content

Repository files navigation

https://raw.githubusercontent.com/uJhin/upbit-client/main/logo/logo.png

Upbit OPEN API Client

Install

  • pip command
pip install upbit-client
  • git command
git clone https://github.com/uJhin/python-upbit-client.git

Quick Start

REST Client

  • Check Your API Keys
# /v1/api_keysfromupbit.clientimportUpbitaccess_key="Your Access Key"secret_key="Your Secret Key"client=Upbit(access_key, secret_key)
api_keys=client.APIKey.APIKey_info()
print(api_keys['result'])
  • Buy Currency
# /v1/ordersfromupbit.clientimportUpbitaccess_key="Your Access Key"secret_key="Your Secret Key"client=Upbit(access_key, secret_key)
order=client.Order.Order_new(
market='KRW-BTC',
side='bid',
volume='0.1',
price='3000000',
ord_type='limit'
)
print(order['result'])
  • Sell Currency
# /v1/ordersfromupbit.clientimportUpbitaccess_key="Your Access Key"secret_key="Your Secret Key"client=Upbit(access_key, secret_key)
order=client.Order.Order_new(
market='KRW-BTC',
side='ask',
volume='0.1',
price='3000000',
ord_type='limit'
)
print(order['result'])

WebSocket Client

  • Get Real-Time Ticker
# Using WebSocketimportjsonimportasynciofromupbit.websocketimportUpbitWebSocket# Definition async functionasyncdefticker(sock, payload):
asyncwithsockasconn:
awaitconn.send(payload)
whileTrue:
recv=awaitconn.recv()
data=recv.decode('utf8')
result=json.loads(data)
print(result)
sock=UpbitWebSocket()
currencies= ['KRW-BTC', 'KRW-ETH']
type_field=sock.generate_type_field(
type='ticker',
codes=currencies,
)
payload=sock.generate_payload(
type_fields=[type_field]
)
event_loop=asyncio.get_event_loop()
event_loop.run_until_complete( ticker(sock, payload) )

Donation

uJhin's BTC

uJhin's ETH

About

Upbit(업비트) Cryptocurrency Exchange OPEN API Client for Python

Resources

Code of conduct

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages