Sign inSign up

lbrenman/watchlist

By lbrenman

•Updated over 4 years ago

An API Builder Stock Watchlist Example

Image
API management
0

934

lbrenman/watchlist repository overview

⁠Docker Hub Readme

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:

  • API_KEY - a randomly selected API Key that you can provide that is used to authenticate API calls in a header with key apikey
  • YAHOO_FINANCE_APIKEY - a Yahoo Finance API Key that you can obtain from Yahoo Finance⁠

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
  }
]

Tag summary

Content type

Image

Digest

Size

61.5 MB

Last updated

over 4 years ago

docker pull lbrenman/watchlist