S&P 500 API

The S&P 500 API provides information about companies in the S&P 500 index, including ticker, name, sector, and the date the company was added to the index.

Checking API status...

/v1/sp500 GET

https://api.api-ninjas.com/v1/sp500

Returns a list of S&P 500 companies. All parameters are optional. If no parameters are provided, data for all companies will be returned (may be slow in poor network conditions).


Parameters

  • ticker  optional

    Stock ticker symbol (e.g. AAPL).

  • name  optional

    Company name (full or partial match).

  • sector  optional

    Company sector (e.g. Information Technology).

  • min_date_added  optional

    Earliest date company was added to the S&P 500 (format: YYYY-MM-DD).

  • max_date_added  optional

    Latest date company was added to the S&P 500 (format: YYYY-MM-DD).

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

  • ticker

    Stock ticker symbol.

  • company_name

    Company name.

  • sector

    Company sector.

  • date_added

    Date the company was added to the S&P 500 (format: YYYY-MM-DD).

  • cik

    Company CIK number.

  • sub_industry

    Company sub-industry.

  • headquarters

    Company headquarters location.

Sample Request Live Demo!

https://api.api-ninjas.com/v1/sp500

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [ { "ticker": "NVDA", "company_name": "Nvidia", "sector": "Information Technology", "date_added": "2001-11-30", "cik": "0001045810", "sub_industry": "Semiconductors", "headquarters": "Santa Clara, California" }, { "ticker": "JNJ", "company_name": "Johnson & Johnson", "sector": "Health Care", "date_added": "1973-06-30", "cik": "0000200406", "sub_industry": "Pharmaceuticals", "headquarters": "New Brunswick, New Jersey" }, ... ]

Code Examples

1 2 3 4 5 6 7 import requests api_url = 'https://api.api-ninjas.com/v1/sp500' response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.