Skip to content

Stock Service

Krishna Prajapati edited this page May 7, 2021 · 8 revisions
  1. Stock Services

    1.1 Request Current Price

    1.2 Request Intraday Price

    1.3 Request Historical Data

    1.4 Request Ticker Statistics

    1.5 Validate Ticker

  2. News Services

    2.1 Request News

Stock Services

Request Current Price

Returns the latest price data available for a ticker

  • URL

    /equity/current/:ticker

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content: { "price": (number) }
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: { "error" : {err} }
  • Sample Call:

    /equity/current/twtr

{
  "price": 65.27
}

Request Intraday Price

Returns a ticker's price data for the day (or last available day in case of weekends)

  • URL

    /equity/intraday/:ticker

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content:
      { 
        {time1}: (number),
        {time2}: (number),
        ...
      }
      
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: { "error" : {err} }
  • Sample Call:

    /equity/intraday/twtr

{
  "09:30": 65.18,
  "09:31": 65.068,
  "09:32": 64.926,
  "09:33": 65.235,
  "09:34": 65.28,
  "09:35": 65.198,
  ...
}

Request Historical Data

Returns the price data for the given ticker and time frame

  • URL

    /equity/historical/:ticker?timeframe={timeframe}

    timeframe must be in ['5d', '1m', '6m', 'ytd', '1y', '5y']

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content:
      { 
        {time1}: (number),
        {time2}: (number),
        ...
      }
      
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: { Invalid timeframe }

    • Code: 400 BAD REQUEST
      Content: { "error" : {err} }

  • Sample Call:

    /equity/historical/twtr?timeframe=1m

{
  "2021-02-23": 73.17,
  "2021-02-24": 71.92,
  "2021-02-25": 74.59,
  "2021-02-26": 77.06,
  "2021-03-01": 77.63,
  "2021-03-02": 73.67,
  "2021-03-03": 70.86,
  "2021-03-04": 66.75,
  "2021-03-05": 66.95,
  "2021-03-08": 63.48,
  "2021-03-09": 67.52,
  "2021-03-10": 64.83,
  "2021-03-11": 68.46,
  "2021-03-12": 68.1,
  "2021-03-15": 70.28,
  "2021-03-16": 69.25,
  "2021-03-17": 70.2,
  "2021-03-18": 66.72,
  "2021-03-19": 66.23,
  "2021-03-22": 65.21
}

Request Ticker Statistics

Returns statistics for an equity

  • URL

    /equity/statistics/:ticker

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content:

      {
        "peRatio":        (number),
        "dividend":       (number),
        "tickerSymbol":   (string),
        "__v":            (number),
        "askPrice":       (number),
        "avgVolume":      (number),
        "beta":           (number),
        "bidPrice":       (number),
        "currentPrice":   (number),
        "dayHigh":        (number),
        "dayLow":         (number),
        "earningsDate":   (date),
        "eps":            (number),
        "equityName":     (string),
        "exDividend":     (number),
        "marketCap":      (number),
        "openPrice":      (number),
        "percentChange":  (number),
        "previousClose":  (number),
        "time":           (date),
        "volume":         (number),
        "week52High":     (number),
        "week52Low":      (number)
      }
      
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: { "error" : {err} }
  • Sample Call:

    /equity/statistics/twtr

{
  "peRatio": -45.83157108280366,
  "dividend": 0,
  "_id": "6058085f8ecf8b81f934319a",
  "tickerSymbol": "twtr",
  "__v": 0,
  "askPrice": 81,
  "avgVolume": 22957837,
  "beta": 1.236305599208382,
  "bidPrice": 65.01,
  "currentPrice": 65.07,
  "dayHigh": null,
  "dayLow": null,
  "earningsDate": "2021-02-09T00:00:00.000Z",
  "eps": -1.44,
  "equityName": "Twitter Inc",
  "exDividend": null,
  "marketCap": 52047523742,
  "openPrice": null,
  "percentChange": -0.00215,
  "previousClose": 65.21,
  "time": "2021-03-23T15:51:21.891Z",
  "volume": 218993,
  "week52High": 80.75,
  "week52Low": 22.36
}

Validate Ticker

Returns whether or not a ticker is a valid tracked ticker

  • URL

    /equity/tickers/:ticker

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content: { "exists": (boolean) }
  • Error Response:

    • Code: 503 SERVICE UNAVAILABLE
      Content: { "error" : "Unable to access database" }
  • Sample Call:

    /equity/tickers/twtr

{
  "exists": true
}

News Services

Request News

Returns news data given an equity

  • URL

    /news/newsInfo/:ticker

  • Method:

    GET

  • URL Params

    ticker: String, Equity Symbol

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content: [ {News Objects} ]

      News Object:

      {
        "headline" : (string),
        "source" : (string),
        "image" : (url),
        "url" : (url),
        "date" : (date),
      }
      
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: { "error" : {err} }
  • Sample Call:

    /news/newsInfo/AAPL

[
  {
    "headline":"2021 iPad Pro: The best new features video - CNET",
    "source":"CNET",
    "image":"https://cloud.iexapis.com/v1/news/image/8993058e-2eab-4ce8-bdc8-9076c6522d31",
    "url":"https://cloud.iexapis.com/v1/news/article/8993058e-2eab-4ce8-bdc8-9076c6522d31",
    "date":"2021-05-07T12:00:03.000Z"
  },
  {
    "headline":"Cathie Wood dimezza quota Apple, riduce Google e Fastly",
    "source":"Investing.com Italy",
    "image":"https://cloud.iexapis.com/v1/news/image/112cdbf3-1ddc-4f25-99d9-88dc371a4c61",
    "url":"https://cloud.iexapis.com/v1/news/article/112cdbf3-1ddc-4f25-99d9-88dc371a4c61",
    "date":"2021-05-07T10:05:25.000Z"
  },
  {
    "headline":"Why Apple Customers Are Drilling Holes Into Their AirTags",
    "source":"Benzinga",
    "image":"https://cloud.iexapis.com/v1/news/image/0fe63ee8-d2d8-4a2c-8d11-47cd5c5e19e6",
    "url":"https://cloud.iexapis.com/v1/news/article/0fe63ee8-d2d8-4a2c-8d11-47cd5c5e19e6",
    "date":"2021-05-07T09:44:35.000Z"
  },
  ...
]