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...
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).
ticker
optionalStock ticker symbol (e.g. AAPL
).
name
optionalCompany name (full or partial match).
sector
optionalCompany sector (e.g. Information Technology
).
min_date_added
optionalEarliest date company was added to the S&P 500 (format: YYYY-MM-DD
).
max_date_added
optionalLatest date company was added to the S&P 500 (format: YYYY-MM-DD
).
X-Api-Key
requiredAPI Key associated with your account.
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.
https://api.api-ninjas.com/v1/sp500
Headers
X-Api-Key
Log in or sign up to get your API Key
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"
},
...
]
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.