Skip to content

Instantly share code, notes, and snippets.

@fcschmidt
Created December 16, 2019 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcschmidt/ad296a1af7b48a2c744d50e6c31c9510 to your computer and use it in GitHub Desktop.
Save fcschmidt/ad296a1af7b48a2c744d50e6c31c9510 to your computer and use it in GitHub Desktop.
#!/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