An open API service indexing awesome lists of open source software.

https://github.com/nfaltir/stock-ticker-api

🍊 A simple python api web application that uses the FastApi Framework. This application allows user to fetch stock tickers from the SP500 index.
https://github.com/nfaltir/stock-ticker-api

api fastapi finance python

Last synced: 2 months ago
JSON representation

🍊 A simple python api web application that uses the FastApi Framework. This application allows user to fetch stock tickers from the SP500 index.

Awesome Lists containing this project

README

          

# Python FastAPI App

version: 1.2.1.0

Overview



This is a small python application that uses the Fastapi Framework. This app creates api endpoints

that users can use to fetch stock tickers from the SP500, you can filter tickers by sector.


## Install Python Modules setup

pip3 install -r requirements.txt


## Run App locally

uvicorn:api:app --reload


Base URL: localhost:8000/


By default, local server will run on port:8000, if this port is not open, server will run on a different port

check code output for specified port.




API Endpoints
----------------------


Endpoint
Data


{baseurl}/
Index Page


{baseurl}/docs
Fastapi Docs


{baseurl}/get-tickers/sp500
All SP 500 Tickers


{baseurl}/sectors
All sector names in SP500


{baseurl}/get-tickers{sector_id}
ALL stock tickers in target sector


Sector Id(s)


financials




consumer-cyclical




real-estate




utilities




basic-materials




communication-services




healthcare




technology




consumer-defensive




financial-services




industrials


Example: Usage
--------------

objective: After running app locally, Get all stock tickers from Engergy sector in Sp500 index.

localhost:8000/get-tickers/energy


Output Figure
example-energy

Deploy to Heroku
--------------
1. Create a requirements file that lists all required modules
inside project folder run this command: `pip3 freeze > requirements.txt`
2. Remember to specify which python version you are using by creating a runtime.txt file `touch runtime.txt`
Heroku will need this file.
file is both case and space sensitive, use this format: `python-3.9.7`
3. Create a Procfile
`touch Procfile`
type the following: `web: uvicorn api:app --host=0.0.0.0 --port=${PORT:-5000}`


Live Demo!!