In the fast-paced world of financial technology, access to real-time market data is not just a luxury—it is a necessity. Whether you are building an algorithmic trading bot, a dynamic portfolio dashboard, or a financial analysis tool, the accuracy and latency of your data feed determine the success of your application.
Developers need a straightforward, reliable way to fetch live market data without parsing complex exchange feeds manually. The Mboum API provides a robust solution for retrieving real-time stock quotes via a simple RESTful interface.
In this guide, we will walk through how to programmatically fetch real-time stock quotes using Python and the Mboum API.
Get your API Key here:
https://mboum.com/pages/api
Mboum API Endpoint for Real-Time Stock Quotes
To retrieve live market data, we will utilize the Quote (real-time) endpoint. This endpoint is designed to provide the most recent trade data for a specific ticker symbol, including the last sale price, volume, and bid/ask data.
Documentation:
https://docs.mboum.com/#stocks-options-GETapi-v1-markets-quote
Endpoint
GET /v1/markets/quote
Base URL
https://api.mboum.com
Key Parameters
-
ticker – The symbol of the company (e.g.,
AAPL,TSLA) -
type – The asset class
Common values include:-
STOCKS -
ETF -
MUTUALFUNDS -
FUTURES
-
Authentication and Request Basics
The Mboum API uses Bearer Token authentication to secure your requests. You must include your unique API key in the HTTP headers of every request.
To generate a token:
-
Log in to your Mboum dashboard
-
Select your account in the upper-right corner
-
Click Personal Access Tokens
Header Format
Authorization: Bearer {YOUR_AUTH_KEY}
Python Example: Fetching Real-Time Stock Quotes
Below is a complete Python script using the requests library to fetch real-time data for Apple Inc. (AAPL). The script sets up authentication headers, passes query parameters, and prints the JSON response.
import requests
import json
# Define the endpoint URL
url = "https://api.mboum.com/v1/markets/quote"
# Set up the query parameters
params = {
"ticker": "AAPL",
"type": "STOCKS"
}
# Authentication header
# Replace {YOUR_AUTH_KEY} with your actual Mboum API key
headers = {
"Authorization": "Bearer {YOUR_AUTH_KEY}",
"Accept": "application/json"
}
try:
# Make the GET request
response = requests.get(url, headers=headers, params=params)
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=4))
else:
print(f"Error: {response.status_code}, {response.text}")
except Exception as e:
print(f"An error occurred: {str(e)}")
Understanding the API Response
When the request is successful, the API returns a JSON object containing metadata and a body with detailed quote information. The response structure clearly differentiates between trading sessions (e.g., Market Hours vs After-Hours).
The core real-time data is found inside the primaryData object.
Key Response Fields
-
symbol – The ticker symbol requested (e.g.,
AAPL) -
lastSalePrice – The most recent trading price
-
netChange – Price difference from the previous close
-
percentageChange – Percentage price change for the session
-
volume – Total shares traded
-
lastTradeTimestamp – Timestamp of the most recent trade
-
bidPrice – Highest price buyers are willing to pay
-
askPrice – Lowest price sellers are willing to accept
-
isRealTime – Confirms the data is real-time
-
marketStatus – Market state (
Open,Closed,After-Hours)
Example Response
{
"body": {
"symbol": "AAPL",
"primaryData": {
"lastSalePrice": "$194.83",
"netChange": "+0.15",
"percentageChange": "+0.08%",
"volume": "45,191,237",
"isRealTime": true
},
"marketStatus": "After-Hours",
"assetClass": "STOCKS"
}
}
Practical Use Cases
Integrating real-time stock quotes enables a wide range of financial applications:
Live Trading Dashboards
Display real-time price movements and market activity.
Algorithmic Trading
Use lastSalePrice and volume in automated trading strategies.
Price Alerts
Trigger SMS or email alerts when percentageChange crosses defined thresholds.
Portfolio Valuation
Calculate portfolio value dynamically using the latest prices.
Final Thoughts
Retrieving accurate market data doesn’t have to be complex. With the Mboum API, developers can access real-time stock quotes through a clean, standardized endpoint. This makes it easy to build fast, responsive, and data-driven financial applications.
Ready to start building?
Get your free API Key here:
https://mboum.com/pages/api