Skip to main content

Upbit OPEN API Client

Project description

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_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upbit-client-1.3.4.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

upbit_client-1.3.4.0-py2.py3-none-any.whl (14.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file upbit-client-1.3.4.0.tar.gz.

File metadata

  • Download URL: upbit-client-1.3.4.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for upbit-client-1.3.4.0.tar.gz
Algorithm Hash digest
SHA256 725108fd5da0a72ff24bd66668904ed19af380f4f74b54ce589b02152fe68af3
MD5 74848aeb8926053dc45c4b87c694ce46
BLAKE2b-256 71439a42ed962de4b9c4cc9e51fe3692a50f693f3c57a04537194099e3dc90c0

See more details on using hashes here.

Provenance

File details

Details for the file upbit_client-1.3.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for upbit_client-1.3.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fe1502d3168a7d1712b84c624adbb941ca8a2803318bccb2981a57079d672738
MD5 7945c365dc24005b61d09c244be14c0e
BLAKE2b-256 7088b5c7011d266259c9fcdd3e816015253532345fc50770b17f8f7f872227a6

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page