How can I download financials (P/E, P/EBITDA, market Cap etc.) for all the SP500 (quarterly or finer

How can I download financials (P/E, P/EBITDA, market Cap etc.) for all the SP500 (quarterly or finer granularity) 2000 to today via API (Python or R preferred)?

Best Answer