Polygon

Learn how to use Polygon with Composio

Overview

SLUG: POLYGON

Description

Polygon.io provides real-time and historical market data APIs for stocks, options, forex, and cryptocurrencies.

Authentication Details

generic_api_key
stringRequired

Connecting to Polygon

Create an auth config

Use the dashboard to create an auth config for the Polygon toolkit. This allows you to connect multiple Polygon accounts to Composio for agents to use.

1

Select App

Navigate to Polygon.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Polygon Auth Config”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using API Key

1from composio import Composio
2
3# Replace these with your actual values
4polygon_auth_config_id = "ac_YOUR_POLYGON_CONFIG_ID" # Auth config ID created above
5user_id = "0000-0000-0000" # UUID from database/app
6
7composio = Composio()
8
9def authenticate_toolkit(user_id: str, auth_config_id: str):
10 # Replace this with a method to retrieve an API key from the user.
11 # Or supply your own.
12 user_api_key = input("[!] Enter API key")
13
14 connection_request = composio.connected_accounts.initiate(
15 user_id=user_id,
16 auth_config_id=auth_config_id,
17 config={"auth_scheme": "API_KEY", "val": {"generic_api_key": user_api_key}}
18 )
19
20 # API Key authentication is immediate - no redirect needed
21 print(f"Successfully connected Polygon for user {user_id}")
22 print(f"Connection status: {connection_request.status}")
23
24 return connection_request.id
25
26
27connection_id = authenticate_toolkit(user_id, polygon_auth_config_id)
28
29# You can verify the connection using:
30connected_account = composio.connected_accounts.get(connection_id)
31print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Polygon toolkit’s playground

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["POLYGON"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Get Aggregates

Description

Tool to fetch custom aggregate ohlcv bars for a stock. use when you need historical price and volume data aggregated by custom intervals over a date range.

Action Parameters

adjusted
booleanDefaults to True
from_
stringRequired
limit
integer
multiplier
integerRequired
sort
string
ticker
stringRequired
timespan
stringRequired
to
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get All Tickers

Description

Tool to retrieve all ticker symbols across asset classes. use when you need to filter by market or exchange and paginate through results.

Action Parameters

active
booleanDefaults to True
cursor
string
exchange
string
limit
integerDefaults to 10
market
string
order
stringDefaults to asc
search
string
sort
string
ticker
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Aggregates

Description

Tool to retrieve aggregate bars for a cryptocurrency over a time range. use when you need to fetch historical bars aggregated by specific time intervals.

Action Parameters

adjusted
booleanDefaults to True
crypto_ticker
stringRequired
from_date
stringRequired
limit
integerDefaults to 5000
multiplier
integerRequired
sort
string
timespan
stringRequired
to_date
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto All Tickers Snapshot

Description

Tool to retrieve snapshots for all cryptocurrency tickers. use when you need a full-market crypto snapshot of the latest values.

Action Parameters

tickers
array

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Exchanges

Description

Tool to retrieve a list of cryptocurrency exchanges supported by polygon. use after setting locale if needed.

Action Parameters

locale
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Grouped Daily

Description

Tool to retrieve daily grouped bars for all cryptocurrencies on a specified date. use when you need a comprehensive end-of-day summary across all crypto tickers.

Action Parameters

adjusted
booleanDefaults to True
date
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Exponential Moving Average (EMA)

Description

Tool to retrieve exponential moving average (ema) for a cryptocurrency ticker. use when you need crypto ema data for analysis after selecting the time window.

Action Parameters

adjusted
booleanDefaults to True
crypto_ticker
stringRequired
expand_underlying
boolean
limit
integerDefaults to 50
order
stringDefaults to desc
series_type
stringRequired
timespan
stringRequired
window
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto MACD Indicator

Description

Tool to retrieve the macd (moving average convergence/divergence) for a crypto ticker. use when you need momentum analysis for a specific cryptocurrency after confirming ticker and parameters.

Action Parameters

adjusted
booleanDefaults to True
expand_underlying
boolean
limit
integerDefaults to 50
order
stringDefaults to desc
series_type
stringDefaults to close
ticker
stringRequired
timespan
stringDefaults to day
window_long
integerDefaults to 26
window_short
integerDefaults to 12
window_signal
integerDefaults to 9

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto RSI Indicator

Description

Tool to retrieve the relative strength index (rsi) for a crypto ticker. use when you need momentum analysis for crypto assets after specifying ticker, timeframe, and optional parameters.

Action Parameters

adjusted
booleanDefaults to True
limit
integerDefaults to 100
order
stringDefaults to desc
series_type
stringDefaults to close
ticker
stringRequired
timeframe
stringRequired
timestamp
string
window
integerDefaults to 14

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Simple Moving Average (SMA)

Description

Tool to retrieve the simple moving average (sma) for a given crypto ticker. use when you need sma values for a crypto asset after confirming ticker, timespan, and window size.

Action Parameters

adjusted
booleanDefaults to True
crypto_ticker
stringRequired
expand_underlying
boolean
limit
integerDefaults to 5000
order
stringDefaults to desc
series_type
stringDefaults to close
timespan
stringRequired
window
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Last Trade

Description

Tool to retrieve the last trade for a specified cryptocurrency pair. use when you need the most recent trade details after specifying both symbols.

Action Parameters

from_symbol
stringRequired
to_symbol
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Open/Close

Description

Tool to fetch daily open and close prices for a given crypto pair on a specified date. use after specifying both currency symbols and the date.

Action Parameters

base
stringRequired
date
stringRequired
quote
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Previous Close

Description

Tool to retrieve previous day’s close for a crypto ticker. use when you need the last closing price of a cryptocurrency before analysis or trading.

Action Parameters

adjusted
booleanDefaults to True
crypto_ticker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Crypto Ticker Book

Description

Tool to retrieve the full l2 order book for a crypto ticker. use when you need a snapshot of combined bids and asks for market depth analysis.

Action Parameters

ticker
stringRequired

Action Response

data
objectRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get Crypto Trades

Description

Tool to fetch historical trade data for a cryptocurrency ticker. use when you need tick-level trades within a time range.

Action Parameters

crypto_ticker
stringRequired
limit
integerDefaults to 1000
order
string
sort
string
timestamp
string
timestamp.gt
string
timestamp.gte
string
timestamp.lt
string
timestamp.lte
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Dividends

Description

Tool to retrieve dividend data for stocks. use when you need corporate dividend information for specific tickers.

Action Parameters

cash_amount
number
declaration_date
string
dividend_type
string
ex_dividend_date
string
frequency
string
limit
integer
order
string
payment_date
string
record_date
string
skip
integer
sort
string
ticker
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Aggregates

Description

Tool to retrieve aggregate bars for a forex pair over a date range. use when you need custom ohlc bars for forex currency pairs within specified time span.

Action Parameters

adjusted
booleanDefaults to True
forex_ticker
stringRequired
from_
stringRequired
limit
integer
multiplier
integerRequired
sort
string
timespan
stringRequired
to
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Grouped Daily Bars

Description

Tool to retrieve daily grouped ohlc bars for all forex currency pairs on a specified date. use when you need aggregated forex data after confirming the date parameter.

Action Parameters

adjusted
booleanDefaults to True
date
Required

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Historical Quotes

Description

Tool to retrieve historical forex quotes for a currency pair over a time range. use when you need bid/ask quotes for an fx ticker between timestamps or dates. use after confirming the forex ticker symbol.

Action Parameters

fxTicker
stringRequired
limit
integerDefaults to 1000
order
string
sort
string
timestamp
string
timestamp.gt
string
timestamp.gte
string
timestamp.lt
string
timestamp.lte
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Locales

Description

Tool to list locales supported by polygon's forex asset class. use when you need available locale codes for regional filtering in fx endpoints.

Action Parameters

asset_class
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Market Holidays

Description

Tool to retrieve upcoming forex market holidays. use when you need a forecast of future fx market closures and hours before scheduling trades.

Action Parameters

Action Response

data
arrayRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Markets

Description

Tool to retrieve a list of exchanges available for the forex (fx) asset class. uses the polygon v3 reference exchanges endpoint.

Action Parameters

cursor
string
limit
integer
locale
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Market Status

Description

Tool to retrieve current forex market status. use when you need to know if the forex market is open or closed.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Previous Close

Description

Tool to retrieve previous day's close for a forex ticker. use when you need the last closing price of a forex currency pair before analysis or trading.

Action Parameters

adjusted
booleanDefaults to True
forexTicker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Snapshot Losers

Description

Tool to retrieve the current snapshot of the top losers in the forex market. use when you need up-to-date information on the worst-performing forex pairs.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Forex Ticker Details

Description

Tool to retrieve detailed information for a forex ticker. use when you need an overview of a currency pair including market and asset data.

Action Parameters

date
ticker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Futures Aggregates

Description

Tool to retrieve historical ohlcv aggregates for a futures contract. use when you need aggregated price and volume data for a futures contract over specified time windows.

Action Parameters

limit
integer
resolution
string
sort
string
ticker
stringRequired
window_start.gte
string
window_start.lte
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Futures Products

Description

Tool to retrieve a comprehensive list of futures products with advanced filtering. use when you need to filter futures listings by date, sector, exchange, or type.

Action Parameters

as_of
string
asset_class
string
asset_sub_class
string
limit
integerDefaults to 100
name
string
name_search
string
sector
string
sort
string
sub_sector
string
trading_venue
string
type
stringDefaults to all

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Futures Product Schedules

Description

Tool to retrieve trading schedules for a futures product. use when you need daily trading session schedules for a given product code.

Action Parameters

limit
integerDefaults to 100
product_code
stringRequired
session_end_date
string
sort
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Futures Quotes

Description

Tool to retrieve real-time quote data for a specified futures contract ticker. use after confirming the exact futures ticker identifier (e.g., 'gcj5').

Action Parameters

limit
integer
session_end_date
string
sort
string
ticker
stringRequired
timestamp
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Futures Schedules

Description

Tool to retrieve futures trading schedules. use when you need trading schedules for all futures contracts on a specific date.

Action Parameters

limit
integer
session_end_date
string
sort
string
trading_venue
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Futures Trades

Description

Tool to retrieve tick-level trade data for a specified futures contract. use when you need detailed trade data over a time range.

Action Parameters

limit
integerDefaults to 1000
session_end_date
string
session_end_date.gt
string
session_end_date.gte
string
session_end_date.lt
string
session_end_date.lte
string
sort
string
ticker
stringRequired
timestamp
string
timestamp.gt
string
timestamp.gte
string
timestamp.lt
string
timestamp.lte
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Upcoming Market Holidays

Description

Tool to retrieve upcoming market holidays and half-day closures. use when you need to look up upcoming exchange holidays and early closures.

Action Parameters

Action Response

data
arrayRequired
error
string
successful
booleanRequired

Tool Name: Get Market Status

Description

Tool to retrieve current market status. use when you need to know if u.s. exchanges are open, closed, or on holiday.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get News

Description

Tool to retrieve recent news articles related to a ticker. use when you need to fetch financial news after identifying a ticker symbol.

Action Parameters

cursor
string
limit
integer
order
string
published_utc.gte
string
published_utc.lte
string
sort
string
ticker
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Stock Open/Close

Description

Tool to fetch daily open and close prices for a stock on a specific date. use when you need daily ohlc with pre/post-market prices.

Action Parameters

adjusted
booleanDefaults to True
date
stringRequired
stocksTicker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Option Aggregates

Description

Tool to fetch custom ohlcv bars for an options contract over a time range. use when you need to analyze option price movements at regular intervals.

Action Parameters

adjusted
booleanDefaults to True
from
stringRequired
limit
integer
multiplier
integerRequired
option_ticker
stringRequired
sort
string
timespan
stringRequired
to
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Option Chain Snapshot

Description

Tool to fetch a real-time snapshot of all option contracts for an underlying asset. use after selecting the underlying ticker to retrieve live option chain data.

Action Parameters

contract_type
string
expiration_date
limit
integer
order
string
sort
string
strike_price
number
underlying_ticker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Option Contract Details

Description

Tool to retrieve detailed information about a specific options contract. use when you need a comprehensive overview of contract specifications by ticker, optionally as of a specific date.

Action Parameters

as_of
string
contract
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Option Contracts

Description

Tool to list option contracts with filters. use when you need to discover or page through option contracts by ticker, expiration, strike, or point-in-time.

Action Parameters

as_of
string
contract_type
stringRequired
expiration_date
string
expired
boolean
limit
integerDefaults to 10
order
string
sort
string
strike_price
number
ticker
string
underlying_ticker
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Option Snapshot

Description

Tool to retrieve a real-time snapshot for a single option contract. use when you need up-to-the-minute quotes, trades, greeks, and metrics for a specified option contract.

Action Parameters

option_contract
stringRequired
underlying_asset
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Previous Close

Description

Tool to get previous trading day’s ohlc and volume for a stock. use when you need the last day’s open, high, low, close, and volume for a given ticker.

Action Parameters

adjusted
booleanDefaults to True
ticker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get reference conditions

Description

Tool to retrieve market condition code mappings. use when you need definitions of trade or quote condition codes after confirming asset class and data type.

Action Parameters

asset_class
string
data_type
string
id
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get reference exchanges

Description

Tool to retrieve supported exchanges and their details. use when you need a list of exchanges filtered by asset class or locale.

Action Parameters

asset_class
string
locale
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get All Stock Tickers Snapshot

Description

Tool to retrieve the current market snapshot for all stock tickers. use when you need real-time ohlcv, trades, and quotes across the entire us stock market in one call.

Action Parameters

include_otc
boolean
tickers
array

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Stock Snapshot Losers

Description

Tool to retrieve the current snapshot of the top losers in the u.s. stock market. use when you need up-to-date information on the worst-performing stocks.

Action Parameters

include_otc
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Stock Snapshot Ticker

Description

Tool to retrieve the current snapshot of a specific stock ticker. use when you need the most recent market snapshot after specifying the ticker symbol.

Action Parameters

ticker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Stock Splits

Description

Tool to retrieve stock split events. use when you need corporate stock split data filtered by ticker or date range. example: "get splits for aapl between 2021-01-01 and 2021-12-31".

Action Parameters

execution_date.gte
string
execution_date.lte
string
limit
integer
order
string
sort
string
ticker
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Exponential Moving Average (EMA)

Description

Tool to fetch exponential moving average (ema) for a given stock ticker. use when you need historical ema data after confirming ticker, timespan, and window size.

Action Parameters

adjusted
booleanDefaults to True
expand_underlying
boolean
limit
integerDefaults to 50
order
stringDefaults to desc
series_type
stringDefaults to close
ticker
stringRequired
timespan
stringRequired
window
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Simple Moving Average (SMA)

Description

Tool to fetch simple moving average (sma) for a given stock ticker. use when you need historical sma data after confirming ticker, timespan, and window size.

Action Parameters

adjusted
booleanDefaults to True
expand_underlying
boolean
limit
integerDefaults to 50
order
stringDefaults to desc
series_type
stringDefaults to close
ticker
stringRequired
timespan
stringRequired
window
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Ticker Details

Description

Tool to retrieve detailed information for a ticker. use when you need an overview of a ticker including company info, market data, and identifiers.

Action Parameters

date
ticker
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Ticker Events

Description

Tool to retrieve corporate events for a specific ticker. use when you need the timeline of corporate actions for a given ticker.

Action Parameters

ticker
stringRequired
types
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Ticker Types

Description

Tool to retrieve all ticker types supported by polygon.io. use after authenticating to explore ticker categories.

Action Parameters

asset_class
string
limit
integer
offset
integer
type
string

Action Response

data
objectRequired
error
string
successful
booleanRequired