# 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.

Source: https://www.marketdata.app/api/stocks/stock-market-api/

---

(image: The letters API at the centre of a cyan network diagram, its spokes radiating to eight ringed nodes on dark navy.)

-   [Market Data API](/topics/api/)
-   [Stock Data](/topics/data/stocks/)
-   [Stock Market API](/topics/api/stocks/)
-   [Tutorials](/tutorials/)

# 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.

-   Last updated February 21, 2026

**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](/docs/api/stocks/quotes). 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](/docs/api/stocks/candles). The candles endpoint is compatible with the [TradingView Technical Analysis Charting Library](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/?feature=technical-analysis-charts).

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.

\[aux\_highlight style=”aux-highlight-yellow” extra\_classes=””\]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.\[/aux\_highlight\]

## Getting Live Stock Data from the API

-   Stock Quotes API Endpoint: `https://api.marketdata.app/v1/stocks/quotes/{symbol}/`
-   [Stock Quotes API Endpoint Docs](/docs/api/stocks/quotes/)

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/](https://api.marketdata.app/v1/stocks/quotes/AAPL/?dateformat=timestamp)

## Getting Historical Stock Data from the API

-   Stock Candles API Endpoint: `https://api.marketdata.app/v1/stocks/candles/{resolution}/{symbol}/`
-   [Stock Candles API Endpoint Docs](/docs/api/stocks/candles)

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.

-   Daily Candles Example: [https://api.marketdata.app/v1/stocks/candles/D/AAPL/](https://api.marketdata.app/v1/stocks/candles/D/AAPL/?dateformat=timestamp)
-   4 Hour Candles Example: [https://api.marketdata.app/v1/stocks/candles/4H/AAPL/](https://api.marketdata.app/v1/stocks/candles/4H/AAPL/?dateformat=timestamp)
-   1 Minute Candles Example: [https://api.marketdata.app/v1/stocks/candles/1/AAPL/](https://api.marketdata.app/v1/stocks/candles/1/AAPL/?dateformat=timestamp)

Read our in-depth tutorial [How To Use The Historical Stock Data API](/api/stocks/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](/sdk/go/golang-stock-api/). 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](/api/stocks/free-stock-market-api/) 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.
