Skip to content

melvinthoompunkal/Stock_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Absolutely! Here's a clean, professional README.md for your StockAPI project that you can push to GitHub. It’s written so others can understand your project, run it locally, and test the endpoints.


StockAPI

A lightweight Flask API for fetching real-time stock data using Yahoo Finance.  
Supports single-stock queries as well as batch requests for multiple stock symbols.

---

## Features

- Get the latest stock price and daily change percentage for a single symbol.
- Fetch multiple stocks at once using a single request.
- Modular architecture: routes, services, and optional API key protection.
- Ready for future expansion with technical indicators or sentiment analysis.

---

Project Structure

StockAPI/ │ ├── app.py # Main entry point ├── routes/ │ ├── init.py │ └── stock_routes.py # API endpoints ├── services/ │ ├── init.py │ └── stock_service.py # Data fetching logic ├── config.py # API key or configuration (optional) ├── requirements.txt # Python dependencies └── README.md


---

Installation

1. Clone the repository:

```bash
git clone https://github.com/yourusername/StockAPI.git
cd StockAPI
  1. Create a virtual environment:
python3 -m venv venv
source venv/bin/activate  # Mac/Linux
# OR
venv\Scripts\activate     # Windows
  1. Install dependencies:
pip install -r requirements.txt

Running the API

python app.py

The API will run locally at:

http://127.0.0.1:5000

API Endpoints

Get a single stock

GET /stock/<symbol>

Example:

http://127.0.0.1:5000/stock/TSLA

Response:

{
  "symbol": "TSLA",
  "price": 189.55,
  "change_percent": 2.08
}

Get multiple stocks

GET /stocks?symbols=AAPL,MSFT,GOOG

Response:

{
  "AAPL": {"symbol": "AAPL", "price": 229.15, "change_percent": 1.12},
  "MSFT": {"symbol": "MSFT", "price": 412.39, "change_percent": -0.45},
  "GOOG": {"symbol": "GOOG", "price": 132.44, "change_percent": 0.72}
}

##License

This project is open-source and free to use for personal or educational purposes.

About

Created a api using flask

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages