Use Cases & Examples
Spartera powers analytics monetization across industries. These examples show how data providers structure their assets and how buyers consume them.
The snippets below focus on the shape of each asset. For the full create → test → price → publish flow, see the Quickstart Guide and Python Examples. Pricing is always set with a separate call (→ Assets), not inline on the asset body.
Sports Analytics
Sports data is one of Spartera's core verticals. Teams, leagues, broadcasters, and betting platforms all need fast, reliable access to performance data.
NBA Player Efficiency Rating
# Calculation asset — returns a single computed metric
asset_data = {
"asset_type": "CALCULATION",
"name": "NBA Player Efficiency Rating — Current Season",
"description": "Average PER across all players with 20+ games played this season. Uses standard NBA efficiency formula.",
"sql_logic": """
SELECT ROUND(AVG(
(points + rebounds + assists + steals + blocks
- (field_goals_attempted - field_goals_made)
- (free_throws_attempted - free_throws_made)
- turnovers) / games_played
), 2) AS avg_per
FROM nba_player_stats
WHERE season = '2024-25'
AND games_played >= 20
"""
}Top Performers Visualization
Visualization assets are configured with a Plotly viz_spec and a source table — the *src keys reference columns in that table. (The old viz_chart_type / viz_dep_var_col_name fields are no longer used for rendering.) For a top-N bar chart, point the asset at a table or view that already holds one row per player with the metric you're charting.
# Visualization asset — renders a chart
asset_data = {
"asset_type": "VISUALIZATION",
"name": "Top 10 NBA Player Efficiency Ratings",
"description": "Bar chart of the top 10 players by efficiency rating for the current season.",
"source_schema_name": "nba",
"source_table_name": "player_efficiency_summary", # one row per player: player_name, efficiency_rating
"viz_spec": {
"data": [
{
"type": "bar",
"xsrc": "player_name",
"ysrc": "efficiency_rating",
"orientation": "v"
}
],
"layout": {"title": "Top 10 NBA Player Efficiency Ratings"}
},
"viz_data_limit": 10
}Give a bar chart both
xsrcandysrc. A bar with an X column and no Y makes Plotly sum X — fine on a small preview, wrong at full volume. For counts per category, aggregate in a view first (GROUP BY) and chart the count column. → Visualization Spec Reference
Who buys sports analytics on Spartera:
- Sports betting platforms needing real-time performance data
- Fantasy sports applications
- Broadcasters and media companies
- Teams doing competitive analysis
Financial Services
Financial data providers use Spartera to monetize proprietary models and datasets while maintaining strict data residency — no raw transaction data ever leaves the source system.
Credit Risk Snapshot
-- Returns a single risk indicator from a proprietary model
SELECT COUNT(*) AS high_risk_applications
FROM loan_applications
WHERE credit_score < 650
OR debt_to_income_ratio >= 0.50
AND application_date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)Revenue Trend Visualization
-- Returns chart-ready time series; point a visualization asset at this as a view
SELECT
DATE_TRUNC('month', transaction_date) AS month,
SUM(amount_usd) AS total_revenue
FROM transactions
WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH)
GROUP BY month
ORDER BY month ASCA line chart over this view would use a scatter trace with mode: "lines", xsrc: "month", ysrc: "total_revenue". (Plotly has no line trace type — the "Line" chart is a scatter with lines mode. → Visualization Spec Reference)
Who buys financial analytics on Spartera:
- Fintech applications needing benchmarks
- Risk teams at banks and lenders
- Investment platforms doing sector analysis
- Compliance teams monitoring thresholds
E-Commerce & Retail
Customer Lifetime Value
SELECT ROUND(AVG(total_spend), 2) AS avg_clv_12mo
FROM (
SELECT customer_id, SUM(order_value) AS total_spend
FROM orders
WHERE order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH)
AND status = 'completed'
GROUP BY customer_id
)Churn Risk Rate
SELECT
ROUND(
COUNT(CASE WHEN days_since_last_order > 90 THEN 1 END) * 100.0 / COUNT(*),
1
) AS churn_risk_pct
FROM (
SELECT
customer_id,
DATEDIFF(CURRENT_DATE, MAX(order_date)) AS days_since_last_order
FROM orders
GROUP BY customer_id
)Marketing Intelligence
Campaign ROAS by Channel
A bar chart of return on ad spend by channel. The SQL aggregates to one row per channel; the visualization asset points at it and charts channel against roas.
# 1. The aggregating view (one row per channel)
# CREATE VIEW marketing.roas_by_channel AS
# SELECT channel, ROUND(SUM(revenue_attributed) / SUM(ad_spend), 2) AS roas
# FROM marketing_performance
# WHERE campaign_date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)
# GROUP BY channel
# 2. The visualization asset
asset_data = {
"asset_type": "VISUALIZATION",
"name": "30-Day ROAS by Marketing Channel",
"description": "Return on ad spend by channel for the trailing 30 days (paid search, social, display, email).",
"source_schema_name": "marketing",
"source_table_name": "roas_by_channel",
"viz_spec": {
"data": [
{"type": "bar", "xsrc": "channel", "ysrc": "roas", "orientation": "v"}
],
"layout": {"title": "30-Day ROAS by Marketing Channel"}
}
}Healthcare & Life Sciences
Healthcare data is particularly well-suited to Spartera's calculation model — HIPAA compliance is far easier when raw patient data never leaves the originating system and only computed results are shared. (For data-feed endpoints, configure exposed fields carefully to maintain compliance.)
Patient Readmission Risk Indicator
-- Returns aggregate risk signal — no individual patient data exposed
SELECT
ROUND(
SUM(CASE WHEN age > 65 AND comorbidity_count > 3 THEN 1 ELSE 0 END)
* 100.0 / COUNT(*),
1
) AS high_risk_admission_pct
FROM patient_admissions
WHERE admission_date >= DATE_SUB(CURRENT_DATE, INTERVAL 90 DAY)Integration Examples
All consumption examples call POST /companies/{company_id}/assets/{asset_id}/process, which executes an asset and returns its result. → Assets
Python / Data Science
import requests
import pandas as pd
def get_spartera_asset(company_id, asset_id, api_key):
response = requests.post(
f"https://api.spartera.com/companies/{company_id}/assets/{asset_id}/process",
headers={"x-api-key": api_key, "Content-Type": "application/json"}
)
return pd.DataFrame(response.json()["data"])
# Pull churn rate and use it in a model
churn_df = get_spartera_asset(MY_COMPANY_ID, CHURN_ASSET_ID, API_KEY)JavaScript / Node.js
async function executeAsset(companyId, assetId, apiKey, parameters = {}) {
const response = await fetch(
`https://api.spartera.com/companies/${companyId}/assets/${assetId}/process`,
{
method: "POST",
headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
body: JSON.stringify({ parameters })
}
);
const { data } = await response.json();
return data;
}
const stats = await executeAsset(process.env.COMPANY_ID, ASSET_ID,
process.env.SPARTERA_API_KEY,
{ season: "2024-25" });Power BI Integration
# Power BI Python script data source
import requests
import pandas as pd
response = requests.post(
"https://api.spartera.com/companies/{company_id}/assets/{asset_id}/process",
headers={"x-api-key": "your-key", "Content-Type": "application/json"}
)
# Power BI automatically picks up 'dataset' as the output dataframe
dataset = pd.DataFrame(response.json()["data"])AI Agent via SparteraConnect
// Your AI agent can call Spartera assets via MCP
// No extra code needed — SparteraConnect handles the tool exposure
const response = await anthropic.messages.create({
model: "claude-sonnet-4-20250514",
messages: [{ role: "user", content: "What's our churn rate this month?" }],
mcp_servers: [{
type: "url",
url: "https://mcp.spartera.com/your-company-id",
name: "spartera"
}]
});Building for the Marketplace
Regardless of vertical, the highest-performing marketplace assets share these traits:
- Clear, specific names — "30-Day Customer Churn Rate" beats "Churn Metric"
- Detailed descriptions — explain what the number means, not just what it is
- Consistent refresh cadence — buyers trust assets with predictable data freshness
- Reasonable execution time — sub-500ms keeps buyers happy
- Meaningful pricing — price based on the decision the buyer can make with your insight, not your cost to compute it
See More
- Quickstart Guide — Create and publish your first asset end to end
- Python Examples — Runnable helpers for every operation
- Assets — Full asset API reference
- Visualization Spec Reference — Chart configuration
