An API Builder Stock Watchlist Example
934
A stock watchlist API example based on API Builder. Project can be found here on Github.
The API is an example of an API First API designed in Stoplight and Built in API Builder as described in the following two blog posts:
The API is shown below:
GET /api/watchlist?stocklist=aapl,txn
and accepts a list of US stock symbols separated by commas.
It returns an array of payload reduced quotes suitable for use in a watchlist:
[
{
"symbol": "AAPL",
"lastPrice": 177.115,
"change": -1.8450012
},
{
"symbol": "TXN",
"lastPrice": 187.31,
"change": -3.699997
}
]
The API uses API Key authentication that is passed in a header with key apikey.
The container requires two env vars:
You can run the container locally using the following commands:
docker pull lbrenman/watchlist
docker run -d --name watchlist -e YAHOO_FINANCE_APIKEY=WA........ep -e API_KEY=Bz.......Xa -p 8080:8080 --rm lbrenman/watchlist
curl 'http://localhost:8080/api/watchlist?stocklist=aapl,txn' --header 'apikey: Bz.......Xa'
Response:
[
{
"symbol": "AAPL",
"lastPrice": 177.115,
"change": -1.8450012
},
{
"symbol": "TXN",
"lastPrice": 187.31,
"change": -3.699997
}
]
Content type
Image
Digest
Size
61.5 MB
Last updated
over 4 years ago
docker pull lbrenman/watchlist