|
| 1 | +# Fundamentals API Migration Guide |
| 2 | + |
| 3 | +## 🚨 Important Changes |
| 4 | + |
| 5 | +The single `/vX/reference/financials` endpoint has been **deprecated** and replaced with 6 specialized endpoints for better performance and more focused data access. |
| 6 | + |
| 7 | +### What's Changed |
| 8 | + |
| 9 | +| Old (Deprecated) | New (Recommended) | |
| 10 | +|------------------|-------------------| |
| 11 | +| `client.vx.list_stock_financials()` | **6 separate methods** (see below) | |
| 12 | +| Single endpoint with complex filtering | Dedicated endpoints optimized for specific data types | |
| 13 | +| Complex response structure | Streamlined, focused response models | |
| 14 | + |
| 15 | +### New Fundamentals Endpoints |
| 16 | + |
| 17 | +1. **Balance Sheets** → `client.list_balance_sheets()` |
| 18 | +2. **Cash Flow Statements** → `client.list_cash_flow_statements()` |
| 19 | +3. **Income Statements** → `client.list_income_statements()` |
| 20 | +4. **Financial Ratios** → `client.list_financial_ratios()` |
| 21 | +5. **Short Interest** → `client.list_short_interest()` |
| 22 | +6. **Short Volume** → `client.list_short_volume()` |
| 23 | + |
| 24 | +## Migration Examples |
| 25 | + |
| 26 | +### Before (Deprecated) |
| 27 | +```python |
| 28 | +from polygon import RESTClient |
| 29 | + |
| 30 | +client = RESTClient(api_key="your_api_key") |
| 31 | + |
| 32 | +# Old way - deprecated |
| 33 | +financials = client.vx.list_stock_financials( |
| 34 | + ticker="AAPL", |
| 35 | + timeframe="quarterly", |
| 36 | + limit=10 |
| 37 | +) |
| 38 | +``` |
| 39 | + |
| 40 | +### After (New) |
| 41 | +### After (New) |
| 42 | + |
| 43 | +```python |
| 44 | +from polygon import RESTClient |
| 45 | + |
| 46 | +client = RESTClient(api_key="your_api_key") |
| 47 | + |
| 48 | +# New way - methods available directly on client (recommended) |
| 49 | +balance_sheets = client.list_balance_sheets( |
| 50 | + tickers="AAPL", |
| 51 | + timeframe="quarterly", |
| 52 | + limit=10 |
| 53 | +) |
| 54 | + |
| 55 | +# Get cash flow statements |
| 56 | +cash_flows = client.list_cash_flow_statements( |
| 57 | + tickers="AAPL", |
| 58 | + timeframe="quarterly", |
| 59 | + limit=10 |
| 60 | +) |
| 61 | + |
| 62 | +# Get income statements |
| 63 | +income_statements = client.list_income_statements( |
| 64 | + tickers="AAPL", |
| 65 | + timeframe="quarterly", |
| 66 | + limit=10 |
| 67 | +) |
| 68 | + |
| 69 | +# Get financial ratios |
| 70 | +ratios = client.list_financial_ratios( |
| 71 | + ticker="AAPL", |
| 72 | + limit=10 |
| 73 | +) |
| 74 | + |
| 75 | +# Get short interest data |
| 76 | +short_interest = client.list_short_interest( |
| 77 | + ticker="AAPL", |
| 78 | + limit=10 |
| 79 | +) |
| 80 | + |
| 81 | +# Get short volume data |
| 82 | +short_volume = client.list_short_volume( |
| 83 | + ticker="AAPL", |
| 84 | + limit=10 |
| 85 | +) |
| 86 | + |
| 87 | +# Clean, direct access - no extra namespacing needed! |
| 88 | + |
| 89 | +## Key Benefits of New API |
| 90 | + |
| 91 | +### 1. **Better Performance** |
| 92 | +- Smaller, focused responses |
| 93 | +- Faster query times |
| 94 | +- Reduced bandwidth usage |
| 95 | + |
| 96 | +### 2. **Cleaner Data Models** |
| 97 | +- Each endpoint has its own optimized model |
| 98 | +- No more complex nested structures |
| 99 | +- Better type safety and IDE support |
| 100 | + |
| 101 | +### 3. **More Specific Filtering** |
| 102 | +- Tailored query parameters for each data type |
| 103 | +- Better filtering capabilities |
| 104 | +- More intuitive parameter names |
| 105 | + |
| 106 | +### 4. **Enhanced Features** |
| 107 | +- Support for Trailing Twelve Months (TTM) data |
| 108 | +- Better date range filtering |
| 109 | +- More comprehensive ratio calculations |
| 110 | + |
| 111 | +## Query Parameters |
| 112 | + |
| 113 | +### Common Parameters (most endpoints) |
| 114 | +- `cik` - Central Index Key (CIK) |
| 115 | +- `tickers` - Ticker symbol(s) |
| 116 | +- `period_end` - Reporting period end date (YYYY-MM-DD) |
| 117 | +- `fiscal_year` - Fiscal year |
| 118 | +- `fiscal_quarter` - Fiscal quarter (1, 2, 3, or 4) |
| 119 | +- `timeframe` - Period type: "quarterly", "annual", "trailing_twelve_months" |
| 120 | +- `limit` - Number of results (default: 100, max: 50,000) |
| 121 | +- `sort` - Sort field and direction |
| 122 | + |
| 123 | +### Ratios-Specific Parameters |
| 124 | +- `ticker` - Stock ticker (required for ratios) |
| 125 | +- `price` - Stock price filter |
| 126 | +- `market_cap` - Market capitalization filter |
| 127 | +- `price_to_earnings` - P/E ratio filter |
| 128 | +- And many more financial metrics... |
| 129 | + |
| 130 | +### Short Interest/Volume Parameters |
| 131 | +- `ticker` - Stock ticker |
| 132 | +- `settlement_date` / `date` - Specific dates |
| 133 | +- Volume and ratio-specific filters |
| 134 | + |
| 135 | +## Response Models |
| 136 | + |
| 137 | +### Balance Sheet Fields |
| 138 | +- `total_assets`, `total_liabilities`, `total_equity` |
| 139 | +- `cash_and_equivalents`, `receivables`, `inventories` |
| 140 | +- `long_term_debt_and_capital_lease_obligations` |
| 141 | +- And more... |
| 142 | + |
| 143 | +### Cash Flow Fields |
| 144 | +- `net_cash_from_operating_activities` |
| 145 | +- `net_cash_from_investing_activities` |
| 146 | +- `net_cash_from_financing_activities` |
| 147 | +- `change_in_cash_and_equivalents` |
| 148 | +- And more... |
| 149 | + |
| 150 | +### Income Statement Fields |
| 151 | +- `revenue`, `cost_of_revenue`, `gross_profit` |
| 152 | +- `operating_income`, `net_income_loss_attributable_common_shareholders` |
| 153 | +- `basic_earnings_per_share`, `diluted_earnings_per_share` |
| 154 | +- And more... |
| 155 | + |
| 156 | +### Financial Ratios Fields |
| 157 | +- `price_to_earnings`, `price_to_book`, `price_to_sales` |
| 158 | +- `debt_to_equity`, `current_ratio`, `quick_ratio` |
| 159 | +- `return_on_assets`, `return_on_equity` |
| 160 | +- `enterprise_value`, `ev_to_ebitda` |
| 161 | +- And more... |
| 162 | + |
| 163 | +### Short Interest Fields |
| 164 | +- `short_interest` - Total shares sold short |
| 165 | +- `avg_daily_volume` - Average daily trading volume |
| 166 | +- `days_to_cover` - Estimated days to cover positions |
| 167 | + |
| 168 | +### Short Volume Fields |
| 169 | +- `short_volume` - Daily short sale volume |
| 170 | +- `total_volume` - Total daily volume |
| 171 | +- `short_volume_ratio` - Percentage short sold |
| 172 | +- Exchange-specific volume breakdowns |
| 173 | + |
| 174 | +## Complete Example |
| 175 | + |
| 176 | +See `examples/rest/fundamentals_example.py` for a comprehensive example showing all endpoints. |
| 177 | + |
| 178 | +## Backward Compatibility |
| 179 | + |
| 180 | +The old `VXClient` is still available for backward compatibility but will show deprecation warnings: |
| 181 | + |
| 182 | +```python |
| 183 | +# Still works but shows warnings |
| 184 | +financials = client.vx.list_stock_financials(ticker="AAPL") |
| 185 | +``` |
| 186 | + |
| 187 | +**Migration Timeline:** |
| 188 | +- ✅ **Now**: New fundamentals API available |
| 189 | +- ⚠️ **Current**: Old API deprecated with warnings |
| 190 | +- 🚫 **Future**: Old API will be removed |
| 191 | + |
| 192 | +## Need Help? |
| 193 | + |
| 194 | +- Check `examples/rest/fundamentals_example.py` for usage examples |
| 195 | +- Review the API documentation at https://polygon.io/docs/ |
| 196 | +- All new endpoints follow the same patterns as existing Polygon APIs |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +**Ready to migrate?** Start with one endpoint at a time and gradually move all your code to the new fundamentals API! 🚀 |
0 commit comments