def fetch_market(isDetails=False, limit_info=False): """업비트에서 거래 가능한 마켓 목록 Args: isDetails (bool, optional): True: 상세조회, False: 비 상세조회. Defaults to False. limit_info (bool, optional): True: 요청 수 제한 정보 리턴, False: 요청 수 제한 정보 리턴 받지 않음. Defaults to False. Returns: list, (dict): 마켓 목록 리스트, 요청 제한 정보 딕셔너리 """ url = "https://api.upbit.com/v1/market/all" if isDetails: query_string = {"isDetails": "true"} else: query_string = {"isDetails": "false"} resp = requests.get(url, params=query_string) if resp.status_code == 200: remaining_req = resp.headers.get('Remaining-Req') limit = parse_remaining_req(remaining_req) data = resp.json() if limit_info: return data, limit else: return data else: raise_error(resp.status_code)
def _send_delete_request(url, headers=None, data=None): resp = requests.delete(url, headers=headers, data=data) if resp.status_code == 200: remaining_req = resp.headers.get('Remaining-Req') limit = _parse_remaining_req(remaining_req) contents = resp.json() return contents, limit else: raise_error(resp.status_code)
def _send_get_request(url, headers=None, data=None): resp = requests.get(url, headers=headers, data=data) if HTTP_RESP_CODE_START <= resp.status_code < HTTP_RESP_CODE_END: remaining_req = resp.headers.get('Remaining-Req') limit = _parse_remaining_req(remaining_req) contents = resp.json() return contents, limit else: raise_error(resp)
def _call_public_api(url, **params): """call get type api Args: url (str): REST API url Returns: tuple: (data, req_limit_info) """ resp = requests.get(url, params=params) if resp.status_code == 200: remaining_req = resp.headers.get('Remaining-Req') limit = _parse_remaining_req(remaining_req) data = resp.json() return data, limit else: raise_error(resp.status_code)