Get Started with Polygon API

Let's look at the step-by-step instructions for getting an API key.

In order to use Polygon APIs, we first need to create an account on Polygon.io.

Create an account

Follow the steps below to create an account on Polygon successfully:

  1. Go to the official Polygon page.

  2. Click “Get your Free API Key.”

  3. Enter your credentials in the given fields.

  4. Click “Sign Up.”

  5. A successful sign-up will take you to the dashboard of Polygon.

The slides given below demonstrate the process of creating an account on Polygon.

Get the API key

To retrieve the API key, follow the steps given below:

  1. Log in to your Polygon account.

  2. Scroll down until you see “API Keys.”

  3. Copy the API key.

The slides below demonstrate the process of getting an API key.

Save the API key

Now that we have our API key, we can use it to access any endpoint available on Polygon.io. Let’s start by verifying our API key. To do this, we fetch news articles related to tickers using an endpoint available in Polygon. 

Click the “Edit” button in the code widget below and enter the API you copied from Polygon. After that, click “Save” to replace the value of the API key throughout the course. Click “Run” to execute the 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/v2/reference/news');
// 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 fetchTickerNewsJSON() {
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
fetchTickerNewsJSON();

If the API key is valid, we’ll get a list of news articles related to different tickers. This endpoint will be discussed in detail later in the course.

Now that we have saved and verified our API key, let’s start learning about the different endpoints available in Polygon.