Market Exchange
Learn how to get a list of exchanges available in Polygon.
We'll cover the following
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.
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 |
| String | Optional | The type of security. Available options: |
| String | Optional | Filter results on the basis of location. Available options: |
Let’s call the exchanges
endpoint first without any optional parameters. Click the “Run” button to see the response we get.
// Importing libraries hereimport fetch from "node-fetch";// Define API key hereconst apiKey = '{{API_KEY}}';// Define endpoint URL hereconst endpointUrl = new URL('https://api.polygon.io/v3/reference/exchanges');// Define Header Parameters hereconst headerParameters = {authorization: `Bearer ${apiKey}`,};// Setting API call optionsconst options = {method: 'GET',headers: headerParameters,};// Function to make API callasync function MarketExchange() {try {const response = await fetch(endpointUrl, options);// Custom function for printing the API responseprintResponse(response);}catch (error) {// Custom function for printing the error messageprintError(error);}}// Calling function to make API callMarketExchange();
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.
// Importing libraries hereimport fetch from "node-fetch";// Define API key hereconst apiKey = '{{API_KEY}}';// Define endpoint URL hereconst endpointUrl = new URL('https://api.polygon.io/v3/reference/exchanges');// Define Header Parameters hereconst headerParameters = {authorization: `Bearer ${apiKey}`,contentType: 'application/json',};// Define Query Parameters hereconst queryParameters = new URLSearchParams({asset_class : 'stocks',locale: 'us'});// Setting API call optionsconst options = {method: 'GET',headers: headerParameters,};// Function to make API callasync function MarketExchange() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);// Custom function for printing the API responseprintResponse(response);} catch (error) {// Custom function for printing the error messageprintError(error);}}// Calling function to make API callMarketExchange();
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 |
| Integer | The total number of results to our query. |
| String | The ID assigned to our query by the server. |
| Object | The details about exchanges available, such as the ID, market identifier code (MIC), and URL of the exchange’s website. |
| Integer | A unique ID given to the exchange by Polygon. |
| Enum | The type of exchange. Possible output: |
| Enum | The asset class the exchange belongs to. Possible output: |
| Enum | The location of the exchange. Possible output: |
| String | The name of this exchange. |
| String | The abbreviation used for the exchange. |
| String | The MIC of the exchange. |
| String | The MIC of the entity operating the exchange. |
| String | The ID used by systematic investment plans for the exchange. |
| String | The URL of the exchange's website. |