Market Data Logo
api
Last Update: March 1, 2024

How To Use the Stock Market API — With Examples!

Get real-time and historical market data from the stock market api. Learn quickly with easy to use examples that work right from your browser.

Market Data’s Stock Market API offers both real-time and historical data for all stocks and ETFs traded on U.S. markets. Real-time prices are available using our stock quote endpoint. This endpoint will deliver a full top of book level 1 real-time stock quote. If historical data is what you’re after, you can get historical candlestick data (perfect for charting) using our stock candles endpoint. The candles endpoint is compatible with the TradingView Technical Analysis Charting Library.

You can experiment on our all Stock Market APIs using the AAPL ticker without any need for registration or authentication. The API will respond to all queries as if you were authenticated. Feel free to try any of the examples below by clicking on them and seeing the output in your browser.

Throughout this example, we’ll add the dateformat=timestamp parameter to each link so that you can click the examples and read the dates & times in human-readable format. However, the default date/time output of the API is unix format. Omit the dateformat=timestamp parameter and you can see the output in seconds after the Unix epoch.

Getting Live Stock Data from the API

Live stock market data is available via the quotes API. This API endpoint will fetch a real-time top of book level 1 stock quote for all U.S.-traded stocks and ETFs. By default, both bid, ask, mid, and last prices are displayed. You can control for latency by using the timestamp of the quote. Please note that only users on paid plans will receive real-time data from the API.

Example: https://api.marketdata.app/v1/stocks/quotes/AAPL/

Getting Historical Stock Data from the API

If you need historical candlestick data, use this candles API endpoint. It will return OHLCV candles at whatever resolution you need, as small as 1 minute through monthly. This endpoint provides historical candles only up through the previous trading day.

Read our in-depth tutorial How To Use The Historical Stock Data API for complete details on how to add from and to parameters, filter, sort and limit the data.

Using the Stock Market API with a Software Development Kit

If you’re using Go, you can use our pre-made Market Data Go SDK. This SDK is abstracts away all the details about making API requests and processing the responses and includes pre-made data structures to get up and running quickly.

Using The Stock Market API For Free

If you are looking for free stock market data to get started quickly and inexpensively, we recommend you take advantage of our free trial offer. Sign-up for a 30 day free trial of either our Starter or Trader plans and get 10,000 or 50,000 daily API calls for free with no credit card needed.

If you don’t have a large need for data, you can also use the Free Forever plan and get 100 daily API calls for life.

On this page
    Add a header to begin generating the table of contents
    Share this article
    Comments & Questions
    Shopping Basket
    //