Massive Python Client
The `massive` library is the official Python client for the Massive (formerly Polygon.io) REST and WebSocket APIs. It provides comprehensive access to real-time and historical market data for Stocks, Options, Forex, and Crypto. The library is currently at version 2.5.0 and aims to follow the API's release cadence, often bundling breaking changes and maintaining backward compatibility where feasible.
Common errors
-
ModuleNotFoundError: No module named 'polygon'
cause Attempting to import from the old 'polygon' package name after upgrading to `massive` client version 2.0.1 or later, which introduced the rebranding.fixChange your import statements from `from polygon import ...` to `from massive import ...`. -
AttributeError: 'SomeClient' object has no attribute 'get_aggs' (or similar for other methods)
cause Method names may have changed or been consolidated, particularly for newer API versions or after major updates (e.g., Futures API).fixConsult the official Massive API documentation or the library's `examples` directory on GitHub for the correct method names and usage patterns for the endpoints you are trying to access. -
KeyError: 'transaction_count'
cause In version 2.0.2, the field name 'transaction_count' was changed to 'transactions' in aggregate models.fixUpdate your code to access the 'transactions' key instead of 'transaction_count' when parsing aggregate data.
Warnings
- breaking The library underwent a major rebranding from Polygon.io to Massive.com in v2.0.1. This changed the package name from `polygon` to `massive`, updated default API base URLs (e.g., `api.polygon.io` to `api.massive.com`), and necessitated changes in import statements.
- breaking The Futures Beta Endpoints were significantly updated and consolidated in v2.1.0. Endpoints like `/futures/vX/contracts`, `/futures/vX/products`, and `/futures/vX/schedules` now handle both lists and specific details, replacing older separate endpoints.
- breaking Effective November 3, 2025 (v2.0.x series), the `bid_size` and `ask_size` fields for stock quotes now report values in shares instead of round lots. This change aligns with SEC Market Data Infrastructure (MDI) Rules.
- deprecated The Benzinga News v1 API was officially sunset on December 1, 2025. This endpoint is no longer available.
- gotcha Users of the free tier API may encounter rate limit errors (`HTTP 429 Too Many Requests`) due to usage limitations.
Install
-
pip install -U massive
Imports
- RESTClient
from polygon import RESTClient
from massive import RESTClient
- WebSocketClient
from polygon import WebSocketClient
from massive import WebSocketClient
Quickstart
import os
from massive import RESTClient
from datetime import date
api_key = os.environ.get('MASSIVE_API_KEY', 'YOUR_API_KEY')
if api_key == 'YOUR_API_KEY':
print("WARNING: Please set the MASSIVE_API_KEY environment variable or replace 'YOUR_API_KEY' with your actual API key.")
# Exit or raise an error in a real application
client = RESTClient(api_key=api_key)
ticker = "AAPL"
multiplier = 1
timespan = "day"
from_date = date(2023, 1, 1)
to_date = date(2023, 1, 5)
print(f"Fetching aggregate bars for {ticker} from {from_date} to {to_date}...")
try:
aggs = []
for a in client.list_aggs(ticker=ticker, multiplier=multiplier, timespan=timespan, from_=from_date, to=to_date):
aggs.append(a)
if aggs:
print(f"Retrieved {len(aggs)} aggregate bars:")
for agg in aggs:
print(agg)
else:
print("No aggregate bars found for the specified period.")
except Exception as e:
print(f"An error occurred: {e}")