# Get Historical Prices — Polygon

> Fetches historical price data for a specified stock ticker within a date range. See the documentation

- Key: `polygon-get-historical-prices`
- Type: Action (Read-only)
- Version: 0.0.3
- App: Polygon (`polygon`) — https://pipedream.com/apps/polygon.md
- This page (HTML): https://pipedream.com/apps/polygon/actions/get-historical-prices
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/polygon/actions/get-historical-prices/get-historical-prices.mjs

## Description

Fetches historical price data for a specified stock ticker within a date range. [See the documentation](https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `stockTicker` | `string` | Yes | Specify a case-sensitive ticker symbol. For example, AAPL represents Apple Inc. Options are loaded from the connected account. |
| `multiplier` | `integer` | Yes | The size of the timespan multiplier. |
| `timespan` | `string` | Yes | The size of the time window. |
| `from` | `string` | Yes | The start of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp. |
| `to` | `string` | Yes | The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp. |
| `adjusted` | `boolean` | No | Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. |
| `sort` | `string` | No | Sort the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return results in descending order (newest at the top). |
| `limit` | `integer` | No | Limits the number of base aggregates queried to create the aggregate results. Max 50000 and Default 5000. Read more about how limit is used to calculate aggregate results in our article on Aggregate Data API Improvements. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "polygon",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "polygon-get-historical-prices",
  arguments: {
    stockTicker: "Stock Ticker",
    multiplier: 10,
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "polygon-get-historical-prices",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    polygon: { authProvisionId: "apn_xxxxxxx" },
    stockTicker: "Stock Ticker",
    multiplier: 10,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "polygon-get-historical-prices",
    "configured_props": {
      "polygon": { "authProvisionId": "apn_xxxxxxx" },
      "stockTicker": "Stock Ticker",
      "multiplier": 10
    }
  }'
```

---

- App: https://pipedream.com/apps/polygon.md · All apps: https://pipedream.com/apps
