Additional Endpoints

Let's look at some other endpoints Polygon provides.

Ticker types endpoint

The ticker types endpoint can be used to get a list of all ticker types available for different securities on Polygon.

Press + to interact
The ticker types endpoint
The ticker types endpoint

The base URL for the ticker endpoint is as follows:

https://api.polygon.io/v3/reference/tickers/types

Request parameters

By default, we get a list of all available ticker types. However, we can filter our search by providing some additional request parameters. An overview of the request parameters that can be provided to this endpoint is given in the table below:

Name

Type

Category

Description

asset_class

String

Optional

The type of security whose ticker types we want.

Accepted input: stocks, options, crypto, and forex.

locale

String

Optional

This is used to filter our search by location.

Accepted input: us for stocks, options, and forex, and global for cryptocurrency.

Let’s call this endpoint in the following code. Click the “Run” button to view the output of the ticker types endpoint.

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/tickers/types');
// 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 TickerType() {
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
TickerType();

Here’s an explanation for the above code:

  • Line 8: We define the endpoint URL.

  • Line 22-32: We define the TickerType function, which calls the endpoint.

  • Line 35: We call the TickerType function.

Response fields

The following table provides details of the attributes in the response object.

Name

Type

Description

results

Object

This contains details about tickers.

count

Integer

The number of results returned.

status

String

The response status to our query.

request_id

String

The ID associated with our query.

Conditions endpoint

Conditions define the rules of buying and selling securities in any market. They are used as guidelines by traders to make important decisions. The conditions endpoint gives a list of conditions used by Polygon.

Press + to interact
The conditions endpoint
The conditions endpoint

The base URL for this endpoint is as follows:

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

Request parameters

By default, the conditions endpoint returns a list of all conditions that Polygon uses. However, we can filter these results by providing some additional request parameters.

The following table gives details about possible request parameters:

Name

Type

Category

Description

asset_class


String

Optional

The specific security we are looking for.

Possible input parameters: stocks, options, fx, and crypto.

data_type

String

Optional

The type of data we are looking for.

Possible input parameters: trade, bbo, and nbbo.

id

Integer

Optional

The ID of a specific condition we are looking for.

sip

String

Optional

Filter response based on securities information processors.

Possible input parameters: CTA, UTP, and OPRA.

order

String

Optional

Order responses based on the sort field.

Possible input parameters: asc and desc for ascending and descending, respectively.

limit

Integer

Optional

The number of results required. By default, the limit is 10 and the maximum input is 1000.

sort

String

Optional

This sorts the results based on the given input. Possible input parameters: asset_class, id, type, name, data_types, or legacy.

Let’s see the response to this query with its default parameters in the following code:

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/conditions');
// Define Header Parameters here
const headerParameters = {
authorization: `Bearer ${apiKey}`,
contentType: 'application/json',
};
// Setting API call options
const options = {
method: 'GET',
headers: headerParameters,
};
// Function to make API call
async function Conditions() {
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
Conditions();

Here’s an explanation for the above code:

  • Line 8: We define the endpoint URL.

  • Lines 23–32: We define the Conditions function, which calls the endpoint.

  • Line 35: We call the Conditions function.

Response fields

The following table gives details about the attributes in the response object:

Name

Type

Description

results

Object

This includes details about each condition.

status

String

The response status to our query.

request_id

String

The ID associated with our query.

count

Integer

The number of results given in response.

next_url

String

The URL to the next page.