Simple stock API for fetching information related to stocks.
- The code:
git clone https://github.com/sethjones348/stocks
- The following software installed on your computer:
Java 8
or higherDocker
Maven
- Navigate to https://polygon.io/
- Create a free account
- Save your free API key
Once the code is downloaded on your computer
- Open a terminal
- Navigate to the home directory of the project
- Run the following:
export POLYGON_API_KEY=<INSERT_YOUR_API_KEY_HERE>
- Verify the previous command by running
echo $POLYGON_API_KEY
- Execute the command:
./mvnw clean package
- Execute the command
java -jar target/stocks-0.0.1-SNAPSHOT.jar
- Execute the command:
./mvnw clean package
- Run the following from the root:
echo ENV POLYGON_API_KEY="<INSERT_YOUR_API_KEY>" >> Dockerfile
- Run the following:
docker build -t <INSERT_WHAT_YOU_WANT_TO_CALL_THIS_IMAGE> .
- Run the following:
docker run -e POLYGON_API_KEY=<your key> -p 8080:8080 -t <THE_NAME_YOU_MADE_UP_IN_THE_PREVIOUS_COMMAND>
Note: For those that do not have Maven or appropriate Java prereqs, feel free to use the following commands to build inside docker, for a "batteries included" approach:
- Execute the command:
docker build -f Dockerfile.Maven -t <your image> .
- Run the following:
docker run -e POLYGON_API_KEY=<your key> -p 8080:8080 -t <your image>:latest
- Open a separate terminal
- Run the following:
curl localhost:8080/stocks/AAPL
- Congrats you just ran your first test!
- Replace AAPL with any stock symbol you want information on and execute the command again.
- GET /stocks/{symbol}
symbol
is of typeString
symbol
should be a valid stock exchange symbol (e.g., AAPL, IBM..)
- If you try and execute the command more than 1 time in a minute span it will not work since we are using the free version of the API :(