MindsDB Integration

Purple Flea for MindsDB

MindsDB turns your database into an AI agent. Combined with Purple Flea's financial APIs, you can write SQL queries that trigger real crypto trades, check wallet balances, and execute escrow payments — all from your data layer.

Get Your API Key → View API Docs

How MindsDB + Purple Flea Works

MindsDB is an AI-powered database layer that understands natural language, runs machine learning models, and connects to external services through its engine abstraction. Its HTTP engine lets you map any REST API as a virtual database table — meaning you can SELECT from and INSERT into Purple Flea as if it were a relational database.

The combination is powerful: MindsDB's LLM functions can analyze market sentiment from text, predict price movements from historical data, and immediately pass those signals to Purple Flea's trading and casino APIs — all within a single SQL workflow.

1

Create a MindsDB LLM function or predictor

Use MindsDB's CREATE MODEL statement to define a prediction model or connect an LLM like GPT-4 or Claude. This becomes your AI decision layer — analyzing price feeds, sentiment data, and position sizing signals before any trade executes.

2

Add Purple Flea via MindsDB's HTTP engine

Register Purple Flea's REST API as a MindsDB database using CREATE DATABASE with ENGINE = 'http'. This exposes every Purple Flea endpoint — markets, trades, wallet, escrow — as queryable tables in your MindsDB environment.

3

Query your database and trigger financial actions

Write SQL that joins your prediction model with Purple Flea's live market data. When the AI signal crosses your threshold, an INSERT into the trade table executes the position in real time. No glue code. No separate orchestration layer. Pure SQL from intelligence to execution.

SQL
Only language required
6
Purple Flea services
275
Perpetual markets
7
Supported chains

SQL-Driven Trading with MindsDB

Below is a complete MindsDB SQL workflow: create the Purple Flea HTTP integration, query live market prices, run an LLM sentiment analysis, and execute a trade — all in SQL. No Python orchestration needed.

SQL — MindsDB + Purple Flea integration
-- Step 1: Register Purple Flea as an HTTP database in MindsDB
CREATE DATABASE purple_flea_api
WITH ENGINE = 'http',
PARAMETERS = {
  "base_url": "https://purpleflea.com/api/v1",
  "headers": {"Authorization": "Bearer your-api-key"}
};

-- Step 2: Query live market price
SELECT symbol, price, change_24h, volume_24h
FROM purple_flea_api.markets
WHERE symbol = 'BTC-PERP';

-- Step 3: Create an LLM model for sentiment analysis
CREATE MODEL market_sentiment
PREDICT sentiment_score
USING
  engine = 'openai',
  model_name = 'gpt-4',
  prompt_template = 'Rate the bullishness of this crypto market data
    on a scale from -1.0 (very bearish) to 1.0 (very bullish).
    Data: {{market_data}}
    Return only the numeric score.';

-- Step 4: Join live market data with AI sentiment
SELECT
  m.symbol,
  m.price,
  m.change_24h,
  s.sentiment_score
FROM purple_flea_api.markets AS m
JOIN market_sentiment AS s
WHERE m.symbol = 'BTC-PERP';

-- Step 5: Execute trade when sentiment is strongly bullish
-- (Run via MindsDB job scheduler or trigger)
INSERT INTO purple_flea_api.trade (symbol, side, size_usd, leverage)
SELECT
  'BTC-PERP',
  'long',
  100,
  5
WHERE (SELECT sentiment_score FROM market_sentiment
        WHERE market_data = 'BTC 24h change: +4.2%, volume spike: 180%'
       ) > 0.7;

-- Step 6: Check wallet balance
SELECT token, balance, usd_value
FROM purple_flea_api.wallet
WHERE chain = 'ethereum';

-- Step 7: Create an automated job that runs every 15 minutes
CREATE JOB btc_sentiment_trader
START '2026-03-07'
EVERY 15 minutes
DO (
  INSERT INTO purple_flea_api.trade (symbol, side, size_usd)
  SELECT 'BTC-PERP', 'long', 50
  FROM market_sentiment
  WHERE market_data = (SELECT CONCAT(symbol, ' price: ', price) FROM purple_flea_api.markets WHERE symbol = 'BTC-PERP')
    AND sentiment_score > 0.65
);

AI + Financial Actions

MindsDB's AI layer connects seamlessly to Purple Flea's execution layer. Each prediction output maps to a specific financial action — no glue code, no separate orchestration service.

🧠

LLM predicts market sentiment → triggers trade

Feed news articles, social data, or on-chain metrics into a MindsDB LLM function. When sentiment crosses a threshold, an INSERT into purple_flea_api.trade opens a real position on Hyperliquid's perpetuals market.

📈

Anomaly detection in price data → exits position

Train a MindsDB anomaly model on historical price data. When a statistically unusual price movement is detected — a flash crash, liquidity spike, or wick — automatically close your position via Purple Flea's trading API before the move fully develops.

📊

Pattern matching in historical data → opens new position

Use MindsDB's time-series forecasting to identify recurring chart patterns — double bottoms, consolidation breakouts, volume-price divergences. When a match is detected in live Purple Flea market data, open the corresponding position automatically.

Available Financial APIs

Purple Flea exposes six production services as HTTP endpoints. Each maps to a MindsDB virtual table — SELECT to read state, INSERT to execute actions.

🎲
Casino
2% house edge

Provably fair coin flips, dice, roulette, and crash games. INSERT a bet, SELECT the outcome. Great for training RL agents on probabilistic decision-making.

📈
Trading
0.05% per trade

275 perpetual markets on Hyperliquid. Long or short, 1x to 20x leverage. SELECT current positions, INSERT new trades, DELETE to close.

💰
Wallet
0.3% swap fee

Multi-chain wallets across 7 blockchains. Check balances, send tokens, and swap via best-route DEX aggregation — all from SQL queries.

🌐
Domains
Market rate

Register blockchain domain names for AI agents across ENS, Unstoppable, and Handshake. Agents use domains as persistent identifiers across sessions.

💧
Faucet
FREE

New agents claim $1 free to start trading and playing without a deposit. INSERT a claim request, get funds immediately. Zero cost agent onboarding.

🔒
Escrow
1% + 15% referral

Trustless agent-to-agent payments. One agent deposits, another releases. SQL-queryable escrow contracts for autonomous agent service networks.

Use Cases

The MindsDB + Purple Flea combination unlocks workflows that are impossible with standalone tools. Your data warehouse becomes a live trading system.

📊

SQL-Driven Quant Strategy

Encode a complete quantitative trading strategy in SQL. JOIN market data with your historical backtesting tables, run an LLM model to score signals, and INSERT trades that pass your criteria — all in a scheduled MindsDB job.

💾

Data Warehouse + Live Trading

Connect your existing data warehouse (Snowflake, BigQuery, Redshift) to MindsDB alongside Purple Flea. Run enriched signals from years of proprietary data directly against live crypto markets.

🤖

ML Model to Execution

Train a regression or classification model in MindsDB on price data. When the model's prediction passes a confidence threshold, automatically route the signal to Purple Flea's trading API without any external code.

💳

Database-Driven Portfolio Management

Store target allocations in a SQL table. MindsDB compares targets to Purple Flea wallet balances and open positions, then executes the swaps and trades required to rebalance — database-native portfolio management.

Related Integrations

Turn Your Database Into
a Crypto Trading Engine

Register in 60 seconds. Get your API key. Add Purple Flea as a MindsDB HTTP database and start executing trades from SQL queries today.