Stock market hours API integration with JQUERY.

Stock market hours API integration with JQUERY.

by Financial Modeling Prep

HTML

<div class="container">
  <div class="stock-name"></div>
</div>

CSS

body {
  font-family: Helvetica Neue, Arial, sans-serif;
  font-size: 14px;
  color: #444;
}

.table {
  border: solid 1px #DDEEEE;
  border-collapse: collapse;
  border-spacing: 0;
  font: normal 13px Arial, sans-serif;
}

.table thead th {
  background-color: #DDEFEF;
  border: solid 1px #DDEEEE;
  color: #336B6B;
  padding: 10px;
  text-align: center;
  text-shadow: 1px 1px 1px #fff;
}

.table tbody td {
  border: solid 1px #DDEEEE;
  color: #333;
  padding: 10px;
  text-shadow: 1px 1px 1px #fff;
  min-width: 80px;
  text-align: center;
}

.stock-name {
  padding: 10px;
}

.container {
  height: 100px;
}

JavaScript

$(document).ready(function() {
  // https://financialmodelingprep.com/developer/docs
  var url = "https://financialmodelingprep.com/api/v3/is-the-market-open";
  $.ajax({
    url: url,
    type: "GET",
    crossDomain: true,
    success: function(response) {

      let resp = response.isTheStockMarketOpen;
      
     var isOpen = 'no';
     
      if(resp.isthemarketopen)
     		isOpen = 'yes';


      $('.stock-name').html('Is the market open today: ' + isOpen);

    },

    error: function(xhr, status) {
      alert("error");
    }

  });
});