Market Exchange

Learn how to get a list of exchanges available in Polygon.

The exchanges endpoint

A market exchange allows interested users to buy and sell securities. The exchanges endpoint in Polygon provides us with a list of exchanges for stocks, options, and forex in the United States and all global sites available for crypto.

Press + to interact
Market exchange endpoint
Market exchange endpoint

The base URL for this endpoint is as follows:

https://api.polygon.io/v3/reference/exchanges

Request parameters

By default, we get a list of all market exchanges available. However, we can provide some request parameters to limit the search results. Details of these parameters are given in the table below.

Name

Type

Category

Description

asset_class

String

Optional

The type of security.

Available options: stocks, options, forex, and crypto.

locale

String

Optional

Filter results on the basis of location.

Available options: us for stock and options and global for crypto and forex.

Let’s call the exchanges endpoint first without any optional parameters. Click the “Run” button to see the response we get.

Press + to interact
// Importing libraries here
import fetch from "node-fetch";
// Define API key here
const apiKey = '{{API_KEY}}';
// Define endpoint URL here
const endpointUrl = new URL('https://api.polygon.io/v3/reference/exchanges');
// Define Header Parameters here
const headerParameters = {
authorization: `Bearer ${apiKey}`,
};
// Setting API call options
const options = {
method: 'GET',
headers: headerParameters,
};
// Function to make API call
async function MarketExchange() {
try {
const response = await fetch(endpointUrl, options);
// Custom function for printing the API response
printResponse(response);
}
catch (error) {
// Custom function for printing the error message
printError(error);
}
}
// Calling function to make API call
MarketExchange();

Here’s an explanation for the above code:

  • Line 8: We define the endpoint URL.

  • Lines 11–13: We define the API key in the header parameter.

  • Lines 16–19: We define the options parameters and set the request type as GET.

  • Lines 22–32: We define the function, MarketExchange, that calls the endpoint.

    • Lines 23–27: We call the API in a try block and print the response.

    • Lines 28–31: We define a catch block to catch all errors and exceptions and print them.

  • Line 35: We call the MarketExchange function.

The above query returns all available exchanges at Polygon. Let’s try to filter our search by providing some request parameters. Click the “Run” button to see the output.

Press + to interact
// Importing libraries here
import fetch from "node-fetch";
// Define API key here
const apiKey = '{{API_KEY}}';
// Define endpoint URL here
const endpointUrl = new URL('https://api.polygon.io/v3/reference/exchanges');
// Define Header Parameters here
const headerParameters = {
authorization: `Bearer ${apiKey}`,
contentType: 'application/json',
};
// Define Query Parameters here
const queryParameters = new URLSearchParams({
asset_class : 'stocks',
locale: 'us'
});
// Setting API call options
const options = {
method: 'GET',
headers: headerParameters,
};
// Function to make API call
async function MarketExchange() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Custom function for printing the API response
printResponse(response);
} catch (error) {
// Custom function for printing the error message
printError(error);
}
}
// Calling function to make API call
MarketExchange();

In the code above, we define the query parameters in lines 17–20. We limit the response to include only the stock exchange market in the United States.

Try to change the query parameters given in lines 17–20 to get results related to different asset classes.

Response fields

The following table provides attribute details in the response object.

Object

Type

Description

count_integer

Integer

The total number of results to our query.

request_id

String

The ID assigned to our query by the server.

results

Object

The details about exchanges available, such as the ID, market identifier code (MIC), and URL of the exchange’s website.

results.id

Integer

A unique ID given to the exchange by Polygon.

results.type

Enum

The type of exchange.

Possible output: exchange, TRF, or SIP.

results.asset_class

Enum

The asset class the exchange belongs to.

Possible output: stocks, options, crypto, or fx.

results.locale

Enum

The location of the exchange.

Possible output: us or global.

results.name

String

The name of this exchange.

results.acronym

String

The abbreviation used for the exchange.

results.mic

String

The MIC of the exchange.

results.operating_mic

String

The MIC of the entity operating the exchange.

results.participant_id

String

The ID used by systematic investment plans for the exchange.

results.url

String

The URL of the exchange's website.