> ## Documentation Index
> Fetch the complete documentation index at: https://docs.financialdatasets.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Historical

> Get historical stock prices for any US ticker. Daily, weekly, monthly, or yearly OHLCV data.

### Overview

The Prices API lets you pull end-of-day (EOD) historical prices for a given ticker like Apple, Microsoft, and more.

You can get prices by the day, week, month, or year going back 3 years.

The data is perfect for backtesting trading strategies, analyzing price patterns, rendering charts, and more.

To get started, please create an account and grab your <b>API key</b> at [financialdatasets.ai](https://financialdatasets.ai).

You will use the API key to authenticate your API requests.

### Coverage

| Tickers | Years of Coverage | Updated    |
| ------- | ----------------- | ---------- |
| 15,000+ | 3+ years          | End of day |

### Available Tickers

You can fetch a list of available tickers with a `GET` request to:
[https://api.financialdatasets.ai/prices/tickers/](https://api.financialdatasets.ai/prices/tickers/)

### Required Parameters

* `ticker` — the stock ticker symbol (e.g., AAPL, NVDA)
* `interval` — `day`, `week`, `month`, or `year`
* `start_date` — start date in YYYY-MM-DD format
* `end_date` — end date in YYYY-MM-DD format

### Getting Started

There are only 3 steps for making a successful API call:

1. Add your API key to the header of the request as `X-API-KEY`.
2. Add the required query params: `ticker`, `interval`, `start_date`, and `end_date`.
3. Execute the API request.

### Example

```python Prices theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import requests

# add your API key to the headers
headers = {
    "X-API-KEY": "your_api_key_here"
}

# set your query params
ticker = 'AAPL'
interval = 'day'         # possible values are {'day', 'week', 'month', 'year'}
start_date = '2025-01-02'
end_date = '2025-01-05'

# create the URL
url = (
    f'https://api.financialdatasets.ai/prices/'
    f'?ticker={ticker}'
    f'&interval={interval}'
    f'&start_date={start_date}'
    f'&end_date={end_date}'
)

# make API request
response = requests.get(url, headers=headers)

# parse prices from the response
prices = response.json().get('prices')
```

### Example Response

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
    "prices": [
        {
            "ticker": "AAPL",
            "open": 243.85,
            "close": 243.36,
            "high": 244.15,
            "low": 241.91,
            "volume": 40230800,
            "time": "2025-01-02"
        },
        {
            "ticker": "AAPL",
            "open": 243.36,
            "close": 245.00,
            "high": 245.55,
            "low": 242.80,
            "volume": 38420500,
            "time": "2025-01-03"
        },
        ...
    ]
}
```


## OpenAPI

````yaml GET /prices
openapi: 3.0.1
info:
  title: Financial Datasets API
  description: >-
    Stock market API with real-time and historical financial data for 27,000+
    tickers over 30+ years. Financial statements, equity prices, insider trades,
    SEC filings, and more.
  version: 1.0.0
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  contact:
    name: API Support
    url: mailto:support@financialdatasets.ai
    email: support@financialdatasets.ai
  termsOfService: https://financialdatasets.ai/terms-of-use
servers:
  - url: https://api.financialdatasets.ai/
    description: Production server
security:
  - X-API-KEY: []
tags:
  - name: Financial Statements
    description: Access to income statements, balance sheets, and cash flow statements
  - name: Market Data
    description: Real-time and historical price data
  - name: Company Information
    description: Company facts like ticker, name, and description
  - name: Earnings
    description: Earnings data and related information
  - name: News
    description: Real-time and historical news articles
  - name: SEC Filings
    description: SEC filings and regulatory documents
  - name: Insider Trades
    description: Insider trading activity and transactions
  - name: Activist Ownership
    description: Activist stakes from SEC Schedule 13D filings, in real time
  - name: Beneficial Ownership
    description: >-
      Holders of more than 5% of a company's shares, from SEC Schedules 13D and
      13G
  - name: Insider Ownership
    description: Insider ownership statements from SEC Forms 3 and 5
  - name: Institutional Holdings
    description: SEC-direct 13F equity holdings of institutional investment managers
  - name: Index Funds
    description: >-
      ETF and index-fund holdings, weights, and the funds that hold a given
      security
  - name: Financial Metrics
    description: Financial ratios, metrics, and key performance indicators
  - name: Macroeconomics
    description: Real-time and historical macroeconomic data like interest rates
  - name: KPIs
    description: Sector-specific operational KPIs extracted from earnings releases.
paths:
  /prices:
    get:
      tags:
        - Market Data
      summary: Get historical stock price data
      description: Get end-of-day (EOD) historical price data for stocks.
      operationId: getPrices
      parameters:
        - name: ticker
          in: query
          description: The stock ticker symbol (e.g. AAPL, MSFT).
          required: true
          schema:
            type: string
        - name: interval
          in: query
          description: The time interval for the price data.
          required: true
          schema:
            type: string
            enum:
              - day
              - week
              - month
              - year
        - name: start_date
          in: query
          description: 'The start date for the price data (format: YYYY-MM-DD).'
          required: true
          schema:
            type: string
            format: date
        - name: end_date
          in: query
          description: 'The end date for the price data (format: YYYY-MM-DD).'
          required: true
          schema:
            type: string
            format: date
      responses:
        '200':
          description: Price data response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PricesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/PaymentRequiredError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  schemas:
    PricesResponse:
      type: object
      properties:
        ticker:
          type: string
          description: The ticker symbol.
        prices:
          type: array
          items:
            $ref: '#/components/schemas/Price'
    Price:
      type: object
      properties:
        open:
          type: number
          description: The open price of the ticker in the given time period.
        close:
          type: number
          description: The close price of the ticker in the given time period.
        high:
          type: number
          description: The high price of the ticker in the given time period.
        low:
          type: number
          description: The low price of the ticker in the given time period.
        volume:
          type: integer
          nullable: true
          description: The trading volume of the ticker in the given time period.
        time:
          type: string
          description: The human-readable time format of the price in UTC.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: A short error message.
        message:
          type: string
          description: A more detailed error message.
  responses:
    BadRequestError:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Bad Request
            message: Invalid request parameters
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Unauthorized
            message: Invalid API key provided
    PaymentRequiredError:
      description: The request requires a paid subscription
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Payment Required
            message: >-
              This endpoint requires a paid subscription. Please upgrade your
              plan.
    NotFoundError:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Not Found
            message: Ticker XXXX not found
  securitySchemes:
    X-API-KEY:
      type: apiKey
      name: X-API-KEY
      description: API key for authentication.
      in: header

````