pizzaplanet

Binance rest-api 이용해보기 본문

Univ./Trading Program Project

Binance rest-api 이용해보기

scio 2018. 3. 13. 17:15


Binance API를 이용하여 Market Data를 가져와보자


Binance official api docs 를 참조!


우선 Binance API는 크게 아래와 같이 나뉘어져 있다.


NameDescription
rest-api.mdDetails on the Rest API (/api)
errors.mdDescriptions of possible error messages from the Rest API
web-socket-streams.mdDetails on available streams and payloads
user-data-stream.mdDetails on the dedicated account stream
wapi-api.mdDetails on the Withdrawal API (/wapi)


가져올 수 있는 데이터가 public type인지 private type로 나눌 수 있다.

예로 public type는 현재 비트코인이 얼마인지, private type는 내 지갑을 조회하는 것. 등이다.

private type를 이용하기 위해서는 api key를 발급받아야 한다. 어려운게 아니니 따로 서술하지 않겠다.


저 중에서 rest api를 먼저 이용해 볼텐데 api는 get, post 방식으로 나눌 수 있다.

 [ Get 방식과 Post 방식의 차이 및 장단점 ]


우선 아래의 코드만 본다면 get 방식의 api는 모두 이용할 수 있을 것이다.


1
2
3
4
5
6
7
8
9
10
11
12
import requests
import pprint
 
ep='https://api.binance.com'
ping='/api/v1/ping'
ticker24h='/api/v1/ticker/24hr'
params = {'symbol''BTCUSDT'}
 
r1=requests.get(ep+ping)
r2 = requests.get(ep+ticker24h, params=params) #use parameter
pprint.pprint(r1.json())
pprint.pprint(r2.json())
cs


'Univ. > Trading Program Project' 카테고리의 다른 글

바이낸스 과거 캔들 가져오기  (2) 2018.04.18
바이낸스 실시간 tick 가져오기  (4) 2018.04.18
팀 분배 및 팀 이슈  (0) 2018.03.13
Server ssh, ftp setting  (2) 2018.03.10
SERVER 구입기  (0) 2018.02.08
Comments