MCPcopy Create free account
hub / github.com/argotorg/solidity / query_api

Function query_api

scripts/common/rest_api_helpers.py:46–64  ·  view source on GitHub ↗
(url: str, params: Mapping[str, str], headers: dict, debug_requests=False)

Source from the content-addressed store, hash-verified

44
45
46def query_api(url: str, params: Mapping[str, str], headers: dict, debug_requests=False) -> dict:
47 if debug_requests:
48 print(f'REQUEST URL: {url}')
49 if len(params) > 0:
50 print(f'QUERY: {params}')
51
52 response = requests.get(url, params=params, headers=headers, timeout=60)
53 response.raise_for_status()
54
55 if debug_requests:
56 json_response = response.json()
57 print('========== RESPONSE ==========')
58 if json_response is not None:
59 print(json.dumps(json_response, indent=4))
60 else:
61 print(response.content)
62 print('==============================')
63
64 return response.json()
65
66
67def download_file(url: str, target_path: Path, headers: dict, overwrite=False):

Callers 2

pull_requestMethod · 0.85

Calls 2

getMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected