A lightweight utility to scrape and retrieve financial index constituents, including S&P 500, Nasdaq-100, and S&P 100.
Project description
Indexes: A Lightweight S&P 500, Nasdaq-100 & S&P 100 Scraper
indexes is a professional Python utility designed to scrape and retrieve financial index constituents, providing developers with a clean, programmatic interface to access real-time market data. It simplifies the process of extracting stock market components from the S&P 500, Nasdaq-100, and S&P 100 for financial analysis and algorithmic trading.
Why use Indexes?
For financial analysts and Python developers, keeping up-to-date lists of S&P 500, Nasdaq-100 and S&P 100 constituents can be tedious. indexes provides a simple, cached interface to fetch this data from reliable public sources (like Wikipedia), returning essential metadata such as Sector, Industry, CIK, and more.
Key Features
- Efficient Scrapers: Get up-to-date S&P 500, Nasdaq-100 and S&P 100 constituents in seconds.
- Flexible Data Formats: Retrieve results as a Python
listor adictkeyed by symbol. - Granular Field Selection: Extract only what you need.
- Smart Caching: Minimizes network requests by caching data within the same execution session.
- Minimalist Design: Zero-config, lightweight, and easy to integrate into larger financial pipelines.
Installation
Install the package via pip:
pip install indexes
Requirements
- Python >= 3.8
requestsbeautifulsoup4
Quick Start & Usage
from indexes import get_sp500, get_nasdaq100, get_sp100
# Get a simple list of all S&P 500 ticker symbols
sp500_symbols = get_sp500()
# Get S&P 100 symbols
sp100_symbols = get_sp100()
# Get Nasdaq-100 details
nasdaq_details = get_nasdaq100(
return_type='dict',
fields=['name', 'industry']
)
# Example: Accessing Apple Inc. metadata (present in both)
print(nasdaq_details['AAPL'])
# Output: {'name': 'Apple Inc.', 'industry': 'Technology'}
# Get a list of dictionaries with custom fields
data = get_sp500(return_type='list', fields=['name', 'sector', 'cik'])
API Documentation
get_sp500(return_type='list', fields=None)
The entry point for fetching the S&P 500 index components.
return_type(str):'list'(default) or'dict'.fields(list, optional): Defaults to['symbol'].- Supported fields:
symbol,name,sector,sub_industry,date_added,cik,founded.
- Supported fields:
get_nasdaq100(return_type='list', fields=None)
The entry point for fetching the Nasdaq-100 index components.
return_type(str):'list'(default) or'dict'.fields(list, optional): Defaults to['symbol'].- Supported fields:
symbol,name,industry,subsector.
- Supported fields:
get_sp100(return_type='list', fields=None)
The entry point for fetching the S&P 100 index components.
return_type(str):'list'(default) or'dict'.fields(list, optional): Defaults to['symbol'].- Supported fields:
symbol,name,sector.
- Supported fields:
Development and Contributions
We welcome contributions from the community! Whether it's adding new indexes, new features or improving the scraper's robustness, feel free to submit a Pull Request.
Local Setup
- Clone the repository:
git clone https://github.com/fzunigam/indexes.git cd indexes
- Install in editable mode:
pip install -e .
Running Tests
Ensure stability by running the test suite:
pytest
Disclaimer
This project was built with the help of AI coding tools.
License
indexes is licensed under the MIT License. See the LICENSE file for more information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file indexes-0.1.3.tar.gz.
File metadata
- Download URL: indexes-0.1.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
437d452e4739a0298f11e1b3a76c15ab6844f0d8e53e6937b554d02ea2346e07
|
|
| MD5 |
0696db9397b465d0c564d568c588dad2
|
|
| BLAKE2b-256 |
dd24bdb5e5898a9dc5a514cebd62e9f551439f48dfb4fd0fefcac05fd9f10afb
|
Provenance
The following attestation bundles were made for indexes-0.1.3.tar.gz:
Publisher:
publish.yml on fzunigam/indexes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
indexes-0.1.3.tar.gz -
Subject digest:
437d452e4739a0298f11e1b3a76c15ab6844f0d8e53e6937b554d02ea2346e07 - Sigstore transparency entry: 1535891915
- Sigstore integration time:
-
Permalink:
fzunigam/indexes@36616a5dc251dcb7d69ed4395a2722c7b12520de -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/fzunigam
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@36616a5dc251dcb7d69ed4395a2722c7b12520de -
Trigger Event:
push
-
Statement type:
File details
Details for the file indexes-0.1.3-py3-none-any.whl.
File metadata
- Download URL: indexes-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd7225dc2c33f767b1858036b98654bb94f4c1f8b77ab1860d7388c96a866af0
|
|
| MD5 |
8d25dfb9fa1b5615ca372652f09b8624
|
|
| BLAKE2b-256 |
89482975bc6e3a609fc6c23c4134dd6376e041f9a0d982087002123092adf603
|
Provenance
The following attestation bundles were made for indexes-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on fzunigam/indexes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
indexes-0.1.3-py3-none-any.whl -
Subject digest:
cd7225dc2c33f767b1858036b98654bb94f4c1f8b77ab1860d7388c96a866af0 - Sigstore transparency entry: 1535891986
- Sigstore integration time:
-
Permalink:
fzunigam/indexes@36616a5dc251dcb7d69ed4395a2722c7b12520de -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/fzunigam
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@36616a5dc251dcb7d69ed4395a2722c7b12520de -
Trigger Event:
push
-
Statement type: