Building your first connector
This page guides you to manually create a connector using Connector Builder and use it within an automation. We are covering the creation through a manual process so we automatically cover and address points that can otherwise typically be skipped. For example, we will be importing a Swagger definition, where Connector Builder will complete most of the work for you.
The workflow we are building is meant to receive daily Slack messages of stock prices that are of interest. Polygon.io provides a set of free APIs that retrieve stock information and can be used for our purpose. They have a quick signup process that, in return, provides us with an API key to make the API calls that we need to make.
Sign Up with Polygon.io
Create a connector in Connector Builder
polygon.svg
icon from the web to add
their logo to your catalog. If you have any form of API definition at hand (swagger,
yaml, etc.) , you can start with the first tile and let Connector Builder do most of
the configuration work for you.Setup authentication and connect
The Polygon Getting started documentation references that any API call to their platform requires you to send your API key in the headers or as a query parameter. To do this, we need to add it into the headers, like in the following example:
https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/2023-01-09/2023-01-09?apiKey=<your_token>
https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/2023-01-09/2023-01-09?apiKey=<your_token>
where <your_token>
is the API key.
Authorization: Bearer <your_token>
Authorization: Bearer <your_token>
where <your_token>
is the API key.
https://api.polygon.io
.
version
"v2"
section to the Base URL, as this allows us to run some of the
older stock API calls.
Under Settings > Authentication set the Authentication type dropdown to
Personal Access Token (PAT). The Polygon documentation refers to an
API key, but given that it has to be sent as Authorization:
Bearer <your_token>
, it is actually closer to an OAuth style token
and therefore PAT
is technically the better definition. Read more
about authentication types within the documentation.
In the screenshot we put our key as the value
and set it so users
won’t be asked for their key since we are not going to share this connector beyond
our tenant. If, however, you want to share the connector beyond the tenant, don’t
add your own key, but keep Ask the user: yes
so that they are
prompted to subscribe to the Polygon service themselves.
Personal Access Token
that we
currently configured automatically sends Authorization: Bearer
<your_token>
as an auth header, rather than you having to build this
config yourself.Setup a connection with the above configuration by clicking Not connected > Add connection at the top right corner of the screen. Notice how this already works as any other Integration Service connector. Click Connect so that we have a test connection to make API calls to.
Test your API calls
After estabilishing a connection to the third party software, we move on to performing the actual API calls. Navigate to the left side panel to API > Create new resource group. The goal is to get a daily Slack notification on the opening price of a given stock. The endpoint we are going to implement now is Polygon's Daily open/close API.
On the modal from Create new resource group copy what you see on screen from the Polygon docs.
/open-close/{stocksTicker}/{date}
and select
Get record (GETBYID)
under methods, since we select a
single object
, rather than an array of objects. Provide a
display name such as Open - Close for stock. Connector Builder will
automatically convert the {x}
variables to path variables.Send request
at the
top. This creates values for the two path parameters. We can take them from the
usage example in the Polygon docs.Publishing the connector to the catalog
date
parameter is of type
DateTime
and provide the mask as example. Providing
display names
will make your connector show up better within
the Studio activity. You can see an example in the screenshot below:Use the connector in Studio
Having a connector appear in Integration Service is only relevant if you can actually use it. Navigate to the Studio designer of your preference and create a new project. For this example, we will be using Studio Web and will name the project Slack daily stock prices, also making this a daily event. Since we want to receive daily messages, the first activity used in this workflow is a Time Trigger.
When you drag a Polygon activity to the canvas, you are prompted to connect to Polygon.io with your account.
Once a connection is established, configure the Polygon activity to retrieve information on Apple stocks (AAPL). You can hardcode the stock you are interested in but you must format the date to be the runtime date. Next, add a Slack activity to send this info to a channel or yourself .
Polygon’s API only takes in 1 stock at a time but you can configure Studio to do multiple calls through the connector and also notify on UiPath’s daily stock opening price (PATH).