Created
December 16, 2019 17:30
-
-
Save fcschmidt/ad296a1af7b48a2c744d50e6c31c9510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
import requests | |
def save_doc(lista): | |
count = 0 | |
with open("exchanges.md", "w") as f: | |
f.write( | |
"|#|Exchange|API Doc URL|Ticker|k-line|Symbols|Notes|\n" \ | |
"|-----|-----|-----|-----|-----|-----|-----|\n" | |
) | |
for item in lista: | |
f.write( | |
f"|{count}|[{item['name']}]({item['exchange_url']})|[api doc]()|-|-|-|-|\n" | |
) | |
count += 1 | |
print("Saved successfully!") | |
def main(): | |
url = "https://min-api.cryptocompare.com/data/exchanges/general" | |
response = requests.get(url) | |
data = response.json()["Data"] | |
items = [obj for obj in data] | |
exchanges = [] | |
for item in items: | |
exchange = { | |
"name": data[item]["Name"], | |
"internal_name": data[item]["InternalName"], | |
"logo_url": f"https://www.cryptocompare.com{data[item]['LogoUrl']}", | |
"exchange_url": data[item]["AffiliateURL"], | |
"country": data[item]["Country"], | |
"description": data[item]["Description"], | |
} | |
exchanges.append(exchange) | |
save_doc(exchanges) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment