|
import requests |
|
import pandas as pd |
|
import gradio as gr |
|
|
|
|
|
API_ENDPOINT = "https://api.example.com/crypto/top-volume/12h" |
|
|
|
def fetch_top_cryptos(): |
|
|
|
|
|
response = requests.get(API_ENDPOINT) |
|
if response.status_code == 200: |
|
data = response.json() |
|
|
|
df = pd.DataFrame(data) |
|
|
|
df = df[['name', 'volume_invested']] |
|
return df |
|
else: |
|
return "Error fetching data" |
|
|
|
|
|
iface = gr.Interface( |
|
fn=fetch_top_cryptos, |
|
inputs=None, |
|
outputs="dataframe", |
|
title="Top Cryptocurrencies by Volume", |
|
description="Shows the top cryptocurrencies by volume invested in the past 12 hours." |
|
) |
|
|
|
|
|
api_key = "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" |
|
|
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|
|
|
|
|