--- title: Real-Time Prices tg h sidebar_position: 1 tags: - "API: High Usage" --- Get real-time midpoint prices for one or more stocks. This endpoint returns real-time prices for stocks, using the [SmartMid](https://www.marketdata.app/smart-mid/) model. import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; ## Endpoint ``` https://api.marketdata.app/v1/stocks/prices/{symbol}/ ``` or ``` https://api.marketdata.app/v1/stocks/prices/?symbols={symbol1},{symbol2},... ``` #### Method ``` GET ``` ## Request Examples **GET** [https://api.marketdata.app/v1/stocks/prices/AAPL/](https://api.marketdata.app/v1/stocks/prices/AAPL/) ```js title="app.js" fetch("https://api.marketdata.app/v1/stocks/prices/AAPL/") .then((res) => { console.log(res); }) .catch((err) => { console.log(err); }); ``` ```python title="app.py" from marketdata.client import MarketDataClient client = MarketDataClient() prices = client.stocks.prices("AAPL") print(prices) ``` **GET** [https://api.marketdata.app/v1/stocks/prices/?symbols=AAPL,META,MSFT](https://api.marketdata.app/v1/stocks/prices/?symbols=AAPL,META,MSFT) ```js title="app.js" fetch("https://api.marketdata.app/v1/stocks/prices/?symbols=AAPL,META,MSFT") .then((res) => { console.log(res); }) .catch((err) => { console.log(err); }); ``` ```python title="app.py" from marketdata.client import MarketDataClient client = MarketDataClient() prices = client.stocks.prices(["AAPL", "META", "MSFT"]) print(prices) ``` ## Response Example ```json { "s": "ok", "symbol": ["AAPL", "META", "MSFT"], "mid": [149.07, 320.45, 380.12], "change": [-2.052, 1.23, -0.85], "changepct": [-0.0088, 0.0039, -0.0022], "updated": [1663958092, 1663958092, 1663958092] } ``` ## Request Parameters You can provide the symbol(s) in one of two ways: 1. As part of the URL path: - **symbol** `string` The company's ticker symbol. 2. As a query parameter: - **symbols** `string` Comma-separated list of ticker symbols. - **extended** `boolean` Control the inclusion of extended hours data in the price output. Defaults to `true` if omitted. - When set to `true`, the most recent price is always returned, without regard to whether the market is open for primary trading or extended hours trading. - When set to `false`, only prices from the primary trading session are returned. When the market is closed or in extended hours, a historical price from the last closing bell of the primary trading session is returned instead of an extended hours price. ## Response Attributes - **s** `string` Will always be `ok` when there is data for the symbols requested. - **symbol** `array[string]` Array of ticker symbols that were requested. - **mid** `array[number]` Array of midpoint prices, as calculated by the [SmartMid](https://www.marketdata.app/smart-mid/) model. - **change** `array[number]` Array of price changes in currency units compared to the closing price of the previous primary trading session. - **changepct** `array[number]` Array of price changes in percent, expressed as a decimal, compared to the closing price of the previous day. For example, a 3% change will be represented as 0.03. :::note - When the market is open for primary trading, **change** and **changepct** are always calculated using the current midpoint price and the last primary session close. When the market is closed or in extended hours, this criteria is also used as long as `extended` is omitted or set to `true`. - When `extended` is set to `false`, and the market is closed or in extended hours, prices from extended hours are not considered. The values for **change** and **changepct** will be calculated using the last two closing prices instead. ::: - **updated** `array[date]` Array of date/times for each stock price. - **s** `string` Status will only be `no_data` if no prices can be found for all of the symbols. If a price for any symbol can be returned, the request will be successful. - **s** `string` Status will be `error` if the request produces an error response. - **errmsg** `string` An error message. ## Usage Information ### Data Availability This endpoint is available to all users and does not require any exchange entitlements. All users receive real-time prices regardless of their plan or access level. **Cached, delayed, and historical data are not available on this endpoint - only real-time prices are provided.** | User Type | Exchange Entitlement | Price Type | |-----------|---------------------|------------| | All Users | Not Required | Real-time | ### Pricing The cost of using the stock prices API endpoint is 1 credit per symbol. | Data Type | Cost Basis | Credits Required per Unit | |--------------------|---------------------------|---------------------------| | Real-Time Data | Per symbol | 1 credit | | Cached Data | Not available | N/A | | Delayed Data | Not available | N/A | | Historical Data | Not available | N/A |