Skip to content

Upbit(업비트) Cryptocurrency Exchange Open API Client of Multi-Programming Language Support

License

Notifications You must be signed in to change notification settings

seunggabi/upbit-client

 
 

Repository files navigation

Upbit Client

Upbit(업비트) Cryptocurrency Exchange API Client

Description

Upbit(업비트) Cryptocurrency Exchange Open API Client of Multi-Programming Language Support

Swagger Generated Support Languages

Install

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

Quick Start

Credentials

mkdir -p ~/.upbit
# vi ~/.upbit/credentials

[default]
access_key = a
secret_key = b

[a]
access_key = c
secret_key = d
client = Upbit() # default
client = Upbit(profile="a")

REST Client

  • Check Your API Keys
# /v1/api_keys

from upbit.client import Upbit

access_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/orders

from upbit.client import Upbit

access_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/orders

from upbit.client import Upbit

access_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 WebSocket

import json
import asyncio

from upbit.websocket import UpbitWebSocket


# Definition async function
async def ticker(sock, payload):
    async with sock as conn:
        await conn.send(payload)
        while True:
            recv = await conn.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

Contributor

deactivate

rm -rf venv

python3 -m venv venv
source venv/bin/activate

pip3 install -r client/python/requirements.txt

About

Upbit(업비트) Cryptocurrency Exchange Open API Client of Multi-Programming Language Support

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 23.9%
  • C# 18.5%
  • Java 15.3%
  • Python 9.0%
  • JavaScript 6.7%
  • Objective-C 4.4%
  • Other 22.2%