API Connections in Code
Last updated
Was this helpful?
Last updated
Was this helpful?
The rule logic you define will run on your end user's browser. You may want certain network requests in your rule logic to be performed from Feathery's servers instead for security reasons, such as hiding authorization information from the user. To do so, you can leverage API connectors
, which allow you to run API requests securely from Feathery's servers.
To create a connector, go to API Connectors
on the Logic
page and define the API you would like your rule to use. You need to define the method (ex: get, post), and any headers or query parameters you'd like to automatically include for all requests to that endpoint.
Any data you define in the headers or query parameters (such as sensitive API keys) will not be exposed client side to people filling your form.
After defining the API you want to use, you will be asked to map the response. If you intend to use our Javascript editor to make the API calls, then you can skip this step by pressing the "Skip" button. If you want to use our no-code API connectors feature (which is what this screen below is for), click here for relevant documentation.
Then, go to your rule code and make a network request to the API connector via the feathery.http
interface. By defining the API connector, it will automatically pass in the relevant connector parameters (headers, body, parameters, etc.) on the server side in a secure manner.
You can use the feathery.http
interface in one of two ways - a simple connector name-based approach and a more advanced, customizable approach.
The simplest way to call the API connector is to run feathery.http.connect(<connector name>)
where the name of the connector is what you specified when creating it. This allows for no additional customization of data on top of the connector.
In this approach, you call the connector via feathery.http.<method>(<url>, <data>, <headers>)
. The right connector to use will be inferred based on matching the method and URL passed in to the method and URL defined on API connectors themselves. The URL passed into this request must contain the defined URL of the relevant API connector as a substring.
method
is a standard REST method: get
, post
, put
, patch
, delete
url
is an endpoint you're requesting that contains a defined API connector URL as a substring.
data
is the request body, which you should pass in an Object
or Array
format. This is merged with the request body defined on the connector config itself, if specified.
For example, {email: <email>, name: <name>}
headers
are additional headers you'd like to pass in an Object
format. These are also merged with headers defined on the connector config itself.
For example, {Authorization: 'Bearer <token>', 'Accept-Encoding': 'gzip'}
For get
requests, make sure to append query and URL parameters directly to the URL rather than attempting to set it via data
, which is only used for the request body.
All API connector requests originate from the static IP address 54.177.134.134
. You may whitelist this IP address to improve the security of your endpoint that's receiving Feathery API connector requests.
When defining and using your connectors, you will also have access to backend variables that can be included via double curly braces.
You're looking to fetch a list of dog breeds via https://dog.ceo/api/breeds/list/all
from Feathery's servers. First, create the API connector.
Then, use the feathery.http
interface to access the API connector from your logic rule.