Launch a shareable Gradio interface for live prediction market consensus โ sport picker, live data, and public sharing via Hugging Face Spaces.
Connect Gradio to Meridian Edge to build a shareable demo of real-time prediction market consensus from 25+ regulated sources. Deploy to Hugging Face Spaces in one command.
pip install gradio requestsimport gradio as gr
import requests
import pandas as pd
API_KEY = "me_live_YOUR_KEY"
def fetch_consensus(sport: str) -> pd.DataFrame:
r = requests.get(
"https://meridianedge.io/api/v1/consensus",
headers={"X-API-Key": API_KEY},
params={"sport": sport, "limit": 15}
)
events = r.json().get("events", [])
if not events:
return pd.DataFrame({"Message": ["No events found"]})
df = pd.DataFrame(events)
df["Consensus"] = (df["consensus_prob"] * 100).round(1).astype(str) + "%"
df["Divergence"] = (df.get("divergence_pct", 0) * 100).round(1).astype(str) + "%"
return df[["title","Consensus","Divergence","market_count"]].rename(
columns={"title":"Event","market_count":"Markets"})
with gr.Blocks(title="Prediction Market Consensus") as demo:
gr.Markdown("## ๐ Prediction Market Consensus\n*meridianedge.io โ Not investment advice*")
sport_dd = gr.Dropdown(["NBA","NHL","MLB","MLS"], value="NBA", label="Sport")
out = gr.DataFrame(label="Live Consensus Data")
btn = gr.Button("Fetch Consensus", variant="primary")
btn.click(fetch_consensus, inputs=sport_dd, outputs=out)
demo.launch(share=True) # share=True for public URLGet your API key and launch this Gradio demo locally or deploy to Hugging Face Spaces in minutes.
View Plans → API Reference