How to Get Real-Time Crypto Prices with the Mobula API in Python

python dev.to

Most crypto APIs are either too expensive, too slow, or designed for traders — not developers.

If you're:

  • building a portfolio tracker,
  • automating a DeFi monitoring bot,
  • or just need live onchain data without paying for an enterprise plan,

This is for you.

The Problem with Getting Crypto Data in 2026

Developers hit the same wall every time.

CoinGecko throttles free-tier requests. CoinMarketCap requires manual API key approval. Binance only covers exchange-listed tokens. And most "real-time" endpoints return data that's 60 seconds stale.

You need price. You need 24h change. You need volume. You need market cap.

What you don't need is a rate limit after 30 requests.

The real issue isn't access. It's that most crypto data APIs weren't built with developers in mind.

What Is the Mobula API?

Mobula is an onchain data API that provides structured market data — including real-time prices, volume, market cap, and liquidity — for thousands of tokens across multiple chains.

It works through a standard REST API with JSON responses.

Developers get access to:

  • Real-time price data (sub-second updates)
  • 24h price change percentage
  • 24h trading volume
  • Fully diluted market cap
  • Multi-chain token support (Ethereum, BSC, Polygon, Solana, and more)

No WebSocket setup required for basic use cases. A single HTTP GET request is enough.


Quick note: if you're a developer tool or fintech company looking for this kind of technical content — tutorials, integration guides, API comparisons — feel free to reach out on LinkedIn.


Setup: Install the Dependencies

No official SDK is needed. Mobula's API is REST-based, so requests is all you need.

pip install requests python-dotenv
Enter fullscreen mode Exit fullscreen mode

Create a .env file to store your API key:

MOBULA_API_KEY=your_api_key_here
Enter fullscreen mode Exit fullscreen mode

Get your free API key at mobula.io.


Example 1 — Fetch Real-Time Price for a Single Token

This is the core use case. One token, one request, live data.

import requests
import os
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("MOBULA_API_KEY")
BASE_URL = "https://api.mobula.io/api/1"

def get_token_price(symbol: str) -> dict:
    url = f"{BASE_URL}/market/data"
    params = {"symbol": symbol}
    headers = {"Authorization": API_KEY}

    response = requests.get(url, params=params, headers=headers)
    response.raise_for_status()

    data = response.json().get("data", {})
    return {
        "symbol": symbol.upper(),
        "price": data.get("price"),
        "price_change_24h": data.get("price_change_24h"),
        "volume_24h": data.get("volume"),
        "market_cap": data.get("market_cap"),
    }

result = get_token_price("BTC")
print(result)
Enter fullscreen mode Exit fullscreen mode

Sample output:

{"symbol":"BTC","price":64312.47,"price_change_24h":2.34,"volume_24h":28450000000.0,"market_cap":1264000000000.0}
Enter fullscreen mode Exit fullscreen mode

Clean. Structured. No parsing gymnastics.


Example 2 — Fetch Multiple Tokens at Once

When you're building a dashboard or tracker, you need batch data — not 10 separate requests.

def get_multiple_tokens(symbols: list[str]) -> list[dict]:
    results = []
    for symbol in symbols:
        try:
            data = get_token_price(symbol)
            results.append(data)
        except requests.HTTPError as e:
            results.append({"symbol": symbol, "error": str(e)})
    return results

tokens = ["BTC", "ETH", "SOL", "MATIC", "LINK"]
portfolio = get_multiple_tokens(tokens)

for token in portfolio:
    if "error" not in token:
        print(
            f"{token['symbol']:6} | "
            f"${token['price']:,.2f} | "
            f"{token['price_change_24h']:+.2f}% | "
            f"Vol: ${token['volume_24h']:,.0f}"
        )
Enter fullscreen mode Exit fullscreen mode

Sample output:

BTC    | $64,312.47 | +2.34% | Vol: $28,450,000,000
ETH    | $3,121.88  | +1.12% | Vol: $14,200,000,000
SOL    | $148.50    | -0.78% | Vol: $3,800,000,000
MATIC  | $0.87      | +0.45% | Vol: $420,000,000
LINK   | $14.23     | +3.10% | Vol: $510,000,000
Enter fullscreen mode Exit fullscreen mode

Five tokens. Five lines. Ready to pipe into a Telegram alert, a Google Sheet, or a Notion dashboard.


Example 3 — Search by Contract Address (Onchain Tokens)

Not every token has a clean ticker symbol. For newer or less-listed tokens, use the contract address instead.

def get_token_by_address(address: str, blockchain: str = "ethereum") -> dict:
    url = f"{BASE_URL}/market/data"
    params = {
        "asset": address,
        "blockchain": blockchain
    }
    headers = {"Authorization": API_KEY}

    response = requests.get(url, params=params, headers=headers)
    response.raise_for_status()

    data = response.json().get("data", {})
    return {
        "name": data.get("name"),
        "symbol": data.get("symbol"),
        "price": data.get("price"),
        "price_change_24h": data.get("price_change_24h"),
        "market_cap": data.get("market_cap"),
        "liquidity": data.get("liquidity"),
    }

# Example: PEPE token on Ethereum
pepe_address = "0x6982508145454Ce325dDbE47a25d4ec3d2311933"
result = get_token_by_address(pepe_address, blockchain="ethereum")
print(result)
Enter fullscreen mode Exit fullscreen mode

This is where Mobula stands out from traditional exchange APIs.

Most CEX-based APIs don't index long-tail or newly launched tokens. Mobula does — because it reads directly from onchain liquidity pools.


Example 4 — Build a Simple Price Alert

Combine the fetcher with a basic threshold check. Useful for bots and automations.

import time

def price_alert_loop(symbol: str, threshold_pct: float = 5.0, interval: int = 60):
    """
    Polls the API every `interval` seconds.
    Triggers an alert if 24h change exceeds `threshold_pct`.
    """
    print(f"Monitoring {symbol} every {interval}s | Alert threshold: ±{threshold_pct}%\n")

    while True:
        try:
            data = get_token_price(symbol)
            change = data["price_change_24h"]
            price = data["price"]

            print(f"[{symbol}] ${price:,.2f} | 24h: {change:+.2f}%")

            if abs(change) >= threshold_pct:
                print(f"🚨 ALERT: {symbol} moved {change:+.2f}% in 24h — price is ${price:,.2f}")

        except Exception as e:
            print(f"Error fetching {symbol}: {e}")

        time.sleep(interval)

# Run the alert loop for ETH
price_alert_loop("ETH", threshold_pct=5.0, interval=60)
Enter fullscreen mode Exit fullscreen mode

From here you can extend this into:

  • Telegram notifications via python-telegram-bot
  • Slack alerts via webhooks
  • n8n automations with an HTTP trigger node
  • Discord bots for trading communities

Mobula API — Quick Reference

Endpoint Method Description
/market/data GET Price, volume, market cap, 24h change
/market/history GET Historical OHLCV data
/market/multi-data GET Batch price data by symbols
/metadata GET Token metadata (logo, description, socials)

Authentication: Authorization: YOUR_API_KEY header on all requests.

Free tier includes several thousand requests/day — enough for personal projects and prototypes.


What You've Built

A working Python module that:

  • Fetches live price, 24h change, volume, and market cap
  • Handles both ticker symbols and contract addresses
  • Supports batch queries across any token list
  • Runs as a polling alert system

No SDKs. No bloated dependencies. Just requests and clean JSON.


Frequently Asked Questions

Is the Mobula API free?
Yes. Mobula offers a free tier with several thousand requests per day — enough for personal projects, prototypes, and low-frequency automations. Paid plans unlock higher rate limits, priority support, and access to premium endpoints like institutional-grade OHLCV history.

Does Mobula support tokens not listed on major exchanges?
Yes, and this is one of its key advantages. Because Mobula indexes onchain liquidity pools directly, it covers long-tail tokens and newly launched assets that CoinGecko and CoinMarketCap often lag behind on. You can query any token by contract address across supported chains.

Which blockchains does Mobula support?
As of 2026, Mobula covers Ethereum, BNB Chain, Polygon, Solana, Avalanche, Arbitrum, Base, and several other EVM-compatible chains. The /market/data endpoint accepts a blockchain parameter to scope results.

How fast is the price data?
Price updates are sub-second for major assets. For long-tail tokens with lower liquidity, refresh rates depend on onchain activity. For most use cases — dashboards, bots, alerts — the latency is negligible compared to alternatives.

Can I use Mobula in production?
Yes. The REST API is stable and versioned. For high-throughput production systems, use the /market/multi-data endpoint to batch requests and stay within rate limits. If you're building something at scale, check the paid plans for SLA guarantees.

Do I need a special library or SDK?
No. Mobula's API is standard REST — just requests in Python is enough. There's no proprietary SDK required.


Start Building with Mobula

Crypto data doesn't need to be complicated.

One endpoint, one request, one structured response — and you have everything you need to build monitoring tools, portfolio trackers, and trading automations without paying for an enterprise contract.

👉 Get your free Mobula API key here

You'll get access to:

  • Real-time prices across thousands of tokens
  • Onchain data including contract address lookup
  • Multi-chain support out of the box
  • A free tier that covers most personal and side-project use cases

Looking for technical content for your company? I can help — LinkedIn · kevinmenesesgonzalez@gmail.com

Source: dev.to

arrow_back Back to Tutorials